Various methods for sharing values across portlets


Sharing values across portlets is one of the most common requirements while implementing portlet based applications. The below high level points will give you a high level idea of how to achieve the same.

1. Through Caching : Placing the variable in Dyna cache in Source portlet as a key value pair and obtaining it in the target portlet.

2. Placing the values in Application scope : This is a costlier operation so it has to be avoided. i.e. placing the variables in HttpSession scope so that 2 different applications can share it.

3. Using PortletSession: Any portlets that are located in a same WAR file can share data using PortletSession. The setAttribute and getAttribute methods needs to be called with scope argument set to PortletSession.APPLICATION_SCOPE in order to share data.

4. Public Render Parameters: The render parameters set from either in processAction method or in render URL are only accessible from the same portlet. JSR 286 introduces public render parameters to share navigational state across portlets even located in different WAR files. Using this parameters to share data avoids event phase as needed using event technique. The render parameters can be shared by just defining XML elements in portlet.xml.

5. Using Events: In addition to public render parameters, JSR 286 introduces events to share data. Unlike public render parameters, events allows to send payload as an object. In order to share data using events, an action phase should occur by user's action of either clicking on a link that is created with action URL or submitting a form whose action is created as action URL.


ejb developer said...

Could you please explore sharing values accross portlets using caching.?

Nice Post.
thanks & regards

ejb developer said...

Nice Post.
aarif m

Post a Comment

Recent Posts

Popular Posts

© 2011-2019 Web Portal Club