Powered by Syntax Highlighter scripts!

Quick checklist on differences between IBM Portlets and JSR Portlets - Part 1

This article gives a quick reference for most of the differences between the IBM Portlets and JSR 168/286 portlets in Java source code.
This can also be used as a quick checklist if we frequently work on JSR portlets and have to look into a IBM portlet for troubleshooting or viceversa.


IBM Portlets implementation

JSR Portlets equivalent

Import statements to be used

import org.apache.jetspeed.portlet.*;
import org.apache.jetspeed.service.*;

import javax.portlet.*;
import com.ibm.portal.portlet.service.*;

Portlet Class inheritance

public class SampleIBMPortlet extends PortletAdapter implements ActionListener{

public class SampleJSRPortlet extends GenericPortlet{

Arguments to lifecycle methods like doView, doEdit, doHelp

public void doView(PortletRequest request, PortletResponse response) {

public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException{

Action processing

public void actionPerformed(ActionEvent event) throws PortletException{

public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {

Content type of Response

In IBM portlets the MIME type is set by using the JSP page directive so setting the contentType to response is not necessary.

This is required to be set in JSR portlets before including the JSP.

Dispatching to JSPs

PortletContext context = getPortletConfig().getContext();
context.include("/jsp/View.jsp", request, response);

PortletContext context = getPortletConfig().getPortletContext();
context.getRequestDispatcher("/jsp/View.jsp").include( request, response);

Accessing Portlet Preferences

PortletData portData = request.getData();
portData.setAttribute("userName", userName);

PortletPreferences prefs = request.getPreferences();

Namespace encoding

This method can be used to return unique string to be prefixed for portlet specific javascript functions.



URL generation

// Save URI for the edit page
PortletURI editPageURI = response.createURI();
// Preserve the edit page URI in the request to make it accessible by the edit page JSP
request.setAttribute("editPageURI", editPageURI.toString());

// Save URI for the edit page
PortletURL editPageURL = response.createRenderURL();
// Preserve the edit page URI in the request to make it accessible by the edit JSP
request.setAttribute("editPageURL", editPageURL.toString());

Create animated GIF file from multiple images

Ever see those animated Gif files which can display multiple images one after another?I wanted to have one for myself to put it in one of my blog and surprised to see that there is one very old small tool of microsoft that can be handy.

It served my purpose as my requirement is just to show the images one after the another. Quality of images that I used below are poor mainly due to get it quickly nature and due to lack of time, aloha comrades we are all running short of time at the end of day :)

If you do not want to install the freeware/shareware in your desktop. You can refer the online GIF creator web applications like

Update: 24/May/2010 - All in all of the links above have limitations on the configuration parameters and mainly on the size of the animation files. The tool that resolved all of my issues and met requirements is http://www.photoscape.org

Portlet preferences getting shared across users JSR 286

I have a JSR 168 porltet which I've recently upgraded to JSR 286 portlet specification. This portlet has some preferences. Users can change the portlet preferences and save them. These preferences should be user specific. This functionality was working fine in JSR 168.
But after upgrading to the JSR 286, this functionality is broken. The preferences stored by one userare shared for all the users. We are deploying the portlets in IBM Websphere Portal 6.1.x.

Changes made during the upgrade of JSR 168 to JSR 286
1) upgraded the portlet to JSR 286 specifications
2) The Edit View is now changed to be rendered over the AJAX through the 'serveResource' method. In essense the edit view is rendered while the portlet is still in VIEW mode and the preferences.store is called when the portlet is in VIEW mode.

One of the reference link on the issue: http://www-01.ibm.com/support/docview.wss?rs=688&uid=swg1PK30573

Debugging currently in progress.

Classpath compile errors for JAXBObject

I am getting the exception below in RAD when I tried to compile a portlet project:

Description Resource Path Location Type
The type com.sun.xml.bind.JAXBObject cannot be resolved. It is indirectly referenced from required .class files UserAttributeBean.java FindProductPortlet/src/com/<comp_name>/<proj_name>/portlets/findproductportlet/bean line 1 Java Problem

Well this is a very basic exception and I've resolved it ample number of times, but at times, we tend to let loose the jar files names and search all the jar files for the file.

Fireworks effect using Javascript

I was in need of the Fireworks effect in my personal blog. So searched the web for the javascripts that can emulate the fireworks in the web site.

After doing a quick search for about 5 mins, I finalized on the fireworks effect in the url
A big thanks to Stephen the javascript guide.

It works really cool, and allows triggering the start and stop events which i customized for the "Start" and "Stop" links in my personal blog.

I've just mimicked the start/stop behaviour here, Enjoy the Fireworks by clicking on the "Start Fireworks" link above.

URL Shorteners - quick post

I was surprised to see some urls that my friend was using these days.
I was wondering how he is hosting his blog content from a diferent website altogether and still get a short url instead of a long one.

Any long url can be converted into a small url for example:

The tiny url is definetely a better option to share with friends when sending in mails or blogs.

The major con with this approach is that we are dependant on the unreliable middleman bit.ly or tinyurl.com for the redirection to your domain.
Mainly because of 2 reasons:
As a user you were not sure where you are getting redirecting by seeing these short URLs and you may sometimes end up not clicking on the url.
and second as the URL owner you will not be sure how long these tiny URLs are supported by these sites.

The main advantage that I see is that the url shorteners like bit.ly provide a way of tracking the hits to any arbitrary url shared to the audience. But with Google Analytics and other top of line tracking systems, you were already tracking the visitors of your blog/ site.