Understanding standard portlet life cycle

A portlet is managed through a well defined life cycle that defines how it is loaded,
instantiated and initialized, how it handles requests from clients, and how it is taken out of service. This life cycle of a portlet is expressed through the init, processAction, render and destroy methods of the Portlet interface.

  • init: When portal server gets request for a page it will check if all the portelts on that page are initialized or not if not it will create new instance of portlet call its init() method.

  • processAction: Whenever user clicks on an action URL or submits a form to action URL the portal server will call processAction() method of the portlet. IN this method your suppose to change state of the portlet by setting render parameter, storing data in database,..etc

  • render: THis is the most common method of the portlet, whenever you go to page which has the portlet or click on the action URL of any other portlet on the page or click on the render URL within the same portlet, refresh page, the render method of the portlet will be called. The render method is responsible for generating markup of the portlet based on its current state.

  • destroy: When portal server decides to take portlet out of the request it will call its destroy method to give it a chance to release resources

Important Point: The Portal server will create only one instance of portlet per JVM and it will create different threads for every request and call appropriate methods of portlets from that thread.

In addition to this your portlet can decide to implement EventPortlet interface which says that portlet can be target of event (Target of inter portlet communication). The EventPortlet interface defines processEvent() method that you should override to implement the logic that should be executed when portlet receives event. THis is useful if you want to use inter portlet communication

If your portlet wants to support Ajax access then you can also implement ResourceServingPortlet interface, that defines serveResource() method. Once you define this method you can create a resource URL from your portlet using resourceURL tag and make request to the URL to get the fragment of portlet. This helps you avoid creating a Servlet in same application as that of the portelt just to support Ajax


srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

EG MEDI said...

Egmedi.com is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store