Java Reference
In-Depth Information
TABLE 7-3. Common Outcome Strings
Usually, the action method performs some processing on the form data of the current page.
For example, the method might check whether the user name and password entered in the
form match the user name and password on file. If they match, the method returns the out-
come
success
. Otherwise, it returns the outcome
failure
. As this example demon-
strates, both the method used to process the action and the outcome returned are necessary
to determine the correct page to access.
Here is a navigation rule that could be used with the example just described:
<navigation-rule>
<from-view-id>/login.xhtml</from-view-id>
<navigation-case>
<from-action>#{LoginForm.login}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/storefront.xhtml</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{LoginForm.logon}</from-action>
<from-outcome>failure</from-outcome>
<to-view-id>/logon.xhtml</to-view-id>
</navigation-case>
</navigation-rule>
This navigation rule defines the possible ways to navigate from
login.xhtml
. Each
navigation-case
element defines one possible navigation path from
lo-
gin.xhtml
. The first
navigation-case
says that if
LoginForm.login
returns
an outcome of
success
, then
storefront.xhtml
will be accessed. The second
navigation-case
says
that
login.xhtml
will
be
re-rendered
if
Lo-
ginForm.login
returns
failure
.
The configuration of an application's page flow consists of a set of navigation rules. Each
rule is defined by the
navigation-rule
element in the
faces-config.xml
file.