Java
  Home arrow Java arrow Introduction to JavaServer Faces, Part...
FaxWave - Free Trial.
Dev Shed Forums 
Administration  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Download TestComplete 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
IBM Developerworks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
JAVA

Introduction to JavaServer Faces, Part 3
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 19
    2004-03-22

    Table of Contents:
  • Introduction to JavaServer Faces, Part 3
  • Wrtiting the JSP Files for the Page Navigation Example
  • Creating the Application Configuration File for the Page Navigation Example
  • Compiling and Running the Page Navigation Example
  • Introducing the JSF Application Programming Interface (API)
  • javax Packages
  • More javax Packages

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    Iron Speed
     
    ADVERTISEMENT

    PCmover - $15 Off with Coupon Code CJPH7Q

    Introduction to JavaServer Faces, Part 3
    (Page 1 of 7 )

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


    Creating the Page Navigation Example
    JavaServer FacesThis section presents another sample application, which features an online survey application with two JSP pages. What makes it different from the previous two examples is that this application has multiple pages. Its main purpose is to demonstrate how to navigate from one JSP page to another.

    Like the first two applications, this application is simple. The first page displays a form that takes two input boxes, where you enter your favorite singer and favorite band. After you submit the form, the second JSP page is displayed. The second JSP page displays the values you entered into the form in the first page. It also allows you to go back to the first page by clicking a button. A JavaBean called SurveyBean is used to store the user’s data.

    This application requires a directory structure, deployment descriptor (the same as the ones for the previous examples, shown in Listing 1), a JavaBean, an application configuration file, and two JSP pages.

    Creating the Directory Structure for the Page Navigation Example

    You need to create a directory called JSPCh02c for this application. In Tomcat, you create the directory under the webapps directory. The directory structure for this application is shown in Figure 10. Notice that it has two JSP pages: page1.jsp and page2.jsp. Also, the SurveyBean class resides under the WEB-INF/classes directory. As usual, you must copy all required libraries to the WEB-INF/lib directory.

    Creating the SurveyBean
    Your application needs a JavaBean to store data. This bean is called SurveyBean, and it can be found in the SurveyBean.java file in the ch02c package. It is shown in Listing 7

    JSF directory structure

    Figure 10 The directory structure of the page navigation example 

    Listing 7 The SurveyBean


    package ch02c
    public 
    class SurveyBean 
       String favSinger 
    null
       String favBand 
    null
       
    public void setFavSinger(String favSinger) { 
          this
    .favSinger favSinger
       

       
    public String getFavSinger() { 
          
    return favSinger
       

       
    public void setFavBand(String favBand) { 
          this
    .favBand favBand
       
    } public String getFavBand() { 
          
    return favBand
       
    <?xml:namespace prefix /><f:use_faces>}
    }

    There is nothing special in the SurveyBean class. It has two properties, favSinger and favBand, and accessors and mutators (get and set methods) for the properties.

    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 Articles
    More By McGraw-Hill/Osborne


     

       

    JAVA ARTICLES

    - Introducing the Spring Framework
    - Java Classes
    - Completing the Syntactic Comparison of Java ...
    - Syntactic Comparison of Java and C/C++
    - Java Statements
    - Conditionals, Expressions and Other Java Ope...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup
    - Using RPC-Style Web Services with J2EE
    - Integrating XML with J2EE
    - Taming Tiger: Concurrent Collections
    - Combating the ‘Object Crisis’

    Iron Speed



    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway