Java Code Examples for javax.faces.application.NavigationHandler#handleNavigation()
The following examples show how to use
javax.faces.application.NavigationHandler#handleNavigation() .
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: SessionBean.java From yawl with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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 2
Source File: ViewExpiredExceptionExceptionHandler.java From journaldev with MIT License | 6 votes |
@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 3
Source File: SessionBean.java From yawl with GNU Lesser General Public License v3.0 | 6 votes |
/** * 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 4
Source File: DefaultExceptionHandler.java From ee7-sandbox with Apache License 2.0 | 5 votes |
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 5
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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 6
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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 7
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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 8
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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 10
Source File: DefaultExceptionHandler.java From spring4-sandbox with Apache License 2.0 | 5 votes |
private void handleNotFoundException(Exception e) { log.debug("handling exception:..."); FacesContext context = FacesContext.getCurrentInstance(); String viewId = "/error.xhtml"; log.debug("view id @" + viewId); NavigationHandler nav = context.getApplication().getNavigationHandler(); nav.handleNavigation(context, null, viewId); context.getViewRoot().getViewMap(true).put("ex", e); context.renderResponse(); }
Example 11
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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: DelegatingNavigationHandlerProxy.java From lams with GNU General Public License v2.0 | 5 votes |
/** * 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 13
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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 14
Source File: DefaultExceptionHandler.java From ee8-sandbox with Apache License 2.0 | 5 votes |
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 15
Source File: DefaultExceptionHandler.java From javaee8-jsf-sample with GNU General Public License v3.0 | 5 votes |
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 ee7-sandbox with Apache License 2.0 | 5 votes |
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: DelegatingNavigationHandlerProxy.java From java-technology-stack with MIT License | 5 votes |
/** * 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 18
Source File: DelegatingNavigationHandlerTests.java From spring-analysis-note with MIT License | 5 votes |
@Override public void handleNavigation(FacesContext facesContext, @Nullable String fromAction, @Nullable String outcome, @Nullable NavigationHandler originalNavigationHandler) { lastFromAction = fromAction; lastOutcome = outcome; if (originalNavigationHandler != null) { originalNavigationHandler.handleNavigation(facesContext, fromAction, outcome); } }
Example 19
Source File: DecoratingNavigationHandler.java From java-technology-stack with MIT License | 4 votes |
/** * Method to be called by subclasses when intending to delegate to the next * handler in the NavigationHandler chain. Will always call the most * appropriate next handler, either the decorated NavigationHandler passed * in as constructor argument or the original NavigationHandler as passed * into this method - according to the position of this instance in the chain. * <p>Will call the decorated NavigationHandler specified as constructor * argument, if any. In case of a DecoratingNavigationHandler as target, the * original NavigationHandler as passed into this method will be passed on to * the next element in the chain: This ensures propagation of the original * handler that the last element in the handler chain might delegate back to. * In case of a standard NavigationHandler as target, the original handler * will simply not get passed on; no delegating back to the original is * possible further down the chain in that scenario. * <p>If no decorated NavigationHandler specified as constructor argument, * this instance is the last element in the chain. Hence, this method will * call the original NavigationHandler as passed into this method. If no * original NavigationHandler has been passed in (for example if this * instance is the last element in a chain with standard NavigationHandlers * as earlier elements), this method corresponds to a no-op. * @param facesContext the current JSF context * @param fromAction the action binding expression that was evaluated to retrieve the * specified outcome, or {@code null} if the outcome was acquired by some other means * @param outcome the logical outcome returned by a previous invoked application action * (which may be {@code null}) * @param originalNavigationHandler the original NavigationHandler, * or {@code null} if none */ protected final void callNextHandlerInChain(FacesContext facesContext, @Nullable String fromAction, @Nullable String outcome, @Nullable 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); } }
Example 20
Source File: DecoratingNavigationHandler.java From spring-analysis-note with MIT License | 4 votes |
/** * Method to be called by subclasses when intending to delegate to the next * handler in the NavigationHandler chain. Will always call the most * appropriate next handler, either the decorated NavigationHandler passed * in as constructor argument or the original NavigationHandler as passed * into this method - according to the position of this instance in the chain. * <p>Will call the decorated NavigationHandler specified as constructor * argument, if any. In case of a DecoratingNavigationHandler as target, the * original NavigationHandler as passed into this method will be passed on to * the next element in the chain: This ensures propagation of the original * handler that the last element in the handler chain might delegate back to. * In case of a standard NavigationHandler as target, the original handler * will simply not get passed on; no delegating back to the original is * possible further down the chain in that scenario. * <p>If no decorated NavigationHandler specified as constructor argument, * this instance is the last element in the chain. Hence, this method will * call the original NavigationHandler as passed into this method. If no * original NavigationHandler has been passed in (for example if this * instance is the last element in a chain with standard NavigationHandlers * as earlier elements), this method corresponds to a no-op. * @param facesContext the current JSF context * @param fromAction the action binding expression that was evaluated to retrieve the * specified outcome, or {@code null} if the outcome was acquired by some other means * @param outcome the logical outcome returned by a previous invoked application action * (which may be {@code null}) * @param originalNavigationHandler the original NavigationHandler, * or {@code null} if none */ protected final void callNextHandlerInChain(FacesContext facesContext, @Nullable String fromAction, @Nullable String outcome, @Nullable 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); } }