JavaServer Faces: The Complete Reference
Chris Schalk
Ed Burns
with James Holmes
Copyright 2007 by The McGraw-Hill Companies, Inc. All rights reserved. Except as permitted under the United States Copyright Act of 1976, no part of this publication may be reproduced or distributed in any form or by any means, or stored in a database or retrieval system, without the prior written permission of the publisher.
ISBN: 978-0-07-171048-0
MHID: 0-07-171048-5
The material in this eBook also appears in the print version of this title: ISBN: 978-0-07-226240-7, MHID: 0-07-226240-0.
All trademarks are trademarks of their respective owners. Rather than put a trademark symbol after every occurrence of a trademarked name, we use names in an editorial fashion only, and to the benefit of the trademark owner, with no intention of infringement of the trademark. Where such designations appear in this book, they have been printed with initial caps.
McGraw-Hill eBooks are available at special quantity discounts to use as premiums and sales promotions, or for use in corporate training programs. To contact a representative please e-mail us at bulksales@mcgraw-hill.com.
Information has been obtained by McGraw-Hill from sources believed to be reliable. However, because of the possibility of human or mechanical error by our sources, McGraw-Hill, or others, McGraw-Hill does not guarantee the accuracy, adequacy, or completeness of any information and is not responsible for any errors or omissions or the results obtained from the use of such information.
TERMS OF USE
This is a copyrighted work and The McGraw-Hill Companies, Inc. (McGraw-Hill) and its licensors reserve all rights in and to the work. Use of this work is subject to these terms. Except as permitted under the Copyright Act of 1976 and the right to store and retrieve one copy of the work, you may not decompile, disassemble, reverse engineer, reproduce, modify, create derivative works based upon, transmit, distribute, disseminate, sell, publish or sublicense the work or any part of it without McGraw-Hills prior consent. You may use the work for your own noncommercial and personal use; any other use of the work is strictly prohibited. Your right to use the work may be terminated if you fail to comply with these terms.
THE WORK IS PROVIDED AS IS. McGRAW-HILL AND ITS LICENSORS MAKE NO GUARANTEES OR WARRANTIES AS TO THE ACCURACY, ADEQUACY OR COMPLETENESS OF OR RESULTS TO BE OBTAINED FROM USING THE WORK, INCLUDING ANY INFORMATION THAT CAN BE ACCESSED THROUGH THE WORK VIA HYPERLINK OR OTHERWISE, AND EXPRESSLY DISCLAIM ANY WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. McGraw-Hill and its licensors do not warrant or guarantee that the functions contained in the work will meet your requirements or that its operation will be uninterrupted or error free. Neither McGraw-Hill nor its licensors shall be liable to you or anyone else for any inaccuracy, error or omission, regardless of cause, in the work or for any damages resulting there from. McGraw-Hill has no responsibility for the content of any information accessed through the work. Under no circumstances shall McGraw-Hill and/or its licensors be liable for any indirect, incidental, special, punitive, consequential or similar damages that result from the use of or inability to use the work, even if any of them has been advised of the possibility of such damages. This limitation of liability shall apply to any claim or cause whatsoever whether such claim or cause arises in contract, tort or otherwise.
For my dad, Frank, the coolest
engineer/rocket scientist/cold warrior
there ever was!
As you used to say,
If youre going to do something,
do it with Audace!
Chris Schalk
To Amy, my best friend, partner, and wife.
Thank you for helping me
achieve my dreams.
Ed Burns
About the Authors
Chris Schalk is a Principal Product Manager and Java Evangelist for Oracles application server and development tools division. Chris primary expertise is Web application development and he works to define the overall set of Web development features for Oracle JDeveloper including JavaServer Faces and ADF Faces. Prior to product management, Chris held positions in both software development and technical marketing at Oracle and IBM. Chris holds a Bachelors of Science in Applied Mathematics with a Specialization in Computer Science from the University of California at Los Angeles. Chris also maintains a popular blog on J2EE Web development at http://www.jroller.com/page/cschalk.
Ed Burns is a senior staff engineer at Sun Microsystems. Ed has worked on a wide variety of client and server-side Web technologies since 1994, including NCSA Mosaic, Mozilla, the Sun Java Plugin, Jakarta Tomcat, and most recently, JavaServer Faces. Ed is currently the co-spec lead for JavaServer Faces. Find Eds blog and other goodies at http://purl.ock.org/NET/edburns/.
James Holmes is a leading Java Web development authority. He is a committer on the Struts project and author of Struts: The Complete Reference. Additionally, Oracle Magazine named him 2002 Java Developer of the Year. He maintains the most comprehensive list of JSF resources on his website at http://www.jamesholmes.com/JavaServerFaces. James is an independent consultant who develops applications for complex transactional environments, including ADP, Bank of America, IBM, SunTrust and UPS. For information on retaining James for Java development projects or training, contact him via email at james@jamesholmes.com. You can also visit his Web site at http://www.JamesHolmes.com/.
Contents at a Glance
Contents
Foreword
What a difference a couple of years makes.
In March 2004, the Expert Group for the JavaServer Faces 1.0 specification (JSR-127) completed its work, and the Final Release was published. But it is interesting to go back a couple of years before that, to when the development process for JavaServer Faces was started.
At that time, there was a wide variety of framework choices for web application architects to choose from. The most popular framework (Apache Struts), as did most of the other frameworks available at the time, provided excellent support for the Model 2 design pattern (encouraging a separation of presentation logic and business logic). However, Struts focused on the server-side logic, and provided only minimal assistance in creating sophisticated user interfaces. There was widespread tools support for Struts, but even here the primary focus was to assist the developer in managing Struts configuration artifacts, and defining page navigation flows. When it came down to designing the individual pages, the user was typically left staring at a blank page, and faced with the task of hand-entering all of the HTML and Struts custom tags necessary to develop a user interface.
In addition, the Java platform was seeing significant competition from other technologiesoften supported by tools such as Microsoft Visual Studiothat supported a different style of development. A tool that could actually draw user interface components on the screen, rather than just showing the developer source code, could tremendously accelerate the development process. Coupled with a focus on simplified platform APIs, this sort of tool could dramatically broaden the population of developers who could leverage these capabilities to produce web applications with high-quality user interfaces.