How to Start the JSF Dance
Last week our project structure changed a bit and I had to think about training new members in the JSF field. I remembered that there's still a draft article, I started in 2006, in my blog management. Rick from DZone told me that there's still a need for giving some tips in JSF programming. So, I polished my article ;-).
Hint: If you still think about changing from your current Web presentation framework to something new, keep in mind that Flex/AIR are on the horizon. If it is possible to break with the markup presentation tradition in your project I suggest to have a look at Flex, first.
I'm doing JSF for about 20 month now. I had a look at Apache MyFaces, Trinidad, Tomahawk, Facelets, Woodstock, JSFTemplating and ICEfaces. Short after ICEfaces became Open Source I implement with it.
JSF may be a pretty cool standard in comparison to existing Web technologies, like Struts, JSP, Servlets or native CGI. I don't think it is pretty cool from a classic GUI developers point of view, but it's a first step in the right direction. But, there's still a problem: besides mature implementations we still need better documentation, sample code and tutorials for the implementation process and the use of JSF components.
I think we still miss smart components and tools that allow to "point-and-click" data into the presentation layer. Imagine you could select a non-visual database table component, a JSF table component, set some attributes to inject the data and deploy this to your application server. Not noteworthy to a VB or Delphi developer even 10 years ago. For Java developers still a challenge.
But, for now lets have a look at what can help to get working code in an acceptable time frame. We have to have a look at general aspects of JSF and the implementation-specific aspects. This is especially important for all the components that are not part of the JSF standard specification.
Although, you may find common aspects you can't expect that you can create a backing bean of a non-standardized component the same way in different frameworks. Trinidad, e.g., needs another data structure to fill a tree than Tomahawk does. Although, it is possible to use the same backing bean if you add a method that converts the structure for Tomahawk to Trinidad then.
JSF in General
I don't know if it is really necessary to study the JSF specs. Most of the spec documents are written in a boring style and are not easy to understand. So, you may have a look at a pretty good presentation from Sun for a first overview.
JSF Tutorials is a comprehensive collection of links that covers introduction up to writing your own components. A similar collection of links is Java Server Faces Resources. Rick Hightower wrote a JSF 1.2 based tutorial (part 2; needs a DeveloperWorks account).
Although, the title is a bit misleading Lean JSF delivers a quick reference for important JSF implementations. The presentation of Marty Hall gives an overview and some experiences with the different Apache Frameworks (MyFaces, Tomahawk, Tobago, Trinidad is main focus).
Here's a tutorial that shows some details of Tomahawk: Build Apache Geronimo applications with Java Server Faces (Needs a DeveloperWorks account)
JSF Tools and Environments
Although, JSF is like working with extended Struts plus Java hacking, it's a good idea to use an IDE and not only a text editor. You may miss really cool GUI designers at the moment, but all IDEs help to get the XML files under control. For a better overview of environments, frameworks and IDE support InfoQ has different articles. The JSF Central Community can help here, too.
Rick Hightower is doing a lot of stuff in the JSF, Spring, Hibernate, JSF, Facelets and Eclipse domain. He's started the SHJFT tutorial that can give you extra information to stuff you may read about in my blog.
Open IDEs to have a deeper look at:
- Eclipse JSF Tools Project (The PDF shows how far this is gone. Pretty nice ;-).)
- JBoss Developer Studio (based on Exadel's Eclipse work and was free for some time; but pretty good for Facelets and RichFaces; you can add other Taglibs for tag support, works e.g. with ICEfaces)
- Netbeans (extension based on the Java Studio Creator work and pretty good for Woodstock, but you may be dependent from Sun's DataProviders)
- JDeveloper (For ADF Faces and Trinidad, even Visual Designing)
JSF Code to Start
Although, the usefulness of code-starters depends on the frameworks you will use in your projects they may help to get a better understanding of the glue you need.
The all-in-one device suitable for every purpose is Matt Raible's AppFuse. It started as a helper to learn Java. But, it is already a showcase for the most important Java frameworks and the glue between them. For our Trinidad friends Faces Goodies maybe helps for better understanding.
The list is not complete, have a look at Amazon comments in any case, but here are some that got my attention:
- JavaServer Faces: The Complete Reference (Home)
- Pro JSF and Ajax: Building Rich Internet Components
- The Definitive Guide to Apache MyFaces and Facelets
Blogs become more and more important. Especially, if documentation is missing and you search for experiences. A lot of developers share their experiences this way. And you can also use the blogs for bi-directional communication, instead to wait for an answer in a forum. Here's a list of guys, writing about JSF in general and also about specific frameworks, you should have a look at:
- Rick Hightower: Sleepless Night in Tuscon Blog
- Matthias Wessendorf
- Martin Grotzke: Javakaffee
- Andrew Robinson: Working with JSF and Facelets
- The Peninsula's Edge
- The GroundBlog By Duncan Mills
- Chris Schalk's J2EE and AJAX Weblog
- Cagatay Civici's Weblog
- The Aquarium: News from the GlassFish Community
Although, JSF becomes the de-facto-standard for markup-based client presentation, don't think that you get a better approach than you have today with Struts plus AJAX extensions. The better strategy may be to wait until Flex is mainstream in development and than thinking about porting to a real GUI presentation. Some thoughts and experiences from the community:
Architecture and Framework Stacks
There are architecture stack changes today that are also influenced by the client presentation (e.g. if you change from JSF-based backing beans to Spring-based ones). Some weeks ago I found a presentation that describes a similar architecture we use successfully today in our project:
We've also Crank in our architecture. Meanwhile Rick Hightower has a presentation about Crank. Although, Architecture details is a bit small in the presentation (have a look at slide 11).
The missing ICEfaces support, resp. porting costs, let us skip the JSF support, because Crank uses another AJAX framework. But, we like the generic DAO/JPA stuff. It let us design a pretty clean layer. And ICEfaces support will come, so that we get a more scalable table presentation then ;-).
(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)