how to make Portlet's service implementation class non-singleton

Viewpoint
Teradata Employee

how to make Portlet's service implementation class non-singleton

Hi,

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.
2 REPLIES
Teradata Employee

Re: how to make Portlet's service implementation class non-singleton

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.
Teradata Employee

Re: how to make Portlet's service implementation class non-singleton

Hi Steve,

Thanks.