Mathzprasad's Blog

September 3, 2009

7. Portlet LifeCycle

Every portlet class should extend javax.portlet.GenericPortlet. Every Portlet executes certain methods that constitutes the lifecycle of a portlet.

Every portlet, (similar to Servlets)
1. gets intialilzed through init() method.
2. serves the requests through renderRequest() and processAction() methods
3. reliquishes the resources and ends its life through the destroy() method.

Whenever an action event is triggered in the portlet, the processAction() method is called.
This processAction() performs any task that should be executed for that event and passes the control to renderRequest() method. Only one portlet action is triggered each time.

The renderRequest() method is responsible for producing the markup that is based on the state and mode of the portlet.
The portlet sets the MIME type on the response and generates the markup either by directly writing to the output stream or by including a servlet or JSP that generates the markup.

Let us consider a portal that has three portlets, A,B and C. An action event can be triggered in any one of the three portlets. Let us say ‘A’ triggers an event.
The whole portal page is rendered.

Here is what happens.

1.processAction() of portlet A is invoked and executed.
2.Once processAction() of portlet A is completed, render process starts.The renderRequest() methods of each portlet is called.
3.The final portal page is rendered to the user.

lifecycle

Next: Simple portlet folder structure in RAD

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Rubric. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.