Powered by Syntax Highlighter scripts!

Creating Sequence Diagrams Real Quick

Thanks for this productivity hack from one of my collegue:
This site http://www.websequencediagrams.com/ allows very easy and intuitive algorithmic way of drawing sequence diagrams. We can just concentrate on the sequence of actions and not on the layout.

For example type the following algorithm in the site and see the result for yourself


Browser->Home.jsp: user clicks on home link
Home.jsp->HomeController:call doHomeAction
HomeController->HomeBO:get Home objects
HomeBO->HomeDAO: get Home DAO Objects
note right of HomeDAO: gets the data from Database.
HomeDAO->HomeBO: Return Home Dataset
HomeBO->HomeController:Return Home objects
HomeController->Home.jsp:Render the home page
Home.jsp->Browser: display Home page


:)

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.


Specification

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.

response.setContentType("text/html");
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);

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

Accessing Portlet Preferences

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

PortletPreferences prefs = request.getPreferences();
prefs.setValue("userName",request.getParameter("username"));
prefs.store();

Namespace encoding

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

PortletResponse.encodeNamespace()

RenderResponse.getNamespace()

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
http://picasion.com/
http://www.gifninja.com/CreateAGif.aspx

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.

CONS:
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.

PROS:
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.

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.