Updates

Latest Tweet



What's New?

Check out for latest innovation, a computer based training video collection


Like this Page

JavaServer Faces in Action Review by Damodar Chetty

Rewarding book - if you work with it

Let me start by pointing out that his target audience includes people who currently develop Java web applications. So its fair then to say that if you are new to JSP and servlets, this isn't quite the book for you. So forget about getting any hand holding with setting up a servlet container or a gentle introduction to JSP actions.

That said, if you know the top end of a web application from its bottom one, and you want to get up to speed on JSF, you're in for a good ride.

1. Architecture (5 out of 5)
--------------------------------
This book shines in the area of general architecture. And, I can't say enough good things about Kito's diagrams.

The first diagram of note provides a birds eye view of a JSF application. If you take the time to read through each textual element in the diagram, you'll get a very comprehensive view of your application's place in the world, when implemented using JSF.

His basic introduction to HTTP and Servlets is just that - basic. But his discussion on what frameworks bring to the table is a must read for web developers. That section culminates in another worthwhile diagram - this time a depiction of web application infrastructure as a stack of services. You can clearly see the benefit you accrue from using JSF, vs. say coding using the servlet API. It overlays Struts on there as well, so you get a nice comparison of the two frameworks.

His first application requires a leap of faith. There's a lot of code here just for a simple Hello World application, and its hard to follow along without a reasonable knowledge of what a standard JSP might look like, so you can spot the differences introduced by JSF. It doesn't help that this basic application starts out of the gate with a roar - you're dynamically adding controls to a component using an action listener! Not good.

His class model of the various JSF components is another must see. Its a very informative overview with the UI Component as the center of attention, surrounded by its minions.

The second chapter is another gem - it provides a detailed description of the various classes that comprise JSF. There's a lot to take in, so you'll find yourself returning here after you've read the rest of the book, to help everything fall in place in your mind.

One thing I had difficulty with was that the topics seemed to jump from low level to high level and back again, leaving me a bit winded. The net result is that I couldn't read this very linearly, and had to backtrack ever so often to find my bearings.

For e.g., the first time you get to building a JSF web application is over 100 pages into the book. Fortunately the structure of a WAR is well known, especially to the target audience of this book, so there's no surprises here, other than to note the specific JARs that are required by your JSF implementation.

In the spirit of the topic organization of this book, one of the most engaging chapters on high level architecture is placed right at the end (chapter 11). There again you find a diagram that maps all of JSF's application classes, grouped as component classes, context classes, application classes, and event handling classes. This chapter is a must read as it provides in depth coverage of the APIs that underpin the JSF classes.

The UI Component's singular importance in JSF is honored by an entire chapter. A table classifies components by family (input, output, etc.), JSF implementation class (UIInput, UIOutput), and HTML subclass (HtmlInputText, HtmlOutputLabel).

The components are treated well with the standard components described in sufficient detail. In a rare fashion, he provides examples of how a component tag is rendered as HTML, and presented in a browser. This gives you a clear picture of the additional scripting that is added for a component.

This includes single- and multi- select controls, and their data models set via UISelectItem instances and UISelectItems.

2. Request Processing (5 out of 5)
--------------------------------------
The life cycle stages are defined clearly and precisely. Its hard to think of any information that might have been missed.

A key concept is that of component and client identifiers - which defines how naming containers influence the name of a child component in the rendered HTML code. This is very clearly portrayed, by yet another diagram that maps the component tree on the server to form components on the client.

All in all, a very satisfying tour of the life cycle.

The coverage of converters and validators is just as complete - including creating custom converters and customizing error messages using message bundles.

3. Templating (4 out of 5)
------------------------------
JSF implementations must support JSP as a templating technology. It's a rare book that doesn't cover the use of JSP actions, custom actions, and JSTL within a JSP page adequately - and this one doesn't disappoint. A key issue with JSP/JSF is that there are certain constraints with using JSF/JSTL tags (such as the tag) - and these are called out adequately. While the coverage is decent, this is not a book on JSP, and it shows.

4. Navigation and Event Handling (3 out of 5)
-------------------------------------------------
This information is spread out across multiple chapters - not something that I prefer. While no details are lost its still a bit of work to piece together the whole story. For example, the default ActionListener is covered a number of chapters away from the topic on declaring an action listener.

5. Miscellaneous (5 out of 5)
--------------------------------
Interestingly, this is one of the rare books that addresses a rarely considered concept - which JSF implementation should you choose. The RI is a reasonable choice, but the larger question is when an alternative implementation such as MyFaces would be preferable.

The Managed Bean Creation Facility is an interesting implementation of inversion of control - much like Spring - where a configuration file drives the creation and initialization of beans. He actually provides guidelines as to which objects should be constructed using this facility, and which ones would be better served by initialization at web application startup - say using a ServletContextListener, so as not to incur inordinate delays in the middle of a user's interaction. And there's even an example later on in the book, if you didn't get the hint.

Internationalization coverage is pretty complete - in terms of configuration in faces-config.xml (and a warning that without these locale-config elements, the JSF implementation may only support the default locale of the application's JVM); determining the user's locale (using the tag, Java code, or the browser's locale settings); and creating resource bundles to house your locale specific properties.

This book is peppered with relevant tips such as the warning here that you can't use the "." character in resource bundle keys.

On the client side it describes the use of , especially the use of the basename attribute and how it is set based on where in the classpath the resource bundle is located. For bundles located in WEB-INF/classes no prefix is necessary - since that's the root of the classpath. However, bundles any deeper than that require to be prefixed appropriately.

Another rare topic for a JSF book is the creation of a global error page and registering it in web.xml and as a global navigation rule.

Finally, there's an example of the use of a servlet filter for security.

6. Examples (3 out of 5)
----------------------------
While I typically don't favor overblown monolithic projects that require you to follow along across multiple chapters, the provided example has all the bells and whistles of a typical application you might encounter - including user roles, workflows, and a common toolbar component.

In addition, Kito provides a really interesting approach to application development - by starting out with a dummy user interface using hard coded beans and static navigation outcomes, and slowly evolving the application.

The result is a bit mixed - the first couple of chapters flow wonderfully. However the latter chapters of the examples felt a bit hurried in their execution, especially once we're into the more difficult aspects of JSF development, such as backing bean design.

7. Conclusion (overall score: 4.5 out of 5)
-----------------------------------------------
You'll be hard pressed to find a book that has such excellent coverage of so many diverse topics - many that are not JSF specific.

You'll also find gems of practical advice throughout the book - for e.g., that you have 3 alternatives as to where to place your action methods (in your backing beans, within independent action classes, or within service classes) along with the tradeoffs associated with each.

A couple of reservations (albeit subjective):

I'm not a big fan on how the topics are organized. As I read this book, I had to keep jumping back and forth - many many times, and that got to be very tiresome.

I typically like related information to be as physically close as possible, preferably within the same chapter. It is hard to use this as a reference book given the geographical distance between related concepts. This may actually fare better as a search-able e-book.

The example application is very comprehensive and well thought through. However, the example is built over multiple chapters, and the latter chapters are not as coherent as the initial ones. I found the change of pace a bit unsettling.

On the whole, though, its been a satisfying read.

Damodar Chetty (swengsol.com)