Java
  Home arrow Java arrow Page 3 - Introduction to JavaServer Faces Part 2
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 2
By: McGraw-Hill/Osborne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: starstarstarstarstar / 20
    2004-03-15


    Table of Contents:
  • Introduction to JavaServer Faces Part 2
  • The Action Listener
  • Continuing With the navigateComponent Tree
  • Console Message
  • And the Message
  • Authoring the JSP Page for the Validator Example

  • 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 2 - Continuing With the navigateComponent Tree
    ( Page 3 of 6 )

    The navigateComponentTree method is called recursively. It first prints the identifier of the component passed in to it. The identifier is indented by a number of blank spaces proportionate to the level argument. The level argument determines the number of spaces before the component name. The indention gives the effect of a hierarchy. When called from the processAction method, the navigateComponentTree method is passed 0 as the level argument.


    for (int i=0i<leveli++)
    System
    .out.print(" ");
    // print component id
    System.out.println(component.getComponentId());

    The navigateComponentTree method then obtains the children of the passed in component by calling the getChildren method of the UIComponent interface. The getChildren method returns an Iterator containing all children of the component.


    Iterator children component.getChildren();

    Next, it iterates all the children and calls the navigateComponentTree method for each of the component’s children.


    </f:use_faces><f:use_faces>// navigate children
    while (children.hasNext()) {
    UIComponent child = (UIComponent) children.next();
    navigateComponentTree(child, level + 1);
     }
    }
    </f:use_faces><f:use_faces>

    NOTE  All the applications for this book can be downloaded from the book’s web site on http://www.brainysoftware.com. Applications are named after the chapters, thus JSFCh01 for Chapter 1, JSFCh10 for Chapter 10, and so on. Because Chapter 2 has three applications, they are named JSFCh02a, JSFCh02b, and JSFCh02c, respectively. You simply need to copy these applications to the webapps directory under %CATALINA_HOME%. All .java files are located under the WEB-INF/classes directory. Also, you must copy the jar files to the WEB-INF/lib directory of each application, as explained in the “Introduction.”

    Compiling and Running the Listener and Component Tree Example

    To compile the application, change to the JSFCh02a/WEB-INF/classes directory. If you are using Windows, type the following command:

    javac -classpath ../lib/jsf-api.jar;../lib/jsfri.
    jar
    ;../../../../common/lib/servlet-api.jar ch02a


    Note that to compile the source files, you need two library files in the lib directory and the servlet-api.jar file. In Tomcat 5, the servlet-api.jar file can be found in the common/lib directory of Tomcat’s home directory.

    If you are using Linux/Unix, use colons (rather than semicolons) to separate the library files:


    javac -classpath ../lib/jsf-api.jar:../lib/jsfri.
    jar
    :../../../../common/lib/servlet-api.jar ch02a


    Then run Tomcat. You can then direct your browser to the following URL:


    http://localhost:8080/JSFCh02a/faces/adder.jsp

    Note that you use the /faces/ pattern before the JSP page name. You will see something similar to Figure 6 in your browser.

    Buy this book now!Remember: This is part one of the second chapter of JavaServer Faces Programming, by Budi Kurniawan (McGraw-Hill/Osborne, ISBN 0-07-222983). Stay tuned for more helpful chapters from McGraw-Hill/Osborne.
    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 2 Hosted by Hostway
    Stay green...Green IT