Wednesday, November 24, 2010

Inter Portlet Communictaion For Session Attributes

If we set any value in session it will be available until session available.

Include Following Line in liferay-portlet.xml:
<private-session-attributes>false</private-session-attributes>

Create session attribute in any file:
PortletSession ps = req.getPortletSession();
ps.setAttribute(key, value, PortletSession.APPLICATION_SCOPE);

Example:
ps.setAttribute("SAMPLE_ATTRIBUTE", "sample", PortletSession.APPLICATION_SCOPE);

Access in other Portlet File:
String name = ps.getAttribute("SAMPLE_ATTRIBUTE", PortletSession.APPLICATION_SCOPE);
Now name contains sample.

0 comments:

Post a Comment

Share & Enjoy

Twitter Delicious Facebook Digg Stumbleupon Favorites More