The Application Configuration Resource File, faces-config.xml – Develop Java Web Applications to Access Databases

8.1.6.1   The Application Configuration Resource File, faces-config.xml

Navigation from one page to another can be done in two ways. One way is to use code directly by writing a JSP tag such as <jsp:forward /> or an HTML hyperlink in the JSF file. Another way that is provided by JSF is to use the application configuration resource file faces-config.xml to build navigation rules. The task of defining navigation rules involves defining which page is to be displayed after the user clicks on a button or a hyperlink. Each <navigation-rule> ele-ment defines how to get from one page as defined by the <form-view-id> to the other pages of the application. A <navigation-rule> element can contain any number of <navigation-case> elements that define the page to open next using the <to-view-id> based on a logical outcome defined by the <from-outcome>. This outcome is defined by the action attribute of the component that submits the form (such as the command Button).

An application configuration resource file, faces-config.xml, is used to define your Java managed beans, validators, converters and navigation rules.

Figure 8.24 shows a part of an example of an application configuration resource file. The con-figuration resource file is composed of a sequence of tags: Starting from the<navigation-rule> tag, a new navigation rule is defined. The <from-view-id>tag is used to define the navigation source, which is the current page (Current.jsp). The <navigation-case> tag is used to define one of the navigation destinations defined by the <to-view-id> tag based on the output of clicked buttons or links triggered by the action tag in the current page. Those outputs are defined by the <from-outcome> tag.

You can use design tools such as PageFlow to do this navigation plan graphically and directly. Refer to Section 5.3.5.12 in Chapter 5 to get more detailed information about using design tools to build this configuration file graphically.

Leave a Comment



                    Blog, Contribute ,Privacy,Terms of Use,Trademarks,© estherknow 2024