Integrating PrimeFaces and Apache Trinidad

PrimeFaces is famous of it’s compatibility with other libraries, for example I know there are many users having PrimeFaces and JBoss RichFaces in their projects with no major problems. Recently I’ve also integrated PrimeFaces with Apache Trinidad however it is a bit tricky. In RichFaces case I didn’t have to do anything but with Trinidad I’ve created a very tiny library called compat-trinidad.jar that enables PrimeFaces to work with Trinidad. So what were the major problems of Trinidad integration.

1) Trinidad tr:form does not extend from JSF’s standard UIForm but it uses it’s own UIXForm API, this is an issue when PrimeFaces tries to find the parent form using UIForm API. I’ve resolved this by also checking for tr:form’s component class name. A bit ugly but no other way.
2) Trinidad has something called RenderingContext that is initialized before rendering the view with it’s own viewhandler. However in PrimeFaces ajax requests, No RenderingContext error was thrown when trying to update a trinidad component with PrimeFaces. compat-trinidad.jar fixes this.

So here’s a sample JSF 1.2 page, it simply echoes what you enter to input text using trinidad and primefaces button. Important part here is Trinidad’s outputText is updated with ajax in both cases.

That’s it, now Trinidad users can enjoy the PrimeFaces goodness as well! Note that currently I’ve added Trinidad support only to PrimeFaces 1.0.1-SNAPSHOT, for PrimeFaces 2 and JSF 2, I’ll wait until Trinidad releases a stable release with JSF 2.0 support.

If you wonder how PrimeFaces manages to be compatible and lightweight, the answer is simple; it is designed targeting JSF 2.0 in the first place and it has no artifacts like custom ViewHandler, StateManager, UIViewRoot, Servlet Filters, Html Parsers, BlaBlaContexts as these stuff will break compatibility, cause race conditions and bring overhead.

I believe a JSF component library should focus on providing components only, not Rocket Science.