Using navigation rules with Faces JSP pages

Use navigation rules if you want to create navigation from one Faces JSP page to another in the same project. Navigation rules are the rules you set for which page to go to when a certain outcome occurs on the original page. For example, if a user receives an error message while trying to click a Submit button, a navigation rule can automatically navigate to a new page that tells the user how to fix the problem.

Note: If you want to create navigation to external Web pages, use the Link component. Drag the Link component to the page and then specify the external target and label.
To create navigation rules:
  1. Create and select one of the following components on the page:
    • Button - Command
    • Link - Command
    • Link - Request
    • The row action of a data table component
    Open the Properties view for the component.
  2. Click the Quick Edit View button on the Properties view to switch to Quick Edit view and code an action that this component can perform. The action must return at least one value.
  3. In the Properties view, click Add Rule. The Add Navigation Rule dialog opens and you can set the navigation rules for this component on this page.
  4. In the Add Navigation Rule dialog:
    1. In the Go to the page section, select the page to which you want to navigate.
    2. In the When the action returns the outcome section, choose "Any outcome" or name an outcome.
    3. In the This rule is used for/by section, choose to have the navigation rule used by all pages or this page only and to have the rule used by any action or the action you specify.
    4. In the When following this rule section, choose to have the parameters work automatically (request forwarding) or to have the parameters coded (request redirection). Note that you can set parameters on the Parameter tab of the Properties view for this component.
    5. Click OK. The rule is added to the table in the Properties view.
At a minimum, you can select the component, then change return null to return "alias" in the Quick Edit view. By default, the alias will be *, which means a return code of anything (except null) will trigger that navigation rule. You can set the return code for a given component in the Quick Edit view. Select the Command event and in the right pane of the Quick Edit view, specify at a minimum: return"". This returns an empty string, which triggers the rule based on *. If you have a specific alias set up (for example, "success"), then the actions needs to return "success" to trigger that navigation rule. You can make a navigation rule apply only to a specific action (choose action in scope). You can have the navigation rule apply on the current page or on all pages in the project. Note that unless you scope it to a particular action, all actions use these navigation rules, whether or not you have explicitly added them using the Properties view.

To learn more about using navigation rules, do the following tutorial (especially the exercise on using navigation rules):

Tutorial: Display dynamic information on Web pages with JavaServer Faces. This tutorial will teach you how to design a dynamic Web site that functions as a newspaper's classified advertising section. The Web site is a complete J2EE Web application that uses JavaServer Faces (JSF) components and Service Data Objects (SDO) components. The Web application uses JSF technology to create dynamic Web pages that link to a database that stores classified advertising data.Tutorial: Display dynamic information on Web pages with JavaServer Faces. This tutorial will teach you how to design a dynamic Web site that functions as a newspaper's classified advertising section. The Web site is a complete J2EE Web application that uses JavaServer Faces (JSF) components and Service Data Objects (SDO) components. The Web application uses JSF technology to create dynamic Web pages that link to a database that stores classified advertising data.

Related concepts
Data table components
Related tasks
Creating an input form connected to a data source
Adding input components to a Faces JSP page
Adding selection lists to a Faces JSP file
Adding hyperlinks to a Faces JSP file
Using File Upload components
Managing errors in JavaServer Faces applications
Creating a Faces JSP file
Related reference
Button - Command
Link - Command
Command row action
Link
Link - Request
Menu bar
Action Bar
Request row action

Feedback