Skip to main content

Converting JSF-based Applications to JSF Aware Portlets


1. Download jsf-portlet.jar and copy it to the WEB-INF/lib directory of the JSF application.

2. Add a new deployment descriptor for the portlet by creating a portlet.xml file.  In the portlet.xml file
    (a) set portlet-class to com.sun.faces.portlet.FacesPortlet.
    (b) set the portlet parameter com.sun.faces.portlet.INIT_VIEW  to point to the first page of the JSF application.
    The sample portlet.xml is shown below. The portlet.xml file must placed in the WEB-INF directory of the application.

<?xml version="1.0" encoding="UTF-8"?>
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd"
version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd
http://java.sun.com/xml/ns/portlet/portlet-app_1_0.xsd">
 <portlet>
<description>JSF Sample Portlet</description>
<portlet-name>jsfsampleportlet</portlet-name>
<display-name>JSF Sample Portlet</display-name>
<!-- You must use this Portlet implementation class -->
<portlet-class>com.sun.faces.portlet.FacesPortlet</portlet-class>

<!-- This is a required parameter and must point to the first page of the JSF Application -->
<init-param>
<description>Portlet init view page</description>
<name>com.sun.faces.portlet.INIT_VIEW</name>
<value>/view.jsp</value>
</init-param>
 <supports>
<mime-type>text/html</mime-type>
<portlet-mode>VIEW</portlet-mode>
<portlet-mode>EDIT</portlet-mode>
<portlet-mode>HELP</portlet-mode>
</supports>
 <portlet-info>
<title>JSF Sample Portlet</title>
<short-title>jsfsampleportlet</short-title>
</portlet-info>
 </portlet>
</portlet-app>

3. To provide EDIT functionality for the JSF portlet, set the portlet parameter com.sun.faces.portlet.INIT_EDIT  to point
to the edit page of your portlet in the portlet.xml file. Snipped is shown below..
 <init-param>
<description>Portlet init edit page</description>
<name>com.sun.faces.portlet.INIT_EDIT</name>
<value>/edit.jsp</value>
</init-param>

4. To provide HELP functionality for the JSF portlet, set the portlet parameter com.sun.faces.portlet.INIT_HELP  to point to the help page of your portlet in the portlet.xml file. Snipped is shown below..
  <init-param>
<description>Portlet init help page</description>
<name>com.sun.faces.portlet.INIT_HELP</name>
<value>/help.jsp</value>
</init-param>

5. Modify the JSP pages as follows:
    1. Remove the <html>, <head>, and <body> tags.
    2. Modify use of forward and redirect as the new page will replace the existing portal pages.
    3. Minimize the use of Javascripts as portlets do not support client side scripts like JavaScript very well.
    4. Using the JSF Portlet Taglibrary is recommended.

6. Deploy the WAR file.


HOME

 
 
Close
loading
Please Confirm
Close