SessionState in PortletSession

Home Search

Examples about portlet communication are available in tapestry-liferay-demo project (see Basket and Catalog portlets).

SessionState in PortletSession

Making page data persist across requests among every page of your application is accomplished with the @SessionState annotation. This annotation is applied to private instance fields of components:

The value of a session state object is stored in the session, and is global to all application pages for the same user. Any page or component that wants to use this object has to declare a field of the same type, with @SessionState annotation.

In portlet world, default scope for session state objects is PORTLET_SCOPE. It means that your object will be persisted, but only in the scope of the porlet. It won't be shared in the others portlets of your application.
For example, if your page displays two porlets, A and B, and if portlet A edits the value of a session state object, the porlet B won't be aware of these modifications.

If you want to share an object among all portlets in your application, you will have to set another persistence strategy for Session State objects in order to use the APPLICATION_SCOPE.
To define a new persistence strategy for a given object in your application, use the method contributeApplicationStateManager in your application module:

More in this section