Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
What is difference between a navigation in JSF FacesContext context = FacesContext.getCurrentInstance(); context.getApplication().getNavigationHandler().handleNavigation(context, null, url); and a redirect HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse(); response.sendRedirect(url); and how to decide when to use wha...
It would seem that the following are equivalent: FacesContext.getCurrentInstance().getApplication().getNavigationHandler().handleNavigation("/index.xhtml?faces-redirect=true"); FacesContext.getCurrentInstance().getExternalContext().redirect("/testapp/faces/index.xhtml"); Are there any differences and when should each be used?
Is there a way to create an html link using h:outputLink, other JSF tag or code to create a non faces request (HTTP GET) with request parameters? For example I have the following navigation-rule <navigation-rule> <navigation-case> <from-outcome>showMessage</from-outcome> <to-view-id>/showMessage.jsf</to-view-id> <redirect/>...
I'm using JSF2 and PrimeFaces3. How can I write selectOneMenu that would invoke JSF navigation to redirect user to another page when he change option in menu?
Inside of a phase listener class that runs during the "RESTORE_VIEW" phase, I have some code like this: public void afterPhase(PhaseEvent event) { FacesContext fc = event.getFacesContext(); NavigationHandler nh = fc.getApplication().getNavigationHandler(); nh.handleNavigation(fc, null, "/a/specific/path/to/a/resource.jspx"); } Navigation to the new URL doesn't work here. The request m...
I wrote myself a custom NavigationHandler very similar to following one but just using a stack to save the history: http://jsfatwork.irian.at/book_de/custom_component.html#!idx:/custom_component.html:fig:backnavigationhandler-code public class HistoryNavigationHandler extends NavigationHandler { private final NavigationHandler navigationHandler; private final Stack<String> out...
Is it possible to use a JSF (PrimeFaces) page in the following fashion ? : external application (not JSF-based) does an HTTP GET with URL parameters JSF page reads those parameters (e.g. as described here) and invokes a backing bean business method, without rendering anything to the user's browser The user is transparently sent to a page corresponding to the navigation outcome of the backing ...
I have an application using PrettyFaces and PrimeFaces. One page is accessed using the URL pattern /#{ location : navigationBean.location }/#{ year : navigationBean.year }. On that page I have a p:selectOneMenu containing possible values for location. If I change this menu I want the page to be refreshed with the same year and the new location. I've tested this using AJAX to set the location ...
Is there any way I can execute some code whenever a navigation rule is executed. Basically what I am trying to do is to have a JourneyTracker bean which will hold the current state of the journey (like the current page the user is in).
I have problem with org.omnifaces.util.Faces#redirect and conversation scoped bean: there is a button <p:commandButton action="#{navigationHandler.gotoCreateCar}" actionListener="#{createHandler.init(searchHandler.search())} value="#{msg.search}" update=":articleSearchForm"> <f:param name="cid" value="#{javax.enterprise.context.conversation.id}"/> </p:commandButton> ...
i have a preRender view event in my bean, and i make some validation in it on the user, and when some condition occur, i redirect the user to login page using prettyFaces, but the redirection doesn't seem to work, i don't know why, here's the code: JSF: <f:event type="preRenderView" listener="#{myBean.preRender}" /> Managed Bean: public String preRender() { log.debug("preRend...
Following my previous question, i have a question about why is it this exception is being thrown if i use <p:button> from primefaces after registering the RedirectNavigationHandler in the faces-config.xml. : SEVERE: Error Rendering View[/TBrowse.xhtml] java.lang.ClassCastException: my.package.RedirectNavigationHandler cannot be cast to javax.faces.application.ConfigurableNavigationHandle...
I have server-side coundown counter. When it == 0, method should execute ExternalContext#dispatch(), but it didn't do it. Method ExternalContext#redirect() works correctly on this place. .... }else{ try { FacesContext.getCurrentInstance().getExternalContext().dispatch("result.xhtml"); } catch (IOException e) { e.printStackTrace(); } }...
I'm trying to implement a Custom Naviguation, that do the usual job and update my breadcrumb. public class CustomNaviguationHandler extends NavigationHandlerImpl{ public void handleNavigation(FacesContext context, String fromAction, String outcome) { //do the breadcrumb update super.handleNavigation(context, fromAction, outcome); } } But when I debug it, the met...
I want to be able to navigate to a different page when user clicks are row. Problems No error is thrown I can see the selectionListener getting executed with expected row value but nothing happens. Is this the right way of doing it i.e. using my action listener for this purpose. Backing bean is this. Backing bean package com.howto; import java.util.ArrayList; import java.util.Collection;...
I have a page: http://mypage.com/items.jsf. This page takes the following for granted: ID is set by GET or ID is set by POST. Now, I can manually call items.jsf?ID=10 But what I really want to do is have a Button which calls a function that returns the navigation URL. public String test() { return "10"; } Now having the following code in the JSF file. <h:form> &l...
 /*
  * $Id: NavigationHandler.java,v 1.15 2007/04/27 22:00:02 ofung Exp $
  */
 
 /*
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
  * 
  * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
  * 
 * The contents of this file are subject to the terms of either the GNU
 * General Public License Version 2 only ("GPL") or the Common Development
 * and Distribution License("CDDL") (collectively, the "License").  You
 * may not use this file except in compliance with the License. You can obtain
 * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
 * or glassfish/bootstrap/legal/LICENSE.txt.  See the License for the specific
 * language governing permissions and limitations under the License.
 * 
 * When distributing the software, include this License Header Notice in each
 * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
 * Sun designates this particular file as subject to the "Classpath" exception
 * as provided by Sun in the GPL Version 2 section of the License file that
 * accompanied this code.  If applicable, add the following below the License
 * Header, with the fields enclosed by brackets [] replaced by your own
 * identifying information: "Portions Copyrighted [year]
 * [name of copyright owner]"
 * 
 * Contributor(s):
 * 
 * If you wish your version of this file to be governed by only the CDDL or
 * only the GPL Version 2, indicate your decision by adding "[Contributor]
 * elects to include this software in this distribution under the [CDDL or GPL
 * Version 2] license."  If you don't indicate a single choice of license, a
 * recipient has the option to distribute your version of this file under
 * either the CDDL, the GPL Version 2 or to extend the choice of license to
 * its licensees as provided above.  However, if you add GPL Version 2 code
 * and therefore, elected the GPL Version 2 license, then the option applies
 * only if the new code is made subject to such option by the copyright
 * holder.
 */
package javax.faces.application;

A NavigationHandler is passed the outcome string returned by an application action invoked for this application, and will use this (along with related state information) to choose the view to be displayed next.

A default implementation of NavigationHandler must be provided by the JSF implementation, which will be utilized unless setNavigationHandler() is called to establish a different one. This default instance will compare the view identifier of the current view, the specified action binding, and the specified outcome against any navigation rules provided in faces-config.xml file(s). If a navigation case matches, the current view will be changed by a call to FacesContext.setViewRoot(). Note that a null outcome value will never match any navigation rule, so it can be used as an indicator that the current view should be redisplayed.

public abstract class NavigationHandler {


    

Perform navigation processing based on the state information in the specified javax.faces.context.FacesContext, plus the outcome string returned by an executed application action.

Parameters:
context The javax.faces.context.FacesContext for the current request
fromAction The action binding expression that was evaluated to retrieve the specified outcome, or null if the outcome was acquired by some other means
outcome The logical outcome returned by a previous invoked application action (which may be null)
Throws:
java.lang.NullPointerException if context is null
    public abstract void handleNavigation(FacesContext context,
                                          String fromAction,
                                          String outcome);
New to GrepCode? Check out our FAQ X