Creating the Application Configuration File for the Page Navigation Example - Java
This chapter has been leading us gently through the JavaServer Faces technology. More importantly, in it, Budi teaches ushow to write an online survey application to get a feel for how this great technology works. This chapter prepares you for the next chapters by introducing the JSF Application Programming Interface (API) and the Application Configuration file. This excerpt comes from chapter two of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983-7, 2004).
In JSF, page navigation is controlled using one or more navigation rules in the application configuration file. Each rule specifies a page of origin and one or more possible targets. A page is represented by its tree identifier, and each possible target is represented by a navigation case. You need to specify a navigation rule for each page from which the user can navigate to another page. You also need to register the SurveyBean in the application configuration file. The application configuration file is shown in Listing 10.
Listing 10The Application Configuration File for the Page Navigation Example
A navigation rule is defined by the navigation-rule element in the application configuration file. For this application, each navigation-rule element needs to contain the from-tree-id element and navigation-case subelements. The from-tree-id 5 3 subelement is the tree identifier of the page of origin. The navigation-case subelement represents a possible target. A navigation-rule element can have zero or several navigation-case subelements. Each navigation-case element specifies the target page for a particular outcome of the from-tree-id processing. For this application, the navigation-case element simply contains a to-tree-id subelement that specifies the destination page.
To specify which page to navigate to from the page1.jsp page, you use the following navigation-rule element:
Remember: This is part three of the second chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). If you've enjoyed what you've seen here, click on the "Buy it now!" banner to pick up a copy today! Buy this book!