background image

Common Outcome Strings

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

Common Outcome Strings

The outcome can be anything the developer chooses, but
Table 14­3
lists some outcomes
commonly used in web applications.
TABLE 14­3
Common Outcome Strings
Outcome
What It Means
success
Everything worked. Go on to the next page.
failure
Something is wrong. Go on to an error page.
logon
The user needs to log on first. Go on to the logon page.
no results
The search did not find anything. Go to the search page again.
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 outcome
success
. Otherwise, it returns the outcome failure. As this example demonstrates, both the
method used to process the action and the outcome returned are necessary to determine the
proper page to access.
Here is a navigation rule that could be used with the example just described:
<navigation-rule>
<from-view-id>/logon.jsp</from-view-id>
<navigation-case>
<from-action>#{LogonForm.logon}</from-action>
<from-outcome>success</from-outcome>
<to-view-id>/storefront.jsp</to-view-id>
</navigation-case>
<navigation-case>
<from-action>#{LogonForm.logon}</from-action>
<from-outcome>failure</from-outcome>
<to-view-id>/logon.jsp</to-view-id>
</navigation-case>
</navigation-rule>
This navigation rule defines the possible ways to navigate from logon.jsp. Each
navigation-case
element defines one possible navigation path from logon.jsp. The first
navigation-case
says that if LogonForm.logon returns an outcome of success, then
storefront.jsp
will be accessed. The second navigation-case says that logon.jsp will be
re-rendered if LogonForm.logon 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.
The navigation rules of the Duke's Bookstore application are very simple. Here are two complex
navigation rules that could be used with the Duke's Bookstore application:
Configuring Navigation Rules
The Java EE 5 Tutorial · September 2007
452