Tuesday, January 15, 2008

Portlet Tutorial - Anatomy of a portlet

This post is a part of the Portlet 2.0 (JSR 286) Tutorial series

Now that we have written and successfully deployed our Hello World portlet, let's understand it's various components.Here is how our portlet would look when deployed in a container.

Notice how the portal has created a distinct boundary or window for our portlet. This is called a Portlet Window. Each portlet is visually contained in a portlet window. In addition to the portlet content (i.e the "Hello Portlet 2.0 World" message that we printed in the render method), the portlet window also contains the portlet title (we mentioned this in the portlet.xml) and some click-able controls called decorations. These decorations help control two different aspects of a portlet - modes and window states.

Portlet Modes and Portlet Window States

At any given point in time, all portlets can defined by in terms of two unique characteristics - what the portlet is currently doing and how much space the portlet is taking up on the page. The Portlet Mode defines what the portlet is currently doing. The Portlet Window State defines how much space a portlet takes up in a particular page.

For example, we could have written a help message for the Hello World Portlet and displayed it when a user clicks on the Help button (the decoration with a "?" symbol). In this case the portlet would be in the "Help" mode. Similarly we could have written different "Hello World" messages based on how much space the portlet occupies on the page. This is possible because in each case, the portlet would be associated with different window states.


Anonymous said...

Great stuff,
Looking forward to the rest of the tutorials

Nick said...

Thanks for posting these lessons.
The content is compact and clear.
I look forward to more!

Ngonidzashe said...
This comment has been removed by the author.
Ngonidzashe said...

You Hammered right to the marrow!!!. I shall thirst no more!!!

Jeff said...

This tutorial is a Great intro to the world of portlet development. Thanks!

Venkys said...

Hi Navneeth,
Your presentation skills are commendable, especially for persons who are just exploring this side of the portal world! Are there any more such useful blogs that can benefit beginners like me?

Even if it might irk a knowledgeable few, I would appreciate if you can maintain the same pace in introducing and elaborating the concepts of portlets.
Thanks in advance,

rajeev said...

Many hanks for the Good introductory tutorial for Portlets.

Jason said...

Awesome work!

TC said...

This tutorial was the best one. Its really very fantastic work of yours.

Uday Bhaskar said...


I am trying to identify purpose of when to use portlets and when not.

We are starting a project and our tech lead suggests JBoss Portlet... and is project doesn't have any disparate sources it's for a new company.

Is it good to go with portlets?


Anonymous said...

Excellent work. Thanks for your contribution.