Java Reference
In-Depth Information
Navigation Model
The JavaServer Faces navigation model makes it easy to define page navigation and to
handle any additional processing that is needed to choose the sequence in which pages are
loaded.
In JavaServer Faces technology,
navigation
is a set of rules for choosing the next page
or view to be displayed after an application action, such as when a button or hyperlink is
clicked.
Navigation can be implicit or user-defined. Implicit navigation comes into play when user-
defined navigation rules are not available. For more information on implicit navigation,
see “
Implicit Navigation Rules
”
on page
164
.
User-defined navigation rules are declared in zero or more application configuration re-
source files, such as
faces-config.xml
, by using a set of XML elements. The default
structure of a navigation rule is as follows:
<navigation-rule>
<description></description
<from-view-id></from-view-id>
<navigation-case>
<from-action></from-action>
<from-outcome></from-outcome>
<if></if>
<to-view-id></to-view-id>
</navigation-case>
</navigation-rule>
User-defined navigation is handled as follows:
• Define the rules in the application configuration resource file.
• Refer to an outcome
String
from the button or hyperlink component's
action
attribute. This outcome
String
is used by the JavaServer Faces implementation
to select the navigation rule.
Here is an example navigation rule:
<navigation-rule>
<from-view-id>/greeting.xhtml</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/response.xhtml</to-view-id>
</navigation-case>
</navigation-rule>