Package javax.faces.application

Examples of javax.faces.application.NavigationHandler


        String outcome = component.getOutcome();
        outcome = (outcome == null) ? facesContext.getViewRoot().getViewId() : outcome;
        outcome = ((outcome == null) ? STR_EMPTY : outcome.trim());

        // Get the correct URL for the outcome.
        NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
        if (!(nh instanceof ConfigurableNavigationHandler)) {
            throw new FacesException("Navigation handler must be an instance of " +
                    "ConfigurableNavigationHandler for using h:link or h:button");
        }
        ConfigurableNavigationHandler navigationHandler = (ConfigurableNavigationHandler) nh;
View Full Code Here


                Object result = method.invoke(this);
                if (result != null)
                {
                    String outcome = result.toString();
                    // Retrieve the NavigationHandler instance..
                    NavigationHandler navHandler = context.getApplication().getNavigationHandler();
                    // Invoke nav handling..
                    navHandler.handleNavigation(context, action, outcome);
                    // Trigger a switch to Render Response if needed
                    context.renderResponse();
                    return;
                }
                restoreSessionMessage();
View Full Code Here

    {
        log.error("Redirecting from page {} to page {}.", getPageName(), outcome.toString());
        // Return to Parent
        FacesContext context = FacesContext.getCurrentInstance();
        // Retrieve the NavigationHandler instance..
        NavigationHandler navHandler = context.getApplication().getNavigationHandler();
        // Invoke nav handling..
        navHandler.handleNavigation(context, action, outcome.toString());
        // Trigger a switch to Render Response if needed
        context.renderResponse();
    }
View Full Code Here

   * or <code>null</code> if none
   */
  protected final void callNextHandlerInChain(
      FacesContext facesContext, String fromAction, String outcome, NavigationHandler originalNavigationHandler) {

    NavigationHandler decoratedNavigationHandler = getDecoratedNavigationHandler();

    if (decoratedNavigationHandler instanceof DecoratingNavigationHandler) {
      // DecoratingNavigationHandler specified through constructor argument:
      // Call it with original NavigationHandler passed in.
      DecoratingNavigationHandler decHandler = (DecoratingNavigationHandler) decoratedNavigationHandler;
      decHandler.handleNavigation(facesContext, fromAction, outcome, originalNavigationHandler);
    }
    else if (decoratedNavigationHandler != null) {
      // Standard NavigationHandler specified through constructor argument:
      // Call it through standard API, without original NavigationHandler passed in.
      // The called handler will not be able to redirect to the original handler.
      decoratedNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
    }
    else if (originalNavigationHandler != null) {
      // No NavigationHandler specified through constructor argument:
      // Call original handler, marking the end of this chain.
      originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
View Full Code Here

   * <code>handleNavigation</code> method with the original NavigationHandler
   * as argument will be used. Else, the standard <code>handleNavigation</code>
   * method will be called.
   */
  public void handleNavigation(FacesContext facesContext, String fromAction, String outcome) {
    NavigationHandler handler = getDelegate(facesContext);
    if (handler instanceof DecoratingNavigationHandler) {
      ((DecoratingNavigationHandler) handler).handleNavigation(
          facesContext, fromAction, outcome, this.originalNavigationHandler);
    }
    else {
      handler.handleNavigation(facesContext, fromAction, outcome);
    }
  }
View Full Code Here

        super(name);
    }

    public void test()
    {
        NavigationHandler navigationHandler = _application.getNavigationHandler();

        UIViewRoot viewRoot = new UIViewRoot();

        // case 1: no from-view-id
        viewRoot.setViewId("/anypage.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome1");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/page1.jsp");

        // case 2: from-view-id = *, with from-outcome, no from-action
        viewRoot.setViewId("/anypage.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome2");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/page2.jsp");

        // case 3: from-view-id = *, with from-outcome and from-action
        viewRoot.setViewId("/anypage.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{action3}", "outcome3");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/page3.jsp");

        // case 4: from-view-id = *, no from-outcome, with from-action
        viewRoot.setViewId("/anypage.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{action4}", "anyoutcome");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/page4.jsp");

        // case 5: exact from-view-id match, with from-outcome, no from-action
        viewRoot.setViewId("/from5.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome5");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/page5.jsp");

        // case 6: wildcard from-view-id match, with from-outcome, no from-action
        viewRoot.setViewId("/context6/anypage.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "outcome6");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/page6.jsp");

        // no match
        viewRoot.setViewId("/anycontext/anypage.jsp");
        _facesContext.setViewRoot(viewRoot);
        navigationHandler.handleNavigation(_facesContext, "#{anyaction}", "anyoutcome");
        assertEquals(_facesContext.getViewRoot().getViewId(), "/anycontext/anypage.jsp");

    }
View Full Code Here

        String outcome = component.getOutcome();
        outcome = (outcome == null) ? facesContext.getViewRoot().getViewId()
                : outcome;
        outcome = ((outcome == null) ? STR_EMPTY : outcome.trim());
        // Get the correct URL for the outcome.
        NavigationHandler nh = facesContext.getApplication().getNavigationHandler();
        if (!(nh instanceof ConfigurableNavigationHandler))
        {
            throw new FacesException(
                    "Navigation handler must be an instance of "
                            + "ConfigurableNavigationHandler for using h:link or h:button");
View Full Code Here

      // that the WSRP is not properly setup and we need to redirect to the error page
      ExternalContext externalContext = context.getExternalContext();
      Map<String, Object> applicationMap = externalContext.getApplicationMap();
      if (!applicationMap.containsKey(CONSUMER_REGISTRY) || !applicationMap.containsKey(PRODUCER_CONFIGURATION_SERVICE))
      {
         NavigationHandler navigationHandler = context.getApplication().getNavigationHandler();
         navigationHandler.handleNavigation(context, null, "error");
      }
   }
View Full Code Here

   
  }
 
  public void goingWithGuide(){
    FacesContext facesContext =  FacesContext.getCurrentInstance();
    NavigationHandler navHandler = facesContext.getApplication().getNavigationHandler();
    navHandler.handleNavigation(facesContext, null, "/road.jsf");
  }
View Full Code Here

    @Override
    public void handle() throws FacesException {
        if (getUnhandledExceptionQueuedEvents().iterator().hasNext()) {
            FacesContext facesContext = FacesContext.getCurrentInstance();
            NavigationHandler navHandler = facesContext.getApplication().getNavigationHandler();
            navHandler.handleNavigation(facesContext, null, "/error.jsf?faces-redirect=true");
        }
    }
View Full Code Here

TOP

Related Classes of javax.faces.application.NavigationHandler

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.