JavaServer Faces

Book description

JavaServer Faces, or JSF, brings a component-based model to web application development that's similar to the model that's been used in standalone GUI applications for years. The technology builds on the experience gained from Java Servlets, JavaServer Pages, and numerous commercial and open source web application frameworks that simplify the development process.In JavaServer Faces, developers learn how to use this new framework to build real-world web applications. The book contains everything you'll need: how to construct the HTML on the front end; how to create the user interface components that connect the front end to your business objects; how to write a back-end that's JSF-friendly; and how to create the deployment descriptors that tie everything together.JavaServer Faces pays particular attention to simple tasks that are easily ignored, but crucial to any real application: working with tablular data, for example, or enabling and disabling buttons. And this book doesn't hide from the trickier issues, like creating custom components or creating renderers for different presentation layers. Whether you're experienced with JSF or a just starting out, you'll find everything you need to know about this technology in this book.Topics covered include:

  • The JSF environment
  • Creating and rendering components
  • Validating input
  • Handling user-generated events
  • Controlling page navigation
  • Working with tabular data
  • Internationalization
  • Integration between JSF and Struts
  • Developing custom renderers and custom components
JavaServer Faces is a complete guide to the crucial new JSF technology. If you develop web applications, JSF belongs in your toolkit, and this book belongs in your library.

Publisher resources

View/Submit Errata

Table of contents

  1. A Note Regarding Supplemental Files
  2. Preface
    1. In This Book
    2. Audience
      1. What You Need to Know
    3. Organization
    4. About the Examples
    5. Conventions Used in This Book
    6. How to Contact Us
    7. Acknowledgments
  3. 1. Introducing JavaServer Faces
    1. 1.1. What Is JavaServer Faces?
    2. 1.2. How Does JSF Compare to Traditional Technologies?
      1. 1.2.1. Less Code in the User Interface Templates
      2. 1.2.2. More Modular User Interface Code
    3. 1.3. Where Does JSF Fit in the Big Picture?
      1. 1.3.1. Using JSF with JSP
      2. 1.3.2. Using JSF with Struts and Other Application Frameworks
      3. 1.3.3. Using JSF with Enterprise JavaBeans
    4. 1.4. What You Need to Get Started
  4. 2. JSF Development Process Overview
    1. 2.1. Developing an Application with a JSF-Based User Interface
    2. 2.2. Developing the Application Backend
    3. 2.3. Developing Components and Integration Code
    4. 2.4. Developing the User Interface Pages
  5. 3. Setting Up the JSF Environment
    1. 3.1. Installing the Java Software Development Kit
    2. 3.2. Installing the Tomcat Server
      1. 3.2.1. Windows Platforms
      2. 3.2.2. Unix Platforms (Including Linux and Mac OS X)
    3. 3.3. Testing Tomcat
    4. 3.4. Installing the Book Examples
    5. 3.5. Example Web Application Overview
  6. 4. Servlet and JavaServer Pages Basics
    1. 4.1. HTTP
      1. 4.1.1. Requests in Detail
      2. 4.1.2. Responses in Detail
      3. 4.1.3. Request Parameters
      4. 4.1.4. Request Methods
    2. 4.2. Web Application Deployment and Runtime Environment
      1. 4.2.1. Web Containers and Servlet Contexts
    3. 4.3. Servlets, Filters, and Listeners
      1. 4.3.1. Using Request Data
      2. 4.3.2. Compiling, Installing, and Running a Servlet
      3. 4.3.3. Generating Responses of Different Types
      4. 4.3.4. Filters and Listeners
        1. 4.3.4.1. Filters
        2. 4.3.4.2. Listeners
    4. 4.4. JavaServer Pages
      1. 4.4.1. JSP Processing
      2. 4.4.2. JSP Elements
        1. 4.4.2.1. Directive elements
        2. 4.4.2.2. Action elements
        3. 4.4.2.3. Scripting elements
        4. 4.4.2.4. Expression Language expressions
        5. 4.4.2.5. JSP comments
      3. 4.4.3. Creating, Installing, and Running a JSP Page
    5. 4.5. Accessing Application Data
  7. 5. Developing the Business Logic and Setting Up Authentication
    1. 5.1. Sample Application Overview
    2. 5.2. Implementing the Business Logic Classes
      1. 5.2.1. The ReportEntry Class
      2. 5.2.2. The Report Class
      3. 5.2.3. The ReportRegistry and FileReportRegistry Classes
    3. 5.3. Authentication and Authorization
      1. 5.3.1. Authenticating the User
      2. 5.3.2. Controlling Access to Web Resources
  8. 6. Creating and Rendering Components
    1. 6.1. The Basics
      1. 6.1.1. Using JSF Components in a JSP Page
      2. 6.1.2. Creating JSF Components
      3. 6.1.3. Rendering the View
      4. 6.1.4. Saving the View State
      5. 6.1.5. Installing and Configuring a JSF Web Application
      6. 6.1.6. Running a JSP Page Containing JSF Components
    2. 6.2. Binding Components to Model Properties
      1. 6.2.1. Using JSF EL Expressions
      2. 6.2.2. Using Value Binding Expressions
      3. 6.2.3. Converting Between Model and View Data Formats
      4. 6.2.4. Creating Objects Automatically as They Are Needed
    3. 6.3. Conditionally Render Components
      1. 6.3.1. Conditionally Disable Components Using Bean Properties
      2. 6.3.2. Conditionally Include Components Using Bean Properties
  9. 7. Validating Input
    1. 7.1. Dealing with Syntax Errors in User Input
    2. 7.2. Using the Standard Validators
      1. 7.2.1. Value Bindings for the Report Entry Fields
    3. 7.3. Defining Custom Error Messages
    4. 7.4. Using a Custom Validator
      1. 7.4.1. Registering a Custom Validator
      2. 7.4.2. Using a Custom Validator in a JSP Page
      3. 7.4.3. Developing a Validator Custom Action
      4. 7.4.4. Deploying the Custom Tag Library
      5. 7.4.5. An Alternative for the Lazy
    5. 7.5. Other Ways to Validate Input
  10. 8. Handling Events
    1. 8.1. Understanding the JSF Event Model
      1. 8.1.1. The Request Processing Lifecycle Phases
    2. 8.2. Handling Application Backend Events
      1. 8.2.1. Using an Action Method and the Default ActionListener
      2. 8.2.2. Using an Action Listener Method or Instance
      3. 8.2.3. Specifying When to Fire an Event
    3. 8.3. Handling User Interface Events
      1. 8.3.1. Triggering an Event by Clicking a Button or a Link
      2. 8.3.2. Triggering an Event by Changing a Value
  11. 9. Controlling Navigation
    1. 9.1. Moving Between JSF Views
      1. 9.1.1. Choosing Between Redirect and Direct Rendering
      2. 9.1.2. Using a Panel Component for Layout
    2. 9.2. Returning a Non-JSF View Response
      1. 9.2.1. Linking Non-JSF Resources
      2. 9.2.2. Processing JSF Input and Generating a Non-JSF Response
    3. 9.3. Returning a JSF View Response to a Non-JSF Request
  12. 10. Working with Tabular Data
    1. 10.1. Displaying a Read-Only Table
      1. 10.1.1. Using Facets
      2. 10.1.2. A Word About JSF and Databases
    2. 10.2. Processing Row-Specific Events
    3. 10.3. Dealing with Large Tables
      1. 10.3.1. Sorting the Data
      2. 10.3.2. Scrolling Through the Data
      3. 10.3.3. Giving the Table Some Style
    4. 10.4. Editing Tabular Data
  13. 11. Internationalization
    1. 11.1. Localizing Application Output
      1. 11.1.1. Selecting Localized Text
      2. 11.1.2. Formatting Dates and Numbers
      3. 11.1.3. Localizing Messages
    2. 11.2. Handling Localized Application Input
    3. 11.3. Dealing with Non-Western Languages
  14. 12. Odds and Ends
    1. 12.1. Building a View from Many JSP Files
      1. 12.1.1. Using Static Includes for Pages with JSF Components
        1. 12.1.1.1. Using one or multiple forms
        2. 12.1.1.2. The included files
      2. 12.1.2. Using Dynamic Includes for Pages with JSF Components
        1. 12.1.2.1. Naming containers for included content
    2. 12.2. Combining JSF Views with Other Content
    3. 12.3. Dealing with Struts Applications and JSF
      1. 12.3.1. Using the Struts-Faces Integration Package
      2. 12.3.2. Migrating a Struts Application to JSF
      3. 12.3.3. Picking the Right Technology for a New Application
    4. 12.4. Programmatically Modifying Components
    5. 12.5. Using a PhaseListener
    6. 12.6. Debugging and Error Handling Ideas
      1. 12.6.1. Using Standard Java Debugging Techniques
      2. 12.6.2. Using Standard Web Application Error Handling
      3. 12.6.3. Using Client-Side State Saving During Development
      4. 12.6.4. Capturing State with a PhaseListener
  15. 13. Developing Custom Renderers and Other Pluggable Classes
    1. 13.1. Developing Custom Renderers
      1. 13.1.1. A Renderer for Encoding Only
        1. 13.1.1.1. The Renderer class
        2. 13.1.1.2. Registering the renderer
        3. 13.1.1.3. The JSP tag handler class
        4. 13.1.1.4. Using the custom renderer
      2. 13.1.2. A Renderer for Encoding and Decoding
        1. 13.1.2.1. The Renderer class
        2. 13.1.2.2. Registering the renderer
        3. 13.1.2.3. The JSP tag handler class
    2. 13.2. Using Other Custom Classes
    3. 13.3. Packaging Custom Classes
  16. 14. Developing Custom Components
    1. 14.1. Extending an Existing Component
      1. 14.1.1. The TabbedRenderer Class
      2. 14.1.2. The UITabLabel Class
      3. 14.1.3. Registering the Component
      4. 14.1.4. The JSP Tag Handler Class
    2. 14.2. Developing a New Component from Scratch
      1. 14.2.1. The TreeModel Class
      2. 14.2.2. The UITree Component Class
      3. 14.2.3. The TreeRenderer Class
      4. 14.2.4. Registering the Component and the Renderer
      5. 14.2.5. The JSP Tag Handler Class
  17. 15. Developing a Custom Presentation Layer
    1. 15.1. The ViewHandler Class
    2. 15.2. Using Java Classes as Views
      1. 15.2.1. Developing the View Class
      2. 15.2.2. Developing the ViewHandler
    3. 15.3. Using Pure HTML Templates with XML View Definition Files
      1. 15.3.1. Developing the HTML Template and the View Specification
      2. 15.3.2. Developing the ViewHandler
  18. A. Standard JSF Tag Libraries
    1. A.1. JSF Tag Libraries URIs and Default Prefixes
    2. A.2. HTML Tag Library Actions
      1. A.2.1. Supported HTML 4.01 Attributes
    3. A.3. Core Library Actions
  19. B. JSF Expression Language Reference
    1. B.1. Syntax
      1. B.1.1. Literals
      2. B.1.2. Keywords and Reserved Words
    2. B.2. Variables
      1. B.2.1. Implicit Variables
    3. B.3. Data Types
      1. B.3.1. Coercion Rules
    4. B.4. Expressions and Operators
      1. B.4.1. Operand Evaluation and Coercing Rules
        1. B.4.1.1. Property and array accessor operators
        2. B.4.1.2. Arithmetic operators
        3. B.4.1.3. Relational operators
        4. B.4.1.4. Logical operators
        5. B.4.1.5. Empty operator
  20. C. Standard JSF Components and Render Kits
    1. C.1. Component Class Categories
    2. C.2. Render-Independent Components
      1. C.2.1. Component Interfaces
      2. C.2.2. Component Classes
      3. C.2.3. Model Classes and Interfaces
    3. C.3. HTML Render Kit Classes
      1. C.3.1. Renderer Class
      2. C.3.2. Standard Renderer Behavior
    4. C.4. HTML-Specific Component Classes
    5. C.5. Request Processing Lifecycle
      1. C.5.1. Restore View
      2. C.5.2. Apply Request Values
      3. C.5.3. Process Validations
      4. C.5.4. Update Model Values
      5. C.5.5. Invoke Application
      6. C.5.6. Render Response
  21. D. Infrastructure API Reference
    1. D.1. Package javax.faces
    2. D.2. Package javax.faces.application
    3. D.3. Package javax.faces.context
    4. D.4. Package javax.faces.convert
    5. D.5. Package javax.faces.el
    6. D.6. Package javax.faces.event
    7. D.7. Package javax.faces.lifecycle
    8. D.8. Package javax.faces.render
    9. D.9. Package javax.faces.validator
    10. D.10. Package javax.faces.webapp
    11. D.11. Identifiers for Standard JSF Messages
  22. E. JSF Configuration File Reference
    1. <description>, <display-name>, and <icon>
    2. <application>
    3. <factory>
    4. <component>
    5. <converter>
    6. <lifecycle>
    7. <managed-bean>
    8. <navigation-rule>
    9. <referenced-bean>
    10. <render-kit>
    11. <validator>
  23. F. Web Application Structure and Deployment Descriptor Reference
    1. F.1. Web Application File Structure
      1. F.1.1. Placing Java Class Files in the Right Directory
    2. F.2. Web Application Deployment Descriptor
      1. Reference Section
      2. Reference Section
      3. Reference Section
      4. Reference Section
      5. Reference Section
      6. Reference Section
      7. Reference Section
      8. Reference Section
      9. Reference Section
      10. Reference Section
      11. Reference Section
      12. Reference Section
      13. Reference Section
      14. Reference Section
      15. Reference Section
      16. Reference Section
      17. Reference Section
      18. Reference Section
      19. Reference Section
      20. Reference Section
      21. Reference Section
      22. Reference Section
      23. Reference Section
      24. Reference Section
      25. Reference Section
      26. F.2.1. Example Application Deployment Descriptor
    3. F.3. Creating a WAR File
  24. About the Author
  25. Colophon
  26. Copyright

Product information

  • Title: JavaServer Faces
  • Author(s): Hans Bergsten
  • Release date: April 2004
  • Publisher(s): O'Reilly Media, Inc.
  • ISBN: 9780596005399