I have recently tried using PrimeFaces with a RichFaces application. I am very impressed with PrimeFaces. It is a well designed, simple, yet powerful JSF framework with a lot of cool components. Unfortunately, it does have bugs that I found as soon as I tried to use it.
PrimeFaces is an open source JSF component suite with various extensions.
- Rich set of components (HtmlEditor, Dialog, AutoComplete, Charts and many more).
- Built-in Ajax based on standard JSF 2.0 Ajax APIs.
- Lightweight, one jar, zero-configuration and no required dependencies.
- Ajax Push support via websockets.
- Mobile UI kit to create mobile web applications for handheld devices.
- Skinning Framework with 35+ built-in themes and support for visual theme designer tool.
- Extensive, clear documentation.
- Large, vibrant and active user community.
Interaction with JSF stack
PrimeFaces uses the following classes to insert itself into the JSF framework. i.e – these are the classes which will be doing stuff to our requests, even if we are not using any PrimeFaces components!
- org.primefaces.context.PrimePartialResponseWriter (affects AJAX requests)
- org.primefaces.context.PrimePartialViewContext (affects AJAX requests)
- org.primefaces.application.PrimeResourceHandler (affects resource handling)
Head Resource Ordering Bug
PrimeFaces comes with some very cool features that allow you to control where your resources are going to be rendered in the <HEAD/>. You can use facets to place your resources into “first”, “middle” and “last” positions. This is a nice feature, since with RichFaces I had to place our style and script tags at the end of the <BODY/>, to make sure that they are rendered after the RF resources. This order is important, since it allows us to override RF styles and scripts.
However, there is a very obvious bug in org.primefaces.renderkit.HeadRenderer which makes this feature quite destructive to our app. Simply including the PrimeFaces jar causes all of our script and style overrides to stop working, b/c the app resources are placed before all others.
There are other issues with this feature as well: http://code.google.com/p/primefaces/issues/detail?id=4807
The problem is explained here: http://code.google.com/p/primefaces/issues/detail?id=4807#c1. Even though I know how to fix the problem, I do not wish to start maintaining our own PrimeFaces patches at this point of low adoption. So, the workaround is to disable Head Resource Ordering entirely for now:
<renderer> <component-family>javax.faces.Output</component-family> <renderer-type>javax.faces.Head</renderer-type> <renderer-class>com.sun.faces.renderkit.html_basic.HeadRenderer</renderer-class> </renderer>
This means that we now have to manually hardcode the theme include for PrimeFaces components:
<h:outputStylesheet library="primefaces-bluesky" name="theme.css" target="head" />