Powered by Syntax Highlighter scripts!

Upgrading JSR 168 portlets to JSR 286 specifications

Recently we had to upgrade our JSR 168 portlets to JSR 286 specifications for utilizing the powerful features of JSR 286 mainly AJAX.
Following steps below outilne the minimal set of changes to be done for upgrading the portlets to JSR 286.
1. portlet.xml XSD reference changes
The portlet.xml should refer to the new xsd definitions.
<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"
id="myportlet_app_id">
to be changed to
<portlet-app xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
version="2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
id="myportlet_app_id">
note the changes highlighted. So after these changes we will refer to the new specifications defined in _2_0 XSD files.

2. portlet.xml - add default namespace for portlet
Im JSR 286 portlets we need to give hte default name space for the portlet as in the line below.
<default-namespace>
http://com.mycomp.myproj.portlet.MyPortletName/
</default-namespace>

3. Tag library change in all JSP files
The portlet 1.0 tag library used in JSR 168 to be replaced with the portlet 2.0 tag library as defined in JSR 286 portlet.
Tag library in portlet 1.0 specification:
<%@taglib prefix="portlet" uri="http://java.sun.com/portlet"%>

Tag library in portlet 2.0 specification:
<%@taglib prefix="portlet" uri="http://java.sun.com/portlet_2_0"%>

Change all the JSPs in the portlet where tags are used.

This completes the minimal changes that are required for upgrading the JSR 168 portlets to JSR 286 portlets.

3 comments:

bhargavi said...

Iam using JSR168 specification in the portlets. Can i use JSR286 specifications in newly added JSP pages for the existing portlets where the previous JSP's contains JSR168 specification? Can i run both the specification in the same portlet side by side?

bhargavi said...

Iam using JSR168 specification in the portlets. Can i use JSR286 specifications in newly added JSP pages for the existing portlets where the previous JSP's contains JSR168 specification? Can i run both the specification in the same portlet side by side?

Naga said...

@Bhargavi - A portlet can be either follow JSR 168 specs or JSR 286 specs. The portlet specification to be followed will be given in the portlet.xml So we cannot have one JSP with JSR 168 and another with 286 in the same portlet.