Setting Up Dynamic Page Navigation for Visual Web JSF Pages

See Also

With dynamic page navigation, the application determines at runtime which page a specific component opens. The page that you navigate from is called the source page. The page that you navigate to is called the destination page. For dynamic navigation, the source page can open one of two or more destination pages. For example, the component's action method might look up a user's record, and if the user is an administrator, go to the Administrator page. If the user is not an administrator, it would go to the Welcome page.

To set dynamic navigation, you create the pages, and then you create the connectors, and then you code the conditional statement.

To create the pages:

  1. If the destination pages are already created, skip to the next section. Otherwise, in the Page Flow editor, right-click and choose New File.
  2. In the New File wizard, select JavaServer Faces as the category and Visual Web JSF Page as the file type. Click Next.
  3. Enter the name of the new Visual Web JSF page and click Finish.
    The new page appears in the Page Flow editor.

To create the connectors:

  1. In the Page Flow editor, drag new connectors from the page to each destination page.
  2. To rename a connector, select it, right-click, and choose Rename.
  3. Type the new name of the connector and click OK.

To code the conditional statement:

  1. In the Page Flow editor, click the on the page to show its components, then right-click the component and choose Open Handler to open the component's action method in the Java Editor.
  2. For single page navigation, you would set the method's return statement to the name of a single connector. To make the navigation dynamic, you code a conditional statement that returns different connectors based on a set of conditions. When a condition is satisfied, the button dynamically returns the correct page.

    For example:

    If you double-click Button1 in Page1.jsp, the Java Editor opens Page1.java with the cursor in the Button1_action method. Replace the button's return statement with the following code:

    	if (gotoform2 == true) {
    		return "Page2Connect";
    	} 
    	else return "Page3Connect";
        
See Also
Setting Up Static Page Navigation
About Pages
About Multiple Pages and Navigation
About the Page Flow Editor

Legal Notices