Friday, November 03, 2006

JSF Portlets with MyFaces Portlet Bridges, and

I've had reasonable luck building JSF JSR 168 portlets with the Apache Portlet Bridge in GridSphere. I've experimented with this in Jetspeed2, should work generally. I like to start with a standalone JSF application, get it to work, and then (with a little fussing around with config files) convert it to a portlet.

There is a Maven 2 MyFaces project archetype that is described nicely (by Evan and Martin--you know who you are) on our VLAB Wiki.

As a starting point, here are standalone Maven 2 pom.xml and web.xml files. These will be generated by the nice archetype.

After you have gotten your app working in standalone mode, you are now ready to convert it into a portlet. Some of these details will be specific to the container you are using, but in general you will need to

  1. Create a portlet.xml file, placed in WEB-INF

  2. Modify pom.xml to add the necessary portlet and bridges jars to your dependencies.

  3. Modify web.xml as required by your container. For Gridsphere we will need to do this by hand but other containers (Jetspeed2, uPortal are two) will do automatically convert your web.xml when you deploy.


Here are the details. First, add the following dependencies to your POM:

<!-- Portlet Dependencies -->
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>1.0</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.portals.bridges</groupId>
<artifactId>portals-bridges-commons</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>org.apache.portals.bridges</groupId>
<artifactId>portals-bridges-jsf</artifactId>
<version>1.0</version>
</dependency>

A full example of pom.xml for the portlet is here..

For GridSphere, we need to add the following xml snippet to the web.xml:

<servlet-mapping>
<servlet-name>PortletServlet</servlet-name>
<url-pattern>/jsr/RDAHMM-portlet</url-pattern>
</servlet-mapping>

A full example of the portlet's web.xml (for GridSphere) is here.

2 comments:

axelspin said...

Heve u tried converting a web app done with myfaces 1.1.5 in a portlet for pluto 1.0.2?

I still have some problems..

anyway FY I am working on a portal for seismic observaories and research group in EU.. I mention just beacus I`ve noticed the quakeSim reference? Are you working on geon?

mulderbaba said...

typo in artifactId, it should be portals-bridges-common

Cheers..