Java
  Home arrow Java arrow Introduction to JavaServer Faces, Part 3
Dev Shed Forums  
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Smartphone Development  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Mobile Linux  
App Generation ROI  
IBM® developerWorks  
Forums Sitemap  
E-Commerce Hosting  
Linux Web Hosting  
Managed Hosting  
Small Business Hosting  
VPS Hosting  
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 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: starstarstarstarstar / 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:
      error-file:tidyout.log Del.ici.ous error-file:tidyout.log Digg
      error-file:tidyout.log Blink error-file:tidyout.log Simpy
      error-file:tidyout.log Google error-file:tidyout.log Spurl
      error-file:tidyout.log Y! MyWeb error-file:tidyout.log 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

     
     
    ADVERTISEMENT


    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

    - Exception Handling Techniques in Java
    - More About Multithreading in Java
    - The Basics of Multiple Threads in Java
    - Data Access Using Spring Framework JDBC
    - New Object Initialization in Java
    - Adding Images With iTextSharp
    - Adding Columns With iTextSharp
    - Creating Simple PDF Files With iTextSharp
    - The Spring Framework: Understanding IoC
    - 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...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
    Stay green...Green IT