File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Portals and Portlets and the fly likes Portlets And Portlet Preferences Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Portals and Portlets
Bookmark "Portlets And Portlet Preferences" Watch "Portlets And Portlet Preferences" New topic
Author

Portlets And Portlet Preferences

C Whitt
Greenhorn

Joined: Dec 29, 2008
Posts: 6
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

Joined: Dec 28, 2008
Posts: 11
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

Joined: Dec 29, 2008
Posts: 6
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

Joined: Dec 28, 2008
Posts: 11
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

Joined: Dec 29, 2008
Posts: 6
So how/where would you store the personal preference?
Pankaj Misra
Greenhorn

Joined: Dec 28, 2008
Posts: 11
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

Joined: Dec 29, 2008
Posts: 6
Pankaj, thanks again for all your help... do you know if 286 does User Preferences?
Pankaj Misra
Greenhorn

Joined: Dec 28, 2008
Posts: 11
I dont remember seeing it though, but need to check the specs for that.
Jack Farinas
Greenhorn

Joined: Mar 04, 2009
Posts: 1
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

Joined: Nov 10, 2009
Posts: 1
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

Joined: Jan 09, 2006
Posts: 8
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
 
 
subject: Portlets And Portlet Preferences
 
Similar Threads
Weblogic portal Backing file, Preferences and portlet hide/undhide and different skins
Unable to show/hide JSF portlets
share (user/preference) data between portlets (ipc with jsr 286 ?)
How to pass Global parameter across portlets which are using JSR 168 API
Problem with Portlet Preferences not loading