Core JavaServer Faces (3rd Edition) - A Review
Buy it now
One Minute Bottom Line
If you are a faithful JEE developer and want to hone your View Layer skills, this book will help you learn the JSF 2.0 specification. Even with some excellent implementations of this specification out there, you'll be comfortable with the basics in no time.
The Table of Contents:
- Chapter 01: Getting Started
- Chapter 02: Managed Beans
- Chapter 03: Navigation
- Chapter 04: Standard Jsf Tags
- Chapter 05: Facelets
- Chapter 06: Data Tables
- Chapter 07: Conversion And Validation
- Chapter 08: Event Handling
- Chapter 09: Composite Components
- Chapter 10: Ajax
- Chapter 11: Custom Components, Converters, And Validators
- Chapter 12: External Services
- Chapter 13: How Do I . . . ?
Chapter 01: Getting Started
An excellent and valuable introduction. The chapter begins with the section Why JavaServer Faces?, explaining the components of JSF and offering a sample code that details a simple login case. The source code to get this login working is available, with each file accompanied by an explanation.
Next the Directory Structure is explained so that you'll know where to put your files.
Building and Deploying the JSF Application is explained in two sections with step-by-step instructions. Here the author uses GlassFish running on Unix/Linux.
A quick variation of this login example is available and working with Ajax.
Another important section is JSF Framework Services, which provides more detailed explanations of how the components of JSF work. I found the images used here and in other sections to be quite helpful.
The chapter ends on a practical note: the JSF's Life Cycle is well covered with an explanation of each cycle.
Chapter 02: Managed Beans
Here the author provides an in-depth explanation of how to use and configure a Bean to be used for JSF. Some patterns and many annotations are covered throughout this chapter, including how to work with Value Expressions.
The sample code for this chapter is a Quiz Form where again each related file is clearly explained.New to this edition is the use of annotations like @ManagedBean, @SessionScoped, and CDI Beans.
The following sections are are also covered:
- Message Bundles
- Messages with Variable Parts
- Setting the Application Locale
- Bean Scopes
The Bean Scopes section includes these scopes:
- Session scope
- Request scope
- Application scope
- Conversation Scope
- View Scope
Bean Life Cycle Annotations is covered too, which makes it possible to work with the @PostConstruct and @PreDestroy annotations. And the old school isn't left out entirely: on several pages you'll find information about JSF - XML configurations.
Chapter 03: Navigation
This chapter covers configuring and working with navigation, especially the h:commandButton tag. As before, many images have been included to facilitate comprehension. The source code and settings are available and they are very easy to be understand. There's even a little bit about REST Navigation.
Chapter 04: Standard Jsf Tags
This somewhat lengthy chapter consists of tables containing certain tags which are used throughout the book. The most important of these are:
- JSF Tag Libraries
- JSF Core Tags
- JSF HTML Tags
- Basic HTML Tag Attributes
- HTML 4.0 Pass-Through Attributes
Chapter: 05 Facelets
Opens with an introduction about Facelets, including an explanation of how they can be grouped by categories and a table explaining some tags. A sample application titled Logging into the planetarium lets you see how useful the templates are.
This chapter is not long but it still has a good amount of sample code.
Chapter 06: Data Tables
Works closely with the h:dataTable tag and its attributes. The authors start with a simple case using a table. Throughout the rest of the chapter, as the tables become more advanced, tag elements like h:dataTable and h:column are introduced with respective explanations.
Styles and its interaction CSS is covered, as well as events with tables (e.g. editing and deleting rows) and a database exercise.
Other features covered are:
- Sorting and Filtering
- Scrolling Techniques
Each example includes the source code with its respective explanation for each file.
Chapter 07: Conversion And Validation
A long chapter and of course an important concern for any application in real life. The chapter begins with a section named Overview of the Conversion and Validation Process, based on important theory and even including an image for better documentation.
Ok, time to code! Conversion of Numbers and Dates is introduced with two samples using the tags f:convertNumber and f:convertDateTime respectively.
The following section Conversion Errors, is important and well covered, even including a valuable table named Standard Conversion Error Messages, which lists many javax.faces.converter elements and their respective explanations.
Next is Using Standard Validators, which covers many important topcs like:
- String Lengths and Numeric Ranges (even including a table)
- Required Values
- Displaying Validation Errors (including a big table listing many items from javax.faces.validator)
A complete sample code that utilizes all of the above points follows.
Next the authors discuss Bean Valitadion JSF 2.0, working with annotations based on Bean Validation Framework (JSR 303), including a table listing and explaining the most important annotations.
The rest of the chapter is a little more complex, as it deals with creating your own custom Converters And Validators. The source code and theory here spans around twenty eight pages!
Chapter 08: Event Handling
It is an important chapter, starting with the section Events and the JSF Life Cycle that displays an important image showing this cycle.
The chapter covers the following sections:
- Value change events
- Action events
- Event Listener
- Immediate Components
- Phase events (short covering)
- System events (Even including a table listing many important Event classes with its respective explanation)
Each section has sample code with its respective explanation and many images to show how each application works.
Many attributes and elements are covered throughout the chapter, such as:
A good amount of source code is available for this section.
Chapter 09: Composite Components
Starts with the section The Composite Tag Library, including a table named Composite Component Tags listing many items with their respective explanations.
This chapter provides an in-depth treatment of the following topics:
- Implementing Composite Components
- Configuring Composite Components
- Attribute Types
- Manipulating Server-Side Data
- Exposing a Composite’s Components
- Exposing Action Sources
All these sections include their own source code with its respective explanation and images of the execution result output.
Chapter 10: Ajax
These days practically all web applications need Ajax. This is a valuable chapter you cannot afford to skip.
The first section is Ajax and JSF, including an important image displaying An Ajax request for validating an input field. You can see clearly how Ajax works. The next section is The JSF Life Cycle and Ajax, including two important images:
- The execute portion of the JSF life cycle
- The render portion of the life cycle
Then the sample code is introduced working with the f:ajax tag. This section includes a table named f:ajax Tag Attributesto to help you better understand the tag.
Two sample cases are provided. They cover Ajax Field Validation and Ajax Request Monitoring, each one with its respective source code and explanation and even including two tables about Data Object Attributes.
Another section is Ajax Responses including an image about Viewing an Ajax response using Firebug. It also has a table about JSF Ajax Response Elements including a snippet code for each element.
Other short sections covered are:
- Queueing Events
- Coalescing Events
To finish the chapter, Using Ajax in Composite Components is covered with a good amount of source code. The sample used is represented with an image named An autocomplete composite component.
Chapter 11: Custom Components, Converters, And Validators
This may be the longest chapter, and definitely includes important information for your aplication.
It starts with the section Implementing a Component Class where the following elements are explained: UIOutput, UIInput, UICommand and UIComponent. It includes a valuable image about JSF component hierarchy. In the sample code the spinner component is used, and images of its execution are provided. Hhere the authors are working with the namespace xmlns:corejsf, and therefore working with the element corejsf:spinner.
The follow section is Encoding: Generating Markup, explaining the encodeBegin, encodeChildren, encodeEnd methods as well as the following elements:
Here the author creates a class named UISpinner which extends the UIInput class.
The sections The Tag Library Descriptor and Processing Tag Attributes are covered with concrete theory and its respective source code with its explanation.
We have two sections with valuable source code and with their respective explanations. These are:
- The Sample Application (Working with a spinner)
I have similar appreciation for these sections:
- Partial State Saving
- Building Ajax Components
For many of these last sections the source code is working with a lot of classes from javax.faces... package and the namespace corejsf.
Chapter 12: External Services
An important chapter that begins with the section Database Access with JDBC, working with our old friend the DataSource interface and also covering:
- Connection Management
- Using Prepared Statements
For the sample application Apache Derby is used with GlassFish. Step-by-step instructions are available for Derby and some images about Configuring a Database Resource in GlassFish too.
A variation of the previous case is now working with JPA. Therefore the new source code is introduced and explained and an Entity class is used. The author includes Using Managed Beans and Stateless Session Beans and Stateful Session Beans (working with CDI). Respective source code is available with its respective explanation.
Another section is Container-Managed Authentication and Authorization where settings configuration on web.xml is included. The auth-method types are covered quickly with its respective images to show the differences between them. These are FORM and BASIC. Also, an image to configure GlassFish about realm is available. A valuable table named Realm Settings for the Database is included, too. It is tested with a Web Browser and Lynx. The source code is included and explained.
The next section is Sending Mail. Again, an image to configure GlassFish about Specifying mail session parameters in GlassFish is included. Another table named Mail Session Parameters is available too.
The last section is Using Web Services working with a WSDL file for the CDYNE weather service. JAX-WS is used for this sample too. The section is not long but again it includes the source code with its respective explanation and some images about the execution for this sample.
Chapter 13: How Do I . . . ?
This chapter is a really valuable how-to reference that address the following questions:
- How do I find more components?
- How do I support file uploads?
- How do I show an image map?
- How do I produce binary data in a JSF page?
- How do I show a large data set, one page at a time?
- How do I generate a pop-up window?
- How do I selectively show and hide parts of a page?
- How do I customize error pages?
- How do I write my own client-side validation tag?
- How do I configure my application?
- How do I extend the JSF expression language?
- How do I add a function to the JSF expression language?
- How do I monitor the traffic between the browser and the server?
- How do I debug a stuck page?
- How do I use testing tools when developing a JSF application?
- How do I use Scala with JSF?
- How do I use Groovy with JSF?
Each solution is acommpanied by valuable theory, source code and practical images to aid understanding.
What I liked:
- A huge amount of valuable source code!
- A lot of theory and explanation
- You can read the entire book comfortably
- Easy to understand 99% of the source code throughout the book
- For each sample code there's an image that represents the application's structure, so you know where each file should be located
- Many images showing the execution output of sample code
What I disliked:
Check out my blog for more reviews.
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)