Java
  Home arrow Java arrow Page 2 - Introduction to JavaServer Faces Part ...
Dev Shed Forums 
Administration  
AJAX  
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 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
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: 4 stars4 stars4 stars4 stars4 stars / 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:
      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
     
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Introduction to JavaServer Faces Part 2 - The Action Listener


    (Page 2 of 6 )

    An ActionListener must implement the javax.faces.event.ActionListener interface. It provides the implementations for the getPhaseId and processAction methods. The getPhaseId method must return a javax.faces.event.PhaseId, and its return value determines in which process event step of the request processing lifecycle the listener will be executed. The getPhaseId method in the ActionListener in Listing 5 returns PhaseId.APPLY_REQUEST_VALUES. This will make the ActionListener‘s processAction method be called after the Apply Request Values phase of the request processing lifecycle.

    The processAction method accepts the javax.faces.event.ActionEvent object from the Lifecycle object. In the ActionListener in Listing 5, the processAction method first obtains the component that triggered the event by calling the getComponent method of the ActionEvent class, and then it prints the component identifier.


    UIComponent component event.getComponent();
    System
    .out.println(
    "The id of the component that fired the action event: "
    component.getComponentId());

    It then prints the action command of the ActionEvent object.


    // the action command
    String actionCommand = event.getActionCommand();
    System.out.println("Action command: " + actionCommand);

    Next, it obtains the instance of the current FacesContext and calls its getTree method to acquire the component tree (an instance of javax.faces.tree.Tree class) representing the request page.


    </f:use_faces><f:use_faces>FacesContext facesContext FacesContext.getCurrentInstance();
    Tree tree 
    facesContext.getTree();

    To get the root of the component tree, it calls the getRoot method of the Tree class.

    UIComponent root tree.getRoot();

    Next, it passes the root to the private method navigateComponentTree, which draws the component tree hierarchy.

    navigateComponentTree(root0);

    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

    - 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...
    - Java Operators
    - Primitive Data Types and Basic Language Rule...
    - Java and Object-Oriented Programming
    - Java Beginning Programming
    - Gaming Development Setup

    IBM developerWorks




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