|
The JavaServer Faces has a navigation model which describes the flow of the pages as per the application state. Navigation is defined as the set of rules for choosing the next page to be displayed after the form is submitted or hyperlink is clicked. These rules are in the configuration file i.e. faces-config.xml file. The <navigation-rule> tag is used to define the navigation flow of a JSF page. The following tags are used to define the navigation flow:-
- <from-view-id>:- This tag is used to define the page from which the event is going to be generated.
- <navigation-case>:- This tag is the super tag of the <from-outcome> and <to-view-id> and collectively used to define the navigation flow for the resultant page. The number of cases mostly depend on the number of events the page is able to generate.
- <from-outcome>:- This tag holds the event outcome state which is matched at the time of calling. For example a state may be success or failure.
- <to-view-id>:- This tag is used to hold the resultant page needs to display after the outcome state of the event is matched with the outcome tag.
Lets take the Registration application as example. We have registration.jsp file. We want if we submit the form the control is transferred to response.jsp page on the success state. So the navigation flow is as follows:-
<navigation-rule> <from-view-id>/registration.jsp</from-view-id> <navigation-case> <from-outcome>success</from-outcome> <to-view-id>/response.jsp</to-view-id> </navigation-case> </navigation-rule> |