PrimeFaces works great with JSF 2.0/NetBeans 6.9

In 2002, JSF was introduced at Java One as “Swing for the Web”. The vision was that you would compose professionally designed components into web pages, add a bit of Java glue code, and presto, you would have a web app without having to worry about HTTP or the DOM.

I perked up because I didn't want to worry about HTTP or the DOM. This was before Ajax was invented, and before I knew that I certainly didn't want to know about the XMLHttpRequest object or JSON.

Ever since, I have been fussing with JSF, not always happily. A couple of years, I wrote this blog about a JSF 1.2 project. I liked the Woodstock component set. But I groused about having to redeploy all the time, the stack trace from hell, and the lack of templating.

What a difference two years make. With GlassFish 3 and JSF 2, templating is easy, hot deployment works pretty well, and Facelets error reporting means that the stack trace from hell is much less common. (Now if the rest of Java EE could do as well and give me the source file/line number for each error...I am looking at you, Weld...)

However, as I ported an app to JSF 2, I had to give up on Woodstock. It has been abandoned and does not seem to work with JSF 2. First, my graduate student Ashlesha Patil provided a UI that used just the basic HTML components. It worked fine but looked rather plain.

So, I looked for another component set that was ready for JSF 2 and took advantage of its latest features. The one that seems furthest along is PrimeFaces (version 2.2M1). It is dead simple to use. No more wretched web.xml or faces-config.xml customizations. Simply add the JAR to WEB-INF/lib and add


to each XHTML page. Then you can use goodies such as p:tabView and p:accordion. After an hour of fussing, the screen looks like this:

That's more like it. Clicking on the tabs and accordion buttons gives subtle animation effects, without any work on my part. There are plenty of themes to choose from if blue and gray aren't your thing. And of course, there are lots of components.

NetBeans 6.9 does code completion on the tags and presents the documentation:

NetBeans 6.10 will include PrimeFaces out of the box, so you won't even have to download the JAR.

After all these years, JSF is finally getting pretty close to its original promise. I really like that I can think in terms of components—such as the tab view or accordion component—without having to worry about HTML or JavaScript. And I can let someone else author these components.

The next step on my wish list is a JSF app framework—something that gives me the basic structure that is common to many apps. In particular, I never want to write the code for login and password recovery again.