javax.faces.application.NavigationHandler Java Examples

The following examples show how to use javax.faces.application.NavigationHandler. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NavigationHandlerAwareApplication.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private NavigationHandler wrapNavigationHandlerWithNewWrapper(NavigationHandler handler)
{
    if (ConfigurableNavigationHandler.class.isAssignableFrom(handler.getClass()))
    {
        try
        {
            Constructor deltaSpikeNavigationHandlerWrapperConstructor =
                navigationHandlerWrapperClass.getConstructor(ConfigurableNavigationHandler.class);

            NavigationHandler navigationHandlerWrapper =
                (NavigationHandler)deltaSpikeNavigationHandlerWrapperConstructor.newInstance(handler);
            return  navigationHandlerWrapper;
        }
        catch (Exception e)
        {
            throw ExceptionUtils.throwAsRuntimeException(e);
        }
    }

    return null;
}
 
Example #2
Source File: NavigationHandlerAwareApplication.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
private NavigationHandler wrapNavigationHandler(NavigationHandler handler)
{
    NavigationHandler result = null;

    if (manualNavigationHandlerWrapperMode == null)
    {
        lazyInit();
    }

    //jsf 2.2+
    if (!manualNavigationHandlerWrapperMode)
    {
        result = wrapNavigationHandlerWithNewWrapper(handler);
    }
    if (result != null)
    {
        return result;
    }

    //jsf 2.0 and 2.1
    return new DeltaSpikeNavigationHandler(handler);
}
 
Example #3
Source File: ViewExpiredExceptionExceptionHandler.java    From journaldev with MIT License 6 votes vote down vote up
@Override
public void handle() throws FacesException {
    for (Iterator<ExceptionQueuedEvent> i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
        ExceptionQueuedEvent event = i.next();
        ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();

        Throwable t = context.getException();
        if (t instanceof ViewExpiredException) {
            ViewExpiredException vee = (ViewExpiredException) t;
            FacesContext facesContext = FacesContext.getCurrentInstance();
            Map<String, Object> requestMap = facesContext.getExternalContext().getRequestMap();
            NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
            try {
                // Push some useful stuff to the request scope for use in the page
                requestMap.put("currentViewId", vee.getViewId());
                navigationHandler.handleNavigation(facesContext, null, "/viewExpired");
                facesContext.renderResponse();
            } finally {
                i.remove();
            }
        }
    }

    // At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them.
    getWrapped().handle();
}
 
Example #4
Source File: SessionBean.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * redirects to the specified page
 * @param page the name of the page to go to
 */
public void gotoPage(String page) {
    Application app = getApplication() ;
    if (app != null) {
        NavigationHandler navigator = app.getNavigationHandler();
        navigator.handleNavigation(getFacesContext(), null, page);
    }

    // if app is null, session has been destroyed
    else {
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("Login.jsp");
        }
        catch (IOException ioe) {
            // message about destroyed app
        }
    }
}
 
Example #5
Source File: SessionBean.java    From yawl with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * redirects to the specified page
 * @param page the name of the page to go to
 */
public void gotoPage(String page) {
    Application app = getApplication() ;
    if (app != null) {
        NavigationHandler navigator = app.getNavigationHandler();
        navigator.handleNavigation(getFacesContext(), null, page);
    }

    // if app is null, session has been destroyed
    else {
        try {
            FacesContext.getCurrentInstance().getExternalContext().redirect("msLogin.jsp");
        }
        catch (IOException ioe) {
            // message about destroyed app
        }
    }
}
 
Example #6
Source File: DefaultExceptionHandler.java    From javaee8-jsf-sample with GNU General Public License v3.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #7
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #8
Source File: DefaultExceptionHandler.java    From javaee8-jsf-sample with GNU General Public License v3.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #9
Source File: DelegatingNavigationHandlerProxy.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Handle the navigation request implied by the specified parameters,
 * through delegating to the target bean in the Spring application context.
 * <p>The target bean needs to extend the JSF NavigationHandler class.
 * If it extends Spring's DecoratingNavigationHandler, the overloaded
 * {@code handleNavigation} method with the original NavigationHandler
 * as argument will be used. Else, the standard {@code handleNavigation}
 * method will be called.
 */
@Override
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);
	}
}
 
Example #10
Source File: DelegatingNavigationHandlerTests.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void handleNavigation(
		FacesContext facesContext, String fromAction, String outcome, NavigationHandler originalNavigationHandler) {
	lastFromAction = fromAction;
	lastOutcome = outcome;
	if (originalNavigationHandler != null) {
		originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome);
	}
}
 
Example #11
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #12
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #13
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #14
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #15
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #16
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #17
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #18
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #19
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #20
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #21
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #22
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #23
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #24
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #25
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #26
Source File: NavigationCaseMapWrapper.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor for wrapping the given navigation-cases
 *
 * @param navigationCases current navigation-cases
 * @param wrapped wrapped navigation-handler
 */
public NavigationCaseMapWrapper(Map<String, Set<NavigationCase>> navigationCases, NavigationHandler wrapped)
{
    this.wrappedNavigationCaseMap = navigationCases;
    this.wrapped = wrapped;
    this.viewConfigBasedNavigationCaseCache = createViewConfigBasedNavigationCases(false);
}
 
Example #27
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #28
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}
 
Example #29
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleViewExpiredException(ViewExpiredException vee) {
    LOG.log(Level.INFO, " handling viewExpiredException...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = vee.getViewId();
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.renderResponse();
}
 
Example #30
Source File: DefaultExceptionHandler.java    From ee8-sandbox with Apache License 2.0 5 votes vote down vote up
private void handleNotFoundException(Exception e) {
    LOG.log(Level.INFO, "handling exception:...");
    FacesContext context = FacesContext.getCurrentInstance();
    String viewId = "/error.xhtml";
    LOG.log(Level.INFO, "view id @" + viewId);
    NavigationHandler nav
            = context.getApplication().getNavigationHandler();
    nav.handleNavigation(context, null, viewId);
    context.getViewRoot().getViewMap(true).put("ex", e);
    context.renderResponse();
}