You are previewing JSF 2.0 Cookbook.
O'Reilly logo
JSF 2.0 Cookbook

Book Description

Over 100 simple but incredibly effective recipes for taking control of your JSF applications

  • Discover JSF 2.0 features through complete examples

  • Put in action important JSF frameworks, such as Apache MyFaces Core, Trinidad, Tomahawk, RichFaces Core, Sandbox and so on

  • Develop JSF projects under NetBeans/Glassfish v3 Prelude and Eclipse/JBoss AS

  • Part of Packt's Cookbook series: Each recipe is a carefully organized sequence of instructions to complete the task as efficiently as possible

  • In Detail

    JavaServer Faces is a Java-based Web application framework intended to simplify development of user interfaces for Java EE applications. You may already be aware of the laborious search through reference guides and documentation to develop your JSF applications. With the JSF Cookbook, you can find solutions to the most common JSF problems in a quick and easy way.

    This book will cover all the important aspects involved in developing JSF applications. It provides clear instructions for getting the most out of JSF and offers many exercises to build impressive desktop-style interfaces for your web applications. Develop JSF applications starting with simple recipes and gradually moving on to complex recipes.

    We discuss all of the fundamental aspects of JSF applications. Once you locate your desired topic, you can try to find a recipe that corresponds to your problem.

    We start off with the simple concepts of Converters, validators and file management. We then work our way with various resources such as CSS, JavaScript, and images to improve your web applications. You will learn to build simple and complex custom components to suit your needs. Next, you get to exploit AJAX as well as implement internationalization and localization for your JSF applications. We then look into ensuring security for your applications and perform testing of your applications. You also get to learn all about Facelets and explore the newest JSF 2.0 features. Finally you get learn a few integrations such as JSTL with JSF, Spring with JSF, and Hibernate with JSF. All these concepts are presented in the form of easy-to-follow recipes.

    Each chapter discusses separate types of recipes and they are presented with an increasing level of complexity from simple to advanced. All of these recipes can be used with JSF 1.2 as well.

    This book helps you to find solutions to the most common aspects regarding JSF development with clear and easy-to-follow recipes

    Table of Contents

    1. JSF 2.0 Cookbook
      1. JSF 2.0 Cookbook
      2. Credits
      3. About the Author
      4. About the Reviewer
      5. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      6. 1. Using Standard and Custom Converters in JSF
        1. Introduction
        2. Working with implicit and explicit conversions
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Standard converters for numbers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Standard converters for date and time
          1. Getting ready
          2. How to do it...
          3. See also
        5. Converters and NULL values
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Creating and using a custom converter
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Using custom converters for h:selectOneMenu
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Binding converters to backing bean properties
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. RichFaces and standard converters
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        10. RichFaces and custom converters
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Instance variables in converters
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        12. Client-side converters with MyFaces Trinidad
          1. Getting ready
          2. How to do it...
            1. How it works...
            2. There's more...
            3. See also
      7. 2. Using Standard and Custom Validators in JSF
        1. Introduction
        2. Using a standard validator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Customizing error messages for validators
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. Creating a custom validator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Binding validators to backing bean properties
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Validating forms with RichFaces rich:beanValidator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        7. Validating forms with RichFaces rich:ajaxValidator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Apache MyFaces Commons validators
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. Bean validation with f:validateBean
          1. Getting ready
          2. How to do it...
          3. There's more...
          4. How it works...
          5. See also
        10. Enforcing a value's presence with f:validateRequired
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Using regular expressions with f:validateRegex
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      8. 3. File Management
        1. Introduction
        2. Downloading files using Mojarra Scales
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Multi-file upload using Mojarra Scales
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. File upload with Apache MyFaces Tomahawk
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. AJAX multi-file upload with RichFaces
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Downloading with PrimeFaces 2.0
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. PPR multi-file upload with PrimeFaces 2.0
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. Extracting data from an uploaded CSV file
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. Exporting data to Excel, PDF, CVS, and XML
          1. Getting ready
          2. How to do it...
          3. There's more...
          4. See also
      9. 4. Security
        1. Introduction
        2. Working with the JSF Security project
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Using the JSF Security project without JAAS Roles
          1. Getting ready
          2. How to do it...
          3. How it works...
        4. Using secured managed beans with JSF Security
          1. Getting ready
          2. How to do it...
          3. See also
        5. Using Acegi/Spring security in JSF applications
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      10. 5. Custom Components
        1. Introduction
        2. Building a "HelloWorld" JSF custom component
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Renderers/validators for custom components
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Adding AJAX support to JSF custom components
          1. Getting ready
          2. How to do it...
            1. Stage 1—creating an image viewer
            2. Stage 2—transforming the image viewer into an image slide viewer
            3. Stage 3—adding AJAX capabilities to the image slide viewer component
          3. See also
        5. Using Proxy Id library for dynamic IDs
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Using JSF ID Generator
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Accessing resources from custom components
          1. How to do it...
          2. How it works...
          3. There's more...
        8. Custom components with Archetypes for Maven
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. RichFaces CDK and custom components
          1. Getting ready
          2. How to do it...
          3. There's more...
          4. See also
        10. Composite custom components with zero Java
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Creating a login composite component in JSF 2.0
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        12. Building a spinner composite component in JSF 2.0
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        13. Mixing JSF and Dojo widget for custom components
          1. Getting ready
          2. How to do it...
          3. See also
      11. 6. AJAX in JSF
        1. Introduction
        2. A first JSF 2.0-AJAX example
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        3. Using the f:ajax tag
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Installing and using Dynamic Faces in NetBeans 6.8
          1. Getting ready
          2. How to do it...
          3. See also
        5. Using the inputSuggestAjax component
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. ajax4jsf—more than 100 AJAX components
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
            1. Other ajax4jsf component
          5. See also
        7. Writing reusable AJAX components in JSF 2.0
          1. How to do it...
          2. How it works...
          3. See also
        8. PrimeFaces, CommandLink, and CommandButton
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      12. 7. Internationalization and Localization
        1. Introduction
        2. Loading message resource bundles in JSF
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. Using locales and message resource bundles
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Message resource bundles without f:loadBundle
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. Working with parameterized messages
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Accessing message resource keys from a class
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Providing a theme to a Visual Web JSF Project
          1. Getting ready
          2. How to do it...
        8. Displaying Arabic, Chinese, Russian, and so on
          1. How to do it...
          2. See also
        9. Selecting a time zone in JSF 2.0
          1. How to do it...
      13. 8. JSF, Images, CSS, and JS
        1. Introduction
        2. Injecting CSS in JSF
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        3. JSF, CSS, and tables
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. JSF and dynamic CSS
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Integrating JavaScript and JSF
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        6. Getting a JSF inputText value from JavaScript
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Working with JSF hidden fields from JavaScript
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        8. Passing parameters from JS to JSF (client to server)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        9. Passing parameters from JSF to JS (server to client)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        10. Opening a pop-up window using JSF and JS
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        11. Passing parameters with HTTP GET within the URL
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        12. Communication between parent pop-up windows
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        13. Populating a JS load function with JSF values
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        14. Dynamic images with PrimeFaces
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        15. Cropping images with PrimeFaces
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        16. Working with rss4jsf project
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        17. Using resource handlers
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
      14. 9. JSF—Managing and Testing
        1. Introduction
        2. Managing JSF with Faces Console
          1. Getting ready
          2. How to do it...
        3. Testing JSF applications with JSFUnit
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        4. JSFUnit and Ant
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. JSFUnit API
          1. How to do it...
        6. A JSF and JMeter issue
          1. Getting ready
          2. How to do it...
          3. How it works...
        7. Working with JSF Chart Creator
          1. Getting ready
          2. How to do it...
          3. See also
      15. 10. Facelets
        1. Introduction
        2. Installing Facelets under JSF 1.2 (or JSF 1.1)
          1. Getting ready
          2. How to do it...
          3. There's more...
        3. Facelets aliasing components
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        4. Facelets templating
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Creating composition components in JSF 2.0
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        6. Passing sub-elements to composition components
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. Passing actions to composition components
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
      16. 11. JSF 2.0 Features
        1. Introduction
        2. JSF 2.0 annotations
          1. How to do it...
            1. Annotations for managed beans
              1. @ResourceDependency annotation
              2. The @ListenerFor annotation
          2. How it works...
            1. Annotations for managed beans
              1. @ResourceDependency annotation
              2. The @ListenerFor annotation
        3. The JSF 2.0 exception handling mechanism
          1. How to do it...
          2. How it works...
          3. See also
        4. Bookmarking JSF pages with PrettyFaces
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
          5. See also
        5. JSF declarative event handling
          1. Getting ready
          2. How to do it...
          3. See also
        6. URLs based on specified navigation outcome
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        7. JSF view parameters
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        8. JSF 2 and navigation cases
          1. How to do it...
          2. How it works...
      17. 12. Mixing JSF with Other Technologies
        1. Introduction
        2. Configuring Seam with JSF
          1. Getting ready
          2. How to do it...
          3. There's more...
            1. Configuring Seam Resource Servlet
            2. Configuring Seam servlet filters
            3. Multipart form submissions
            4. Setting the character encoding
            5. Conversation propagation with redirects
            6. Exception handling
          4. See also
        3. An overview of Seam JSF controls
          1. Getting ready
          2. How to do it...
          3. See also
        4. Mixing JSF and JSTL
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. See also
        5. Integrating JSF and Hibernate
          1. Getting ready
          2. How to do it...
          3. How it works...
        6. Integrating JSF and Spring
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
        7. Mixing JSF and EJB (JPA)
          1. Getting ready
          2. How to do it...
          3. How it works...
          4. There's more...
      18. A. Configuring JSF-related Technologies
        1. Apache MyFaces Trinidad (supports JSF 2.0)
        2. RichFaces (supports JSF 2.0)
        3. Apache MyFaces Tomahawk (supports JSF 1.2)
        4. Apache MyFaces Tomahawk Sandbox (supports JSF 1.2)
          1. Apache MyFaces Commons Validators (supports JSF 2.0)
          2. Prime Faces (supports JSF 2.0)
        5. Mojarra Scales (supports JSF 1.2)
        6. j4j (supports JSF 2.0)
        7. rss4jsf (supports JSF 2.0)