Thursday, June 14, 2012

How to navigate to another page programmatically

Here is a method that enables you to navigate from a page to another using navigation rules defined in your taskflow. 
public void forward(String redirect ) {
        FacesContext facesContext = FacesContext.getCurrentInstance();
        // redirect defines the navigation rule that must be used in order
        // to redirect the user to the adequate page...
        NavigationHandler myNav = facesContext.getApplication().getNavigationHandler();
        myNav.handleNavigation(facesContext, null, redirect);
    }