Wednesday 21 September 2011

Portlet Life Cycle

The Life Cycle Methods Called by the container are:

1) init(PortletConfig config)
2) processAction(ActionRequest request,ActionResponse response)
3) render(RenderRequest request,RenderResponse response)
4) destroy()

Init(PortletConfig config):
Called when the portlet is instantiated by the container. This method is called only once, immediately after the portlet instance is created.

PortletConfig represents the read-only configuration data , specified in protlet’s configuration file (portlet.xml).
This init method behaves similar to the servlet’s init method.

processAction(ActionRequest request,ActionResponse):
Called after user submitted changes to the portlet. Intended to process input from a user action.
ProcessAction method is called in response to a user action such as clicking a hyperlink or submitting a form.
ProcessAction notifies the portlet about the user’s request for an action.

render(RenderRequest request ,RenderResponse response):
render notifies the portlet to generate the markup fragment.
Render follows the ProcessAction in the chain of lifecycle methods.

destroy:
destroy will be called just before the portlet is garbage collected and provides last chance to freeup portlet resources.

No comments:

Post a Comment