Navigating to a different page in JSF portlet

You can navigate to a different page when you are using JSR 286 event feature. To achieve this in JavaServer Faces (JSF) , use the NavigationHandler in processEvent() method in the custom portlet class. You may either use Implicit or Explicit navigation.

A NavigationHandler navigates to a page based on implicit navigation and/or explicit navigation using the navigation rules specified in faces-config.xml. A NavigationHandler parameter navigates to a page based on Implicit navigation. It also navigates based on explicit navigation using the navigation rules specified in faces-config.xml.

In JSF 1.2, navigation rules are declared in the faces-config.xml file to perform page navigations. For example:
<navigation-rule>
	<from-view-id>firstPage.xhtml</from-view-id>
	<navigation-case>
		<from-outcome>secondPage</from-outcome>
		<to-view-id>/secondPage.xhtml</to-view-id>
	</navigation-case>
</navigation-rule>
In JSF 2, implicit navigation is introduced where you do not need to declare the navigation rule in faces-config.xml file, rather you may put the outcome in the action attribute of commandButton or commandLink. For example:
<h:commandButton id="button1" action="secondPage" value="Go to Second Page" />
Where 'secondPage' is the name of the page to which the user wants to navigate. For example, you can use the NavigationHandler parameter in the processEvent() method in the custom portlet class:
public void processEvent(EventRequest request, EventResponse response) throws PortletException, java.io.IOException {
    super.processEvent(request, response);
    FacesContext facesContext = FacesContext.getCurrentInstance();
    Event event = request.getEvent();
    if (event.getName().toString().equals("AnyMessage")) 
   {
         NavigationHandler nav = facesContext.getApplication().getNavigationHandler();
         String page = "secondPage";
         nav.handleNavigation(facesContext, null, page);
         facesContext.renderResponse();
         super.saveViewState(facesContext);
    }
    facesContext.release();
  }

Feedback