Laliwala IT Services

Laliwala IT Services
Website Development

Monday, February 21, 2011

PortletPreferences to store some user specific attributes

Jay Johnson : Hello All,

I'm using the PortletPreferences to store some user specific attributes. Once a user is authenticated, the following block of code gets executed:

1
2public void serveResource(final ResourceRequest request,
3 final ResourceResponse response) throws PortletException,IOException {
4
5 // Some logic to get the uservalue..
6
7 try {
8 PortletPreferences pp = request.getPreferences();
9 pp.setValue("userattribute", uservalue);
10 pp.store();
11 } catch (Exception e) {
12 // handle exception...
13 }
14
15 ...
16}


The preference is getting saved but unfortunately the same value is always returned for "userattribute", even though a different user is authenticated. Looking at the portletpreferences table, I do see the row containing the preference but the ownerid is always set to "0".

I am using Liferay 5.2.3.

Any help would be appreciated.

Thanks,
J}


No comments:

Post a Comment