background image

The navigation-case Element

<< The navigation-rule Element | Registering a Custom Renderer >>
<< The navigation-rule Element | Registering a Custom Renderer >>

The navigation-case Element

The navigation-case elements are checked against the outcome and the method expression in
this order:
Cases specifying both a from-outcome value and a from-action value. Both of these
elements can be used if the action method returns different outcomes depending on the
result of the processing it performs.
Cases specifying only a from-outcome value. The from-outcome element must match either
the outcome defined by the action attribute of the UICommand component or the outcome
returned by the method referred to by the UICommand component.
Cases specifying only a from-action value. This value must match the action expression
specified by the component tag.
When any of these cases is matched, the component tree defined by the to-view-id element
will be selected for rendering.
Using NetBeans IDE, you can configure a navigation rule by doing the following:
1. After opening your project in NetBeans IDE, expand the project node in the Projects pane.
2. Expand the Web Pages and WEB-INF nodes of the project node.
3. Double-click faces-config.xml.
4. After faces-config.xml opens in the editor pane, right-click in the editor pane.
5. Select JavaServer Faces
Add Navigation Rule.
6. In the Add Navigation Rule dialog:
a. Enter or browse for the page that represents the starting view for this navigation rule.
b. Click Add.
7. Right-click again in the editor pane.
8. Select JavaServer Faces
Add Navigation Case.
9. In the Add Navigation Case dialog:
a. From the From View menu, select the page that represents the starting view for the
navigation rule (from step 6a).
b. (optional) In the From Action field, enter the action method invoked when the
component that triggered navigation is activated.
c. (optional) In the From Outcome field, enter the logical outcome string that the activated
component references from its action attribute.
d. From the To View menu, select or browse for the page that will be opened if this
navigation case is selected by the navigation system.
e. Click Add.
"Referencing a Method That Performs Navigation" on page 371
explains how to use a
component tag's action attribute to point to an action method.
"Writing a Method to
Handle Navigation" on page 404
explains how to write an action method.
Configuring Navigation Rules
The Java EE 5 Tutorial · September 2007
454