HTML and CSS Reference
In-Depth Information
the complete source code of the Survey application is available on the topic web site at
www.apress.com/9781430250104 (attached in the Chapter 2 source code zip file).
Note
Navigation
In the JSF framework, there are two types of navigations:
Implicit navigation.
Rule-based navigation.
The next sections illustrate both navigation types with examples of when to use each of them.
Implicit Navigation
In the firstApplication , we already have two examples of page navigations. The first one was about the
<h:commandButton> , which navigates from the index.xhtml page to the welcome.xhtml page:
<h:commandButton value="#{bundle['application.login']}" action="welcome"/>
The second example was about the < h:link> , which navigates from the welcome.xhtml page to the
index.xhtml page:
<h:link value="#{bundle['application.welcomepage.return']}" outcome="index"/>
The mentioned two examples represent the first mentioned type of JSF navigations, which is called “ implicit
navigation .” Implicit navigation was introduced in the JSF framework in its 2.0 version. It is called implicit because
using it, you do not have to define a navigation rule in the JSF configuration file ( faces-config.xml ); all that you
need to do is to specify the relative path of the target page in the action or the outcome attributes (you do not need
to mention the .xhtml extension of the target page because the JSF navigation system will append it for you and will
navigate to the target page).
Using implicit navigation, you can also make an HTTP Redirect to the target page instead of forwarding the
HTTP Request to the target page (which is the default behavior). This can be performed by using the faces-redirect
parameter, as follows:
<h:commandButton value="#{bundle['application.login']}" action="welcome? faces-redirect=true "/>
Setting the faces-redirect parameter to true tells the JSF navigation system to make HTTP Redirect instead of
the HTTP Request forwarding.
The most important advantage of the JSF implicit navigation is its simplicity; however, one of its drawbacks is the
inflexibility that happens when you have a complex navigation in the JSF application and you need to rename one of
the target navigation pages. In this case, you will have to revisit all the pages that include the target navigation page in
order to change the old page name to the new page name. So it is recommended to use the JSF implicit navigation for
small applications or for prototyping or for PoCs (Proof of Concepts).
 
 
Search WWH ::




Custom Search