Home arrow Java & J2EE arrow Page 3 - Introduction to JavaServer Faces, Part 3

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).

TABLE OF CONTENTS:
  1. Introduction to JavaServer Faces, Part 3
  2. Wrtiting the JSP Files for the Page Navigation Example
  3. Creating the Application Configuration File for the Page Navigation Example
  4. Compiling and Running the Page Navigation Example
  5. Introducing the JSF Application Programming Interface (API)
  6. javax Packages
  7. More javax Packages
By: McGraw-Hill/Osborne
Rating: starstarstarstarstar / 21
March 22, 2004

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

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 10 The Application Configuration File for the Page Navigation Example


<?xml version="1.0" ? >
<!DOCTYPE faces-config PUBLIC
  
"-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
  
"http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
 
<
faces-config>
 
<managed-bean>
  
<managed-bean-name>surveyBean</managed-bean-name>
  
<managed-bean-class>ch02c.SurveyBean</managed-bean-class>
  
<managed-bean-scope>session</managed-bean-scope>
 
</managed-bean>
 
<navigation-rule>
  
<from-tree-id>/page1.jsp</from-tree-id>
  
<navigation-case>
  
<to-tree-id>/page2.jsp</to-tree-id>
 
</navigation-case>
</navigation-rule>
<navigation-rule>
 
<from-tree-id>/page2.jsp</from-tree-id>
  
<navigation-case>
   
<to-tree-id>/page1.jsp</to-tree-id>
  
</navigation-case>
 
</navigation-rule>
</faces-config>

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:


<navigation-rule>
 
<from-tree-id>/page1.jsp</from-tree-id>
 
<navigation-case>
  
<to-tree-id>/page2.jsp</to-tree-id>
 
</navigation-case>
</navigation-rule>

To specify which page to navigate to from the page2.jsp page, you use the following navigation-rule element:


<navigation-rule>
 
<from-tree-id>/page2.jsp</from-tree-id>
 
<navigation-case>
  
<to-tree-id>/page1.jsp</to-tree-id>
 
</navigation-case>
</navigation-rule>

 

Buy this book now!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!



 
 
>>> More Java & J2EE Articles          >>> More By McGraw-Hill/Osborne
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

JAVA & J2EE ARTICLES

- More Java Bugs Lead to More Attacks
- Oracle's Java One Brings News, Surprises
- Oracle Patches Java Runtime Environment
- Apple Syncs Java Update with Oracle
- Spring 3.1 Java Development Framework Compat...
- Jelastic Java PaaS Availability and Pricing ...
- NetBeans 7.1 Released, Supports JavaFX 2
- SolarWinds Releases Newest Version of Java M...
- Free Monitoring Tool for Java Apps on Heroku
- Heroku Adds JCloud Platform Support, Java 7 ...
- Java SE 8 Speculation in Full Swing
- Java SE 7 Now Available
- New JVM Language and Java Reporting Tool
- Java 7 Release Update and New Eclipse Toolkit
- The Best Java Netbeans IDE Plugins

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: