Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Portlets And Portlet Preferences

 
C Whitt
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm building portlets (JSR 186's for Liferay 5.1) and I've gotten the portlets the way I want them but I'm having a hard time getting my brain around something I think is simple...
Portlet Preferences... or more specifically when does setting them affect you only and when does it affect everyone that does not have a preference set. Here's my example I have a flash based weather portlet that I am storing the zip code for your location in a portlet preference. I'm putting this on a page that people can use and I will allow some to set their own zip code but what I want is when they don't have one set for theirselves that I can change it. How does this work? Because I think portlet preferences are personal so would I need to go to something like portletConfig instead for the globals(default) but check to see if they have something defined in portlet preferences defined first? Thanks in advance
 
Pankaj Misra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First thing first,

Portlet Preferences are not personal, they are configurations to run a portlet instance with certain behaviours.

So if you want to put a portlet on a page, that should exhibit different behaviours for different types of users, here are the options.

1. Have the user role accessed to show or hide certain controls on the portlet. this would be highly programatic rather configuration driven, but could server the purpose.

2. Create different sets of pages with instances of the same portlet but with difference portlet preferences. Have the portlet preferences drive the behaviour of the portlet.
Pros: Configurable portlet Instances
Con: Creation of duplicate pages and complex navigations

Unfortunately, Liferay 5.1 does not support multiple instance of same portlet on the same page.

Hope the above helps you.
[ December 29, 2008: Message edited by: Pankaj Misra ]
 
C Whitt
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Pankaj, So portlet preferenses are just that the preference for this one portlet. So if User A sets it and then User B sets it, User B wins due to they were the last to set it, not User A sees theirs and User B sees theirs?
 
Pankaj Misra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A User Preference is bound to a particular portlet instance, and is generally used by administrators for configuring them one-time on the portal page.


Well we can also allow the users to alter it, but any change in a portalet instance's preferences would impact all the users using that instance. So yes, what you said about User A and User B is correct.

Coming to you specific problem, the typical way to resolve it is to check is the zip code is set. If the zip code is not set, then fetch it from the portlet preference and carry on. This way the portlet preference is used as the default value.

[ December 29, 2008: Message edited by: Pankaj Misra ]

[ December 29, 2008: Message edited by: Pankaj Misra ]
[ December 29, 2008: Message edited by: Pankaj Misra ]
 
C Whitt
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So how/where would you store the personal preference?
 
Pankaj Misra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JSR-168 portlets do not support User Preferences, but this would be done as a feature implemented in the Edit Mode of the portlet.

So in the Edit Mode, we implement the required features that would allow the user to store his personalized settings in the backend, effectively acting as a User preference.
 
C Whitt
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Pankaj, thanks again for all your help... do you know if 286 does User Preferences?
 
Pankaj Misra
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont remember seeing it though, but need to check the specs for that.
 
Jack Farinas
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In liferay, preferences CAN be personnal.

For that, you have to set "preferences-owned-by-group" to false in the "liferay-portlet.xml" fil....



cheers
 
kamil nice
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was just reading PDF from Sun: JSR-168 portlet specification PDF. On the page 19 I've encountered description of Portlet Preferences object.


Pankaj Misra wrote:JSR-168 portlets do not support User Preferences, but this would be done as a feature implemented in the Edit Mode of the portlet.

So in the Edit Mode, we implement the required features that would allow the user to store his personalized settings in the backend, effectively acting as a User preference.
 
Neeraj Shidhaye
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well let me explain here

By implementing JSR168 custom portlet mode called "edit_shared", is the solution to your problem.

data set in Edit_Shared mode will be shared by all users for that portlet instance on that page. This will be treated as global preference fro that portlet instance.
data set in edit mode will be user specific and will get stored to user preference.

In your case, users who will have rights to edit mode will be able to change zip code to see weather of their desired city.
Users who are not having rights to edit mode, will see weather details as per set in edit_shared mode.

Edit_shared mode settings will be changed by adminstrator, and this will be set for all users for that portlet instance on that page.

hope that helps..

<Neeraj Sidhaye/>
http://ExtremePortal.blogspot.com
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic