WPS : Sharing data across portlets

Sharing data across portlets usually leads us to the use of session objects. Most of the best practices recommend not overloading or overusing the session object, as it can be detrimental to the health of the application and the server.

So, what ways are provided by the WebSphere Portal Server to share the data across the portlets?

As per the JSR 168 spec, the PortletSession objects must be scoped at the portlet application context level. Each portlet application has its own distinct PortletSession object per user session. The portlet container must not share the PortletSession object or the attributes stored in it among different portlet applications or among different user sessions.

The setAttribute method of the PortletSession interface binds an object to the session into the specified scope.

*************************************************************
PortletSession session = request.getPortletSession();

session.setAttribute("app-scope-attribute", "value", PortletSession.APPLICATION_SCOPE);
session.setAttribute("portlet-scope-attribute", "value", PortletSession.PORTLET_SCOPE);
session.setAttribute("no-scope-attribute", "value");
*************************************************************



Filed in:
0 Comments To ' WPS : Sharing data across portlets '

Post a Comment