All Forums Viewpoint
bilal.farooq 28 posts Joined 08/10
19 Jul 2011
how to make Portlet's service implementation class non-singleton


Our Portlets Service Implementation class has to contain some "state" information, how can it be made a non-singleton...?
I tried singleton="false" in the bean declaration in applicationContext.xml but it does not seem to work.

If this is not possible, what would be the best place to keep state information in our portlet, the state information has to be specific per poertlet instance.

stever 149 posts Joined 08/09
19 Jul 2011

All controller classes in Spring MVC should be singletons. If you use a prototype bean, then the way that it is mapped to the URL changes. The Viewpoint PDK does not document this approach since we believe it is not an optimal solution.

Depending upon the nature of the state you need to store, you can either store the data in the user's HTTP session or in preferences. Typically we store short-lived state in the user's session. This might be something like whether the user is viewing the summary or detail view of a portlet, that we don't intend to persist after a user logs out of Viewpoint. ControllerContext.setSessionParameter(String, String) can be used to namespace the key name so that a separate value is stored for each portlet instance.

You can also use the preferences to save state that needs to be persisted across logins. Much of the state of Viewpoint portlets is stored in preferences, including details of your data grid configuration, the Teradata system you are viewing, and what metrics are displayed on a graph.

bilal.farooq 28 posts Joined 08/10
20 Jul 2011

Hi Steve,


You must sign in to leave a comment.