Package javax.faces.application

Examples of javax.faces.application.NavigationCase


       
        facesContext.getViewRoot().setViewId("/x.jsp");
       
        NavigationHandlerImpl nh = new NavigationHandlerImpl();

        NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");

        Assert.assertEquals("/go.jsp", nc.getToViewId(facesContext));
    }   
View Full Code Here


       
        facesContext.getViewRoot().setViewId("/x.jsp");
       
        NavigationHandlerImpl nh = new NavigationHandlerImpl();

        NavigationCase nc = nh.getNavigationCase(facesContext, null, "go");

        Assert.assertEquals("/a.jsp", nc.getToViewId(facesContext));
    }
View Full Code Here

        facesContext.getViewRoot().setViewId("/a.jsp");
       
        NavigationHandlerImpl nh = new NavigationHandlerImpl();

        NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");

        Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
    }
View Full Code Here

        facesContext.getViewRoot().setViewId("/a.jsp");
       
        NavigationHandlerImpl nh = new NavigationHandlerImpl();

        NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null);

        Assert.assertNull(nc);
    }
View Full Code Here

                    }
                    return map2;
                }
            };
   
            NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");
   
            Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
        }
    }
View Full Code Here

                    }
                    return map2;
                }
            };
   
            NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "nogo");
   
            Assert.assertEquals("/c.jsp", nc.getToViewId(facesContext));
        }
    }
View Full Code Here

                    }
                    return map2;
                }
            };
   
            NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", null);
   
            //If the <if> element is absent, only match a non-null outcome
            Assert.assertNull(nc);
        }
    }
View Full Code Here

                    }
                    return map2;
                }
            };
   
            NavigationCase nc = nh.getNavigationCase(facesContext, "#{rules.go}", "go");
   
            Assert.assertEquals("/b.jsp", nc.getToViewId(facesContext));
        }
    }
View Full Code Here

    {
        NavigationHandlerImpl nh = new NavigationHandlerImpl();
       
        // get the NavigationCase
        // note that the URL parameters can be separated via & or &amp;
        NavigationCase navigationCase = nh.getNavigationCase(facesContext, null,
                "test.xhtml?faces-redirect=true&a=b&amp;faces-include-view-params=true&amp;c=d&e=f");
       
        // created the expected parameter map
        Map<String, List<String>> expected = new HashMap<String, List<String>>();
        expected.put("a", Arrays.asList("b"));
        expected.put("c", Arrays.asList("d"));
        expected.put("e", Arrays.asList("f"));
        // note that faces-redirect and faces-include-view-params
        // should not be added as a parameter
       
        Assert.assertEquals(expected, navigationCase.getParameters());
        Assert.assertTrue("faces-include-view-params=true in the query String must "
                + "set includeViewParams to true.", navigationCase.isIncludeViewParams());
        Assert.assertTrue("redirect=true in the query String must "
                + "set redirect to true.", navigationCase.isRedirect());
    }
View Full Code Here

            throw new FacesException("Navigation handler must be an instance of " +
                    "ConfigurableNavigationHandler for using h:link or h:button");
        }
        ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) nh;
        // fromAction is null because there is no action method that was called to get the outcome
        NavigationCase navigationCase = navigationHandler.getNavigationCase(facesContext, null, outcome);

        // when navigation case is null, force the "link" to be rendered as text
        if (navigationCase == null) {
            return null;
        }

        // handle URL parameters
        Map<String, List<String>> parameters = new HashMap<String, List<String>>();
        List<UIParameter> validParams = getValidUIParameterChildren(
                facesContext, component.getChildren(), true, false);
        for (UIParameter param : validParams) {
            String name = param.getName();
            Object value = param.getValue();
            if (parameters.containsKey(name)) {
                parameters.get(name).add(value.toString());
            } else {
                List<String> list = new ArrayList<String>(1);
                list.add(value.toString());
                parameters.put(name, list);
            }
        }

        // handle NavigationCase parameters
        Map<String, List<String>> navigationCaseParams = navigationCase.getParameters();
        if (navigationCaseParams != null) {
            parameters.putAll(navigationCaseParams);
        }

        // In theory the precedence order to deal with params is this:
        // component parameters, navigation-case parameters, view parameters
        // getBookmarkableURL deal with this details.
        ViewHandler viewHandler = facesContext.getApplication().getViewHandler();
        String href = viewHandler.getBookmarkableURL(facesContext,
                navigationCase.getToViewId(facesContext), parameters,
                navigationCase.isIncludeViewParams() || component.isIncludeViewParams());

        // handle fragment (viewId#fragment)
        String fragment = (String) component.getAttributes().get("fragment");
        if (fragment != null) {
            fragment = fragment.trim();
View Full Code Here

TOP

Related Classes of javax.faces.application.NavigationCase

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.