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

    Are Portlet Preferences user-specific?

    rraposa

      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

        • 1. Are Portlet Preferences user-specific?
          prabhat.jha

          PortletPreferences are user specific otherwise it's not really a preference. ;-) I think what you are seeing is probably related to session clean up when user logs out. This should be fixed in upcoming GateIn 3.2.GA.

           

          To verify this assertion, can you please use different browser when you login as user2?

          • 2. Are Portlet Preferences user-specific?
            rraposa

            Thanks, Prabhat! I thought I was going crazy there for a while.

             

            I had user2 pick blue, then logged in as user2 in a different browser and, voila!, the background was blue. So as expected, preferences are unique to each user.