To navigate from one Facelet page to another in the same
project, you can use implicit navigation or you can set navigation
rules. 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 clickSubmit,
a navigation rule can automatically navigate to a new page that tells
the user how to fix the problem.
Procedure
- Create and select one of the following components on the
page:
- Button - Command
- Button - Navigate
- Link - Navigate
- Link - Command
Open the Properties view for the component.
- To use navigation rules:
- In the Properties view, click Add Rule.
- In the Add Navigation Rule dialog box, in the Go
to the page section, select the page to which you want
to navigate, or select Compute from the drop-down
list to select an EL expression.
- In the When section, you can:
- Name an outcome in the The outcome is field.
If this check box is not selected, the navigation rule does not check
the outcome.
- Add conditional navigation by adding or selecting an EL expression
in the This expression is true field to specify
a condition that must be met in order for the navigation rule to be
accepted. Conditional navigation adds an <if> element to the navigation
case.
- In the This rule is used for/by section,
choose to use the navigation rule either for all pages or only this
page, and to have either any action or the action you specify use
the rule.
- In the When following this rule section,
you can choose between these options:
- Use request forwarding. When navigating
to the page specified by the navigation rule, the URL does not change.
- Use request redirection. When navigating
to the page specified by the navigation rule, the URL is updated with
parameters that are appended to the navigation rule. You can also Include
view parameters in navigation rules that use redirection.
With view parameters, you can append the values specified in any <f:viewParam>
tags as query parameters in the generated target URL. Selecting Include
view parameters sets the includeviewParams attribute to
true on a <redirect> element in the faces-config.xml file. If this
check box is not selected, the generated URI will contain only redirect
parameters and exclude any view parameters.
- Click OK. The
rule is added to the table in the Properties view.
- To use implicit navigation:
- If no matching navigation case is found after all rules
are checked, the navigation handler looks for a view ID that matches
the action outcome. If a view is found, implicit navigation loads
the matching file. You can use implicit navigation by selecting a
page to navigate to in the Action or outcome field,
or clicking the Select or code an action icon.
- Select an action from the list of Faces
actions.
- Code an action opens the Quick Edit view
where you can write your Java™ code
for the action.
- You can also modify and delete navigation rules from the
table by clicking Edit or Remove in
the Properties view.