background image

Defining Page Navigations

<< Displaying Error Messages | Configuring Error Messages >>
<< Displaying Error Messages | Configuring Error Messages >>

Defining Page Navigations

<h:inputText id=
"userNo" label="User Number"
value=
"#{UserNumberBean.userNumber}"
converterMessage=
"#{ErrMsg.userNoConvert}">
<f:validateLongRange
minimum=
"#{UserNumberBean.minimum}"
maximum=
"#{UserNumberBean.maximum}" />
</h:inputText>
<h:commandButton id=
"submit"
action=
"success" value="Submit" />
<h:message showSummary=
"true" showDetail="false"
style=
"color: red;
font-family:
'New Century Schoolbook', serif;
font-style: oblique;
text-decoration: overline
"
id=
"errors1"
for=
"userNo"/>
</h:form>
</f:view>
Now you have completed the greeting page. Assuming you have also done the response.jsp
page, you can move on to defining the page navigation rules.
Defining Page Navigation
Defining page navigation involves determining which page to go to after the user clicks a button
or a hyperlink. Navigation for the application is defined in the application configuration
resource file using a powerful rule-based system. Here is one of the navigation rules defined for
the guessNumber example:
<navigation-rule>
<from-view-id>/greeting.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/response.jsp</to-view-id>
</navigation-case>
</navigation-rule>
<navigation-rule>
<from-view-id>/response.jsp</from-view-id>
<navigation-case>
<from-outcome>success</from-outcome>
<to-view-id>/greeting.jsp</to-view-id>
</navigation-case>
</navigation-rule>
This navigation rule states that when the button on the greeting page is clicked the application
will navigate to response.jsp if the navigation system is given a logical outcome of success.
A Simple JavaServer Faces Application
The Java EE 5 Tutorial · September 2007
296