Total Pageviews

Sunday, August 28, 2016

Liferay: Understanding portlet:defineObjects

There is so much confusion about the implicit objects provided by <portlet:defineObjects/> tag on JSP as developers cannot see them easily. Experienced developers know what is available and they can use them freely. Here is a cheat sheet for the same.

<portlet:defineObjects/> is an empty tag without any attribute, and must be included after the mentioned directive.


JSR -286 (Portlet 2.0) have objects available from the following 13 objects, depending upon the origin of render, which lies in 3 categories:

  1. Request Objects
    1. RenderRequest – if the origin of request is from render phase
    2. ActionRequest - if the origin of request is from action phase
    3. ResourceRequest - if the origin of request is from ajax (serveResource)
    4. EventRequest - if the origin of request is from event (processEvent)
  2. Response Objects
    1. RenderResponse - if the origin of request is from render phase
    2. ActionResponse - if the origin of request is from action phase
    3. ResourceResponse - if the origin of request is from ajax (serveResource)
    4. EventResponse - if the origin of request is from event (processEvent)
  3. Portlet Objects
    1. PortletConfig
    2. PortletSession
    3. Map<String, Object> - contains list of all portletSessionAttributes
    4. PortletPreferences
    5. Map<String, String[]> - contains list of all portletPreferences

That’s all for today. Thanks for reading and have a nice day.