Persist in PortletSession

Home Search

Persist in PortletSession

Making page data persist across requests to a single page is accomplished with the @Persist annotation. This annotation is applied to private instance fields of components:

In portlet world, each portlet application has its own distinct PortletSession object per user session.

Objects stored in the session using the PORTLET_SCOPE must be available to the portlet during requests for the same portlet window that the objects where stored from. By default the @Persist annotation store object in PORTLET_SCOPE.

The PortletSession interface defines two scopes for storing objects, APPLICATION_SCOPE and PORTLET_SCOPE. Any object stored in the session using the APPLICATION_SCOPE is available to any other portlet that belongs to the same portlet application and that handles a request identified as being a part of the same session.

If your want to store your data in the APPLICATION_SCOPE you can use the new persistence strategie for that.

This make you data synchronized across any instance of the porlet used by any portal page for the current PortletSession. This is a powerful way to share data across portlet and portal pages but The portlet should take into account that objects that are stored in the application scope can be accessed by other portlets in parallel and thus should synchronize write access to these objects.

More in this section