Rutvij's Odyssey

Life of a Developer and Technologies he plays with

Posts Tagged ‘Websphere Portal

User specific Preferences in Liferay

with 6 comments

As per JSR 168 Specificaiton Portlet Preferences are user specific and may be shared across portlets/pages ( NOT Mandatory: config/edit_shared modes)  which depends on portlet container.

If you have Websphere Portlet development experience you will wonder why preferences are not ‘user specific’  in liferay.

In this post I will explain how to solve this mystery and make your user specific preferences work in Liferay too.

Preferences in this example :
Portlet shows two  preference values  in VIEW mode JSP:  A. Sets dynamically by API B. From portlet.xml.
Edit Mode shows and allow to update preferences.
processAction stores updated  preferences.

Really simple use  isn’t it ?

Expected Behavior:
When user Bob logs in to portal and set his preferences, he can see them in VIEW mode. So preferences are personalized only for Bob. When Alice/another user logs in to Portal she can set her preferences which is only for her, no other user can see.

In Websphere portal: As per Expected.

In Liferay portal: When Bob logs in and set his preferences and it will be set for Alice and David too .i.e when Alice logs in to portal she can see preferences values set by Bob. If she too updates, it overwrites value set by Bob.

I was wondering  why its happening like this…because as  per JSR if user sets Preferences in EDIT/VIEW/HELP  mode it is user specific only.

Solution : Liferay supports  great level of customization for preferences (I will explain it  in details in my future posts).

But by default  Liferay sets  some customized levels for preferences  ‘ON’.

So in order to make  preferences  user specific in liferay, add following entries to liferay-portlet.xml :

<portlet>
....
<preferences-unique-per-layout>false</preferences-unique-per-layout>
<preferences-owned-by-group>false</preferences-owned-by-group>
....
</portlet>

Do these changes and redeploy portlet, now Bob’s preferences are for Bob only !!!

Written by rutvijshah

December 6, 2009 at 3:34 pm