Hazem Ahmed Saleh Blog

« How to change Modes... | Main | Google release free... »

20060501 Monday May 01, 2006

Eleven Steps To Convert Your JSF Application To IBM Websphere Portal
Existing JSF applications can be migrated in order to run in WebSphere Portal

Existing JSF applications can be migrated in order to run in WebSphere Portal.

Since JSF is a framework there are many variations to how the application can

be built with JSF. These steps (which are extracted from IBM JSF RedBook) can be used as a starting point for the migration effort, but may not cover all of the issues that can be encountered.

 

1. Check if there are any file upload component in the application, or if the

application uses components that support the download of binary data. These

features are not supported in JSF portlets and cannot be migrated.  

---------------

2. Decide to which Portlet API you want to migrate your JSF application. The

migration can be done either to the JSR 168 API or to the IBM Portlet API.  

---------------

3. Create a portlet.xml according to the API you decided to migrate to (the JSR 168 API or to the IBM Portlet API).  

---------------

4. Specify the FacesPortlet class. This class will perform the tasks that the

FacesServlet does in a conventional JSF application.

 

– In JSR 168 API, the FacesPortlet is declared in portlet.xml and points to

the class com.ibm.faces.webapp.FacesGenericPortlet. The existing

FacesServlet in web.xml should be deleted.

 

– In IBM Portlet API, FacesPortlet is declared in web.xml and points to the

class com.ibm.faces.webapp.WPFacesGenericPortlet. The existing

FacesServlet in web.xml should be replaced by the FacesPortlet.  

---------------

5. Specify the initial page to be loaded in each portlet mode.

- In JSR 168 API.

<init-param>

       <name> com.ibm.faces.portlet.page.view </name>

       <value>/index.jsp</value>

</init-param>

<init-param>

      <name>com.ibm.faces.portlet.page.edit</name>

      <value>/html/edit/index.jsp</value>

</init-param>

- In IBM Portlet API.

<config-param>

       <param-name>com.ibm.faces.portlet.page.view</param-name>

       <param-value>/index.jsp</param-value>

</config-param>

<config-param>

       <param-name>com.ibm.faces.portlet.page.edit</param-name>

       <param-value>/html/edit/index.jsp</param-value>

</config-param>

---------------

6. Import the correct jar file that contains the JSF Portlet Runtime into the

WEB-INF/lib directory:

– In JSR 168 API, this is the jsf-portlet.jar.

– In IBM Portlet API, this is the jsf-wp.jar.  

---------------

7. Include a faces-context-factory in faces-config.xml:

– In JSR 168 API, include this factory tag:

<factory>

      <faces-context-factory>

        com.ibm.faces.context.PortletFacesContextFactoryImpl

      </faces-context-factory>

</factory>

– In IBM Portlet API, include this factory tag:

<factory>

      <faces-context-factory>

        com.ibm.faces.context.WPPortletFacesContextFactoryImpl

      </faces-context-factory>

</factory>

---------------

8. However, in faces-config.xml, you need to specify variable and property

resolvers to correctly use value binds:

– In JSR 168 API, include this application tag. If you already have an

application tag in your file, include only the inner tags shown below:

<application>

      <variable-resolver>

        com.ibm.faces.databind.SelectItemsVarResolver

      </variable-resolver>

      <variable-resolver>

        com.ibm.faces.application.PortletVariableResolver

      </variable-resolver>

      <property-resolver>

        com.ibm.faces.databind.SelectItemsPropResolver

      </property-resolver>

</application>

– In IBM Portlet API, include this application tag. If you already have an

application tag in your file, include only the inner tags shown below:

<application>

      <variable-resolver>

        com.ibm.faces.databind.SelectItemsVarResolver

      </variable-resolver>

      <variable-resolver>

        com.ibm.faces.application.WPPortletVariableResolver

      </variable-resolver>

      <property-resolver>

        com.ibm.faces.databind.SelectItemsPropResolver

      </property-resolver>

</application>  

---------------

9. Be careful with pages that use JavaScript code. You will have to namespace

all JavaScript calls and references to JSF components.   

---------------

10.If your existing JSF application already supports multiple locales, remember

to update portlet.xml to include the supported languages.   

---------------

11.The JSPs should be modified so they do not use HTML head and body

elements. All HTML output to the portal is written in the context of an HTML

table cell.11.The JSPs should be modified so they do not use HTML head and body

elements. All HTML output to the portal is written in the context of an HTML

table cell.   

---------------

This is about all. I hope that this post could help you to convert your JSF applications to portal ones.

Posted by Hazem ( May 01 2006, 08:57:29 AM EDT ) Permalink Comments [2]

Comments:

I was searching for a solution like that before but I found poor results. Thanks for your post. It is great.

Posted by Java Developer on May 01, 2006 at 04:51 PM EDT #

What if you want to use a JSF implementation other than the IBM one?

Posted by Marc on July 12, 2007 at 12:40 PM EDT #

Post a Comment:

Name:
E-Mail:
URL:

Your Comment:

HTML Syntax: NOT allowed

Valid HTML! Valid CSS!

This is a personal weblog, I do not speak for my employer.