2 Replies Latest reply on Jan 10, 2011 4:26 PM by Rich Raposa

    Are Portlet Preferences user-specific?

    Rich Raposa Novice

      I have read several articles on the web explaining how developers can use the PortletPreferences object to store user-specific settings for a portlet. I'm doing something simple - I want the background color of the portlet to be chosen by the user. I have the following code in processAction:

       

              PortletPreferences prefs = request.getPreferences();

              String newColor = request.getParameter("color");

              prefs.setValue("color", newColor);

              prefs.store();

       

      If I login to GateIn as user1 and choose blue for the color, then logout, log back in as user2, the portlet background is blue. Moreover, if user2 changes the color to red, then I log back in as user1, the background is red!

       

      This makes me think there is only one PortletPreferences object for each portlet, which would be fine except it seems to contradict the spec, which says preferences are not shared amongst users, and it also contradicts some of these articles I've read online about using portlet preferences as a way for each user to customize a portlet. However, if you read the Portlet API carefully, it does not mention anything about users - it only says that PortletPreferences is a handy place for storing portlet configuration data.

       

      Can anyone clarify if preferences are user-specific or not?

       

      Thanks!

      Rich