RichFaces Portlet Experiences
ebephil Oct 10, 2007 5:02 AMHello everybody,
I recently started working on a JSR-168 portlet project and, as a fresh graduate, am still quite new to Java EE in general and JSF/Portlets in particular. I went through quite some trouble to get RichFaces to work in my portlets. And although not everything is working yet, I thought I would just write down my experiences so that other users might have a starting point. There is a lot of information about portlet support in the forum, jira and the wiki, but almost nothing of that seemed to be what I was looking for. Maybe other people can add their experiences or correct me when I'm wrong, maybe we can even turn this into a portlet tutorial or something like that.
Like probably everybody else too, I started by deploying the portal-echo demo portlet supplied in the repository using JBoss Portal 2.6.1 on top of JBoss 4.2.0.GA. That however, soon came to an end. At first, the MyFaces-libs were missing. After adding them (and telling JBoss about it via web.xml), the lib containing the org.ajax4jsf.portlet packaged was missing so I added this one as well. After I had done this, I had conflicts with all those common-libs (logging in particular), so I removed them from the war. That didn't help either as the digester now had a hickup when trying to initialize MyFaces. That's the point were I just gave up.
Lucky for me, I wasn't the only one having troubles. So I finally stumbled across a working demo-portlet provided by Michael Karas aka suckerd while helping some other user. http://jira.jboss.com/jira/secure/attachment/12316176/portlet-jsfrichfacesdemo.war
That was the first RichFaces portlet I could deploy. And as simple as it was, I was quite happy to finally see that blue gradient of the blueSky skin in a locally portlet. The libs required to run the portlet seem to be richfaces-api-x.x.x.jar, richfaces-impl-x.x.x.jar, richfaces-ui-x.x.x.jar (distributed e.g. in the binary downloads of richfaces), portlet-x.x.x.jar (nedds to be built first, can be found in the extensions/portlet dir in the project source code) and jsf-facelets-portal.jar. To get it to work on JBP 2.6.2, I also had to add the (latest) commons-beanutils-1.8.0-BETA, commons-collections-3.2 and commons-digester-1.8 libs.
I stripped down the config of that portlet (especially all the xml-files except for the ones really needed, that is faces-config.xml, portlet.xml and web.xml), and with the instructions given in section 3.3 of the RichFaces user guide, I managed to do my own little portal-echo portlet.
After all that success, I started to change my existing portlets from using Sun's JSF portlet bridge in conjunction with plain JSF/JSP to using the org.ajax4jsf.portlet.AjaxFacesPortlet in conjunction with Facelets/xhtml.
I encountered some quirks there too, though:
First off, the AjaxFacesPortlet does not seem to support EDIT and HELP mode out of the box. As far as I understand, I need to override the doHelp and doEdit methods to achieve that, but didn't have time to figure out where these init-params are processed.
Also, I had to place my pages directly in the root of the portlet. Storing them in WEB-INF/jsf didn't work, ended up in a 404 error whenever some ajax-magic happened.
Then, simpleTogglePanels don't seem to work properly when used in two or more portlets on the same page. Using switchType="client", only the last (that is, lowest) portlet works properly. Trying to toggle the simpleTogglePanels in the other portlets results in a "this.panels[panelId] has no properties" JavaScript error. Setting the switchType to ajax didn't help either as it fails with a ELException in some cases for some reason. Haven't been able to track this down properly yet as it seems to work in one portlet and doesn't seem to work in the other.
The mediaOutput component doesn't seem to work either. It always throws a FacesException (AJAX call to portlet without namespace parameter).
Another component I tried to use was the a4j:include which didn't seem to work either.
Oh, and it seems like one could only use one skin at a time. Different RichFaces skin-configurations in different portlets on the same page seem to be overridden by the last portlet's skin.
Did anybody get these components to work? Is there a list of components working in a portlet? The wiki says all richfaces components do work in portlets. How about the a4j-part?
I really like RichFaces and A4J and am willing to help making it more stable. Keep up the good work.
Regards
Phil