Core JavaServer Faces, Second Edition

Book description

JavaServer Faces (JSF) is quickly emerging as the leading solution for rapid user interface development in Java-based server-side applications. Now, Core JavaServer™ Faces–the #1 guide to JSF–has been thoroughly updated in this second edition, covering the latest feature enhancements, the powerful Ajax development techniques, and open source innovations that make JSF even more valuable.

Authors David Geary and Cay Horstmann delve into all facets of JSF 1.2 development, offering systematic best practices for building robust applications, minimizing handcoding, and maximizing productivity. Drawing on unsurpassed insider knowledge of the Java platform, they present solutions, hints, tips, and “how-tos” for writing superior JSF 1.2 production code, even if you’re new to JSF, JavaServer Pages™, or servlets.

The second edition’s extensive new coverage includes: JSF 1.2’s improved alignment with the broader Java EE 5 platform; enhancements to the JSF APIs; controlling Web flow with Shale; and using Facelets to replace JSP with XHTML markup. The authors also introduce Ajax development with JSF–from real-time validation and Direct Web Remoting to wrapping Ajax in JSF components and using the popular Ajax4jsf framework.

This book will help you

  • Automate low-level details and eliminate unnecessary complexity in server-side development

  • Discover JSF best practices, ranging from effective UI design and style sheets to internationalization

  • Use JSF with Tiles to build consistent, reusable user interfaces

  • Leverage external services such as databases, LDAP directories, authentication/authorization, and Web services

  • Use JBoss Seam to greatly simplify development of database-backed applications

  • Implement custom components, converters, and validators

  • Master the JSF 1.2 tag libararies, and extend JSF with additional tag libraries


  • Preface
    Acknowledgments

    Chapter 1: Getting Started
    Chapter 2: Managed Beans
    Chapter 3: Navigation
    Chapter 4: Standard JSF Tags
    Chapter 5: Data Tables
    Chapter 6: Conversion and Validation
    Chapter 7: Event Handling
    Chapter 8: Subviews and Tiles
    Chapter 9: Custom Components, Converters, and Validators
    Chapter 10: External Services
    Chapter 11: Ajax
    Chapter 12: Open Source
    Chapter 13: How Do I . . .
    Index 

    Table of contents

    1. Copyright
    2. Preface
      1. About This Book
      2. Required Software
      3. Web Support
    3. Acknowledgments
    4. 1. Getting Started
      1. Why JavaServer Faces?
      2. Software Installation
      3. A Simple Example
        1. Ingredients
        2. Directory Structure
        3. Build Instructions
      4. Sample Application Analysis
        1. Beans
        2. JSF Pages
        3. Navigation
        4. Servlet Configuration
        5. The Welcome File
      5. Development Environments for JSF
        1. Integrated Development Environments
        2. Visual Builder Tools
        3. Automation of the Build Process with Ant
      6. JSF Framework Services
      7. Behind the Scenes
        1. Rendering Pages
        2. Decoding Requests
        3. The Life Cycle
    5. 2. Managed Beans
      1. Definition of a Bean
        1. Bean Properties
        2. Value Expressions
      2. Message Bundles
        1. Messages with Variable Parts
        2. Setting the Application Locale
      3. A Sample Application
      4. Backing Beans
      5. Bean Scopes
        1. Session Scope
        2. Application Scope
        3. Request Scope
        4. Life Cycle Annotations
      6. Configuring Beans
        1. Setting Property Values
        2. Initializing Lists and Maps
        3. Chaining Bean Definitions
        4. String Conversions
      7. The Syntax of Value Expressions
        1. Using Brackets
        2. Map and List Expressions
        3. Resolving the Initial Term
        4. Composite Expressions
        5. Method Expressions
    6. 3. Navigation
      1. Static Navigation
      2. Dynamic Navigation
      3. Advanced Navigation Issues
        1. Redirection
        2. Wildcards
        3. Using from-action
        4. The Navigation Algorithm
    7. 4. Standard JSF Tags
      1. An Overview of the JSF Core Tags
      2. An Overview of the JSF HTML Tags
        1. Common Attributes
          1. Basic Attributes
          2. IDs and Bindings
          3. Values, Converters, and Validators
          4. Styles
          5. Conditional Rendering
          6. HTML 4.0 Attributes
          7. DHTML Events
      3. Forms
        1. Form Elements and JavaScript
      4. Text Fields and Text Areas
        1. Hidden Fields
        2. Using Text Fields and Text Areas
        3. Displaying Text and Images
      5. Buttons and Links
        1. Using Command Buttons
        2. Using Command Links
      6. Selection Tags
        1. Checkboxes and Radio Buttons
        2. Menus and Listboxes
        3. Items
          1. The f:selectItem Tag
          2. The f:selectItems Tag
          3. Item Groups
          4. Binding the value Attribute
          5. All Together: Checkboxes, Radio Buttons, Menus, and Listboxes
      7. Messages
      8. Panels
    8. 5. Data Tables
      1. The Data Table Tag—h:dataTable
      2. A Simple Table
        1. h:dataTable Attributes
        2. h:column Attributes
      3. Headers, Footers, and Captions
      4. JSF Components
      5. Editing Table Cells
      6. Styles
        1. Styles by Column
        2. Styles by Row
      7. Database Tables
        1. JSTL Result Versus Result Sets
      8. Table Models
        1. Editing Table Models
        2. Sorting and Filtering
      9. Scrolling Techniques
        1. Scrolling with a Scrollbar
        2. Scrolling with Pager Widgets
    9. 6. Conversion and Validation
      1. Overview of the Conversion and Validation Process
      2. Using Standard Converters
        1. Conversion of Numbers and Dates
          1. Converters and Attributes
          2. The converter Attribute
        2. Conversion Errors
          1. Displaying Error Messages
          2. Displaying All Error Messages
          3. Using a Custom Error Message
          4. Changing the Text of Standard Error Messages
        3. A Complete Converter Example
      3. Using Standard Validators
        1. Validating String Lengths and Numeric Ranges
        2. Checking for Required Values
        3. Displaying Validation Errors
        4. Bypassing Validation
        5. A Complete Validation Example
      4. Programming with Custom Converters and Validators
        1. Implementing Custom Converter Classes
          1. Specifying Converters
          2. Reporting Conversion Errors
          3. Getting Error Messages from Resource Bundles
          4. The Custom Converter Sample Application
        2. Implementing Custom Validator Classes
        3. Registering Custom Validators
        4. Validating with Bean Methods
        5. Supplying Attributes to Converters
        6. Validating Relationships Between Multiple Components
    10. 7. Event Handling
      1. Life Cycle Events
      2. Value Change Events
      3. Action Events
      4. Event Listener Tags
        1. The f:actionListener and f:valueChangeListener Tags
      5. Immediate Components
        1. Using Immediate Input Components
        2. Using Immediate Command Components
      6. Passing Data from the UI to the Server
        1. The f:param Tag
        2. The f:attribute Tag
        3. The f:setPropertyActionListener Tag
      7. Phase Events
      8. Putting It All Together
    11. 8. Subviews and Tiles
      1. Common Layouts
      2. A Book Viewer and a Library
      3. The Book Viewer
        1. Monolithic JSF Pages
        2. Common Content Inclusion
        3. Content Inclusion in JSP-Based Applications
        4. JSF-Specific Considerations
      4. Content Inclusion in the Book Viewer
        1. Looking at Tiles
        2. Installing Tiles
        3. Using Tiles with the Book Viewer
        4. Parameterizing Tiles
        5. Extending Tiles
      5. The Library
        1. Nested Tiles
        2. Tile Controller
    12. 9. Custom Components, Converters, and Validators
      1. Classes for Implementing Custom Components
        1. Tags and Components
        2. The Custom Component Developer’s Toolbox
      2. Encoding: Generating Markup
      3. Decoding: Processing Request Values
        1. Using Converters
      4. Implementing Custom Component Tags
        1. The TLD File
        2. The Tag Handler Class
        3. The Spinner Application
        4. Defining Tag Handlers in JSF 1.1
      5. Revisiting the Spinner
        1. Using an External Renderer
        2. Calling Converters from External Renderers
        3. Supporting Value Change Listeners
        4. Supporting Method Expressions
        5. The Sample Application
      6. Encoding JavaScript to Avoid Server Roundtrips
      7. Using Child Components and Facets
        1. Processing SelectItem Children
        2. Processing Facets
        3. Encoding CSS Styles
        4. Using Hidden Fields
        5. Saving and Restoring State
        6. Firing Action Events
        7. Using the Tabbed Pane
      8. Implementing Custom Converters and Validators
        1. Custom Converter Tags
          1. Saving and Restoring State
          2. The Sample Custom Converter Application
        2. Custom Validator Tags
    13. 10. External Services
      1. Database Access with JDBC
        1. Issuing SQL Statements
        2. Connection Management
        3. Plugging Connection Leaks
        4. Using Prepared Statements
      2. Configuring a Data Source
        1. Configuring a Database Resource in GlassFish
        2. Configuring a Database Resource in Tomcat
        3. Accessing a Container-Managed Resource
        4. A Complete Database Example
      3. An Introduction to LDAP
        1. LDAP Directories
        2. Configuring an LDAP Server
        3. Accessing LDAP Directory Information
      4. Managing Configuration Information
        1. Configuring a Bean
        2. Configuring the External Context
        3. Configuring a Container-Managed Resource
        4. Creating an LDAP Application
      5. Container-Managed Authentication and Authorization
      6. Using Web Services
    14. 11. Ajax
      1. Ajax Fundamentals
      2. JavaScript Libraries
        1. The Prototype Library
        2. The Fade Anything Technique Library
      3. Form Completion
      4. Realtime Validation
      5. Propagating Client-Side View State
      6. Direct Web Remoting
      7. Ajax Components
        1. Hybrid Components
          1. The Rico Accordion
          2. The JSF-Rico Accordion Hybrid
        2. Keeping JavaScript Out of Renderers
        3. Transmitting JSP Tag Attributes to JavaScript Code
      8. Ajax4jsf
        1. Implementing Form Completion with Ajax4jsf
        2. Implementing Realtime Validation with Ajax4jsf
    15. 12. Open Source
      1. Web Flow—Shale
        1. Dialog Configuration
        2. Entering a Dialog
        3. Dialog Navigation
        4. Dialog Scope
        5. Dialog Context Sensitivity
        6. Subdialogs
      2. Alternate View Technologies—Facelets
        1. XHTML Views
        2. Replacing Markup with JSF Components: The jsfc Attribute
        3. Using JSF Tags
        4. Page Composition with Templates
        5. Facelets Custom Tags
      3. EJB Integration—Seam
        1. An Address Book
        2. Configuration
        3. Entity Beans
        4. Stateful Session Beans
        5. JSF DataModel Integration
        6. Conversation Scope
    16. 13. How Do I ...
      1. Web User Interface Design
        1. How Do I Find More Components?
        2. How Do I Support File Uploads?
        3. How Do I Show an Image Map?
        4. How Do I Include an Applet in My Page?
        5. How Do I Produce Binary Data in a JSF Page?
        6. How Do I Show a Large Data Set, One Page at a Time?
        7. How Do I Generate a Pop-up Window?
        8. How Do I Selectively Show and Hide Components?
        9. How Do I Customize Error Pages?
      2. Validation
        1. How Do I Write My Own Client-Side Validation Tag?
        2. How Do I Use the Shale Validator for Client-Side Validation?
        3. How Do I Validate Relationships Between Components?
      3. Programming
        1. How Do I Use JSF with Eclipse?
        2. How Do I Locate a Configuration File?
        3. How Can a JSF Component Access Resources From a JAR File?
        4. How Do I Package a Set of Tags into a JAR File?
        5. How do I Get the Form ID for Generating document.forms[id] in JavaScript?
        6. How Do I Make a JavaScript Function Appear Only Once Per Page?
        7. How Do I Carry Out Initialization or Cleanup Work?
        8. How Do I Store a Managed Bean Longer than Request Scope But Shorter Than Session Scope?
        9. How Do I Extend the JSF Expression Language?
      4. Debugging and Logging
        1. How Do I Decipher a Stack Trace?
        2. How Do I Avoid the “Stack Trace From Hell”?
        3. How Do I “Hot Deploy” My Application?
        4. How Do I Comment Out a Part of a JSF Page?
        5. How Do I Find the Logs?
        6. How Do I Find Out What Parameters My Page Received?
        7. How Do I Turn on Logging of the JSF Container?
        8. How Do I Debug a Stuck Page?
        9. How Do I Find the Library Source?

    Product information

    • Title: Core JavaServer Faces, Second Edition
    • Author(s): David Geary, Cay Horstmann
    • Release date: May 2007
    • Publisher(s): Pearson
    • ISBN: 9780131738867