Forums

Home » Liferay Portal » English » x. Miscellaneous

Combination View Flat View Tree View
Threads [ Previous | Next ]
X Man
Portlet Preferences
January 19, 2012 4:35 AM
Answer

X Man

Rank: Junior Member

Posts: 41

Join Date: January 5, 2012

Recent Posts

Hello.
I use PortletPreferences class,this code to store preferences in the action(ConfigAction implements ConfigurationAction):
preferences().setValue("greeting", greeting);
preferences().store();

,and this code to retrieve the data in the jsp page:
String greeting = preferences.getValue("greeting", "no peferences");
But I dont get the values that I stored it.
How can I use the preferences successfully.
Thank you.
Dave Weitzel
RE: Portlet Preferences
February 9, 2012 8:14 PM
Answer

Dave Weitzel

Rank: Regular Member

Posts: 153

Join Date: November 18, 2009

Recent Posts

Are there any errors in your console log or catalina.out file?

I am also having problems using preferences.store() in 6.1 is that the version you are using? I ma be raising a jira ticket tomorrow if I cannot crack it.

to help more perhaps a full snippet of code showing how the preferences were created in the first place.
Sandeep Nair
RE: Portlet Preferences
February 9, 2012 10:49 PM
Answer

Sandeep Nair

Rank: Liferay Legend

Posts: 1671

Join Date: November 5, 2008

Recent Posts

If you are using ConfigurationAction retrieve portletPreferences like this in java

1String portletResource = ParamUtil.getString(
2            actionRequest, "portletResource");
3
4        PortletPreferences preferences =
5            PortletPreferencesFactoryUtil.getPortletSetup(
6                actionRequest, portletResource);
7preferences().setValue("greeting", greeting);
8preferences().store();


And in jsp use this
 1
 2PortletPreferences preferences = renderRequest.getPreferences();
 3
 4String portletResource = ParamUtil.getString(request, "portletResource");
 5
 6if (Validator.isNotNull(portletResource)) {
 7    preferences = PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource);
 8}
 9String greeting = preferences.getValue("greeting", "no peferences");


Regards,
Sandeep