Forums

Home » Liferay Portal » English » 3. Development

Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Dariusz Sawicki
Save portlet preferences by preferences--parameter--
December 20, 2012 5:21 AM
Answer

Dariusz Sawicki

Rank: Regular Member

Posts: 164

Join Date: March 27, 2009

Recent Posts

Hi
It's working in 6.x Liferay?

<aui:input name="preferences--parameter--" value="" type="text"/>

Because not working for me if I extended asset publishser.

Regards
sawi
Amit Doshi
RE: Save portlet preferences by preferences--parameter--
December 26, 2012 3:33 AM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

sawi _:
Hi
It's working in 6.x Liferay?

<aui:input name="preferences--parameter--" value="" type="text"/>

Because not working for me if I extended asset publishser.

Regards
sawi


What you are exactly looking for?

If you are looking to store value in portlet prefrence then below is the code.

1
2final PortletPreferences prefs = portletRequest.getPreferences();
3prefs.setValue("paramName", "paramValue");
4prefs.store();


Thanks & Regards,
Amit Doshi
Hitoshi Ozawa
RE: Save portlet preferences by preferences--parameter--
January 2, 2013 5:36 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Alloy UI is just an user interface library so it won't save any data.

Follow Amit's instructions and create a Java class which is invoked from your FORM if you want to save your data.
Jitendra Rajput
RE: Save portlet preferences by preferences--parameter--
January 2, 2013 10:45 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 858

Join Date: January 7, 2011

Recent Posts

Its is working with Liferay 6.1

Define your AUI element with below syntax
<aui:input name="preferences--showFeedTitle--" type="checkbox" value="<%= showFeedTitle %>" />


It should follow pattern like preferences--paramName-- .

And make sure you use below Configuration class in your liferay-portlet.xml
<configuration-action-class>com.liferay.portal.kernel.portlet.DefaultConfigurationAction</configuration-action-class>


By using this way we dont need to write any code to store form element value into preferences . DefaultConfigurationAction class will detect form element with specified syntax and store the same in preference for you.

In case if you want to retrieve value from preference then directly use
1preferences.getValue("showFeedTitle")
// No need to use that syntax to get value
Hitoshi Ozawa
RE: Save portlet preferences by preferences--parameter--
January 2, 2013 10:59 PM
Answer

Hitoshi Ozawa

Rank: Liferay Legend

Posts: 7949

Join Date: March 23, 2010

Recent Posts

Interesting. Have to test it out.

The normal way to save configuration is outlined in the page below.
http://www.liferaysolution.com/2012/05/add-configuration-page-in-plugin.html
Jitendra Rajput
RE: Save portlet preferences by preferences--parameter--
January 2, 2013 11:09 PM
Answer

Jitendra Rajput

Rank: Liferay Master

Posts: 858

Join Date: January 7, 2011

Recent Posts

Yes its interesting and it will reduce code to store form elements values in preferences. emoticon

Listed same thing on my blog as well.
http://itsliferay.blogspot.in/2012/07/advantage-of-using-liferay-61.html
Amit Doshi
RE: Save portlet preferences by preferences--parameter--
January 2, 2013 11:04 PM
Answer

Amit Doshi

Rank: Liferay Master

Posts: 549

Join Date: December 29, 2010

Recent Posts

Jitendra Rajput:
Yes its interesting and it will reduce code to store form elements values in preferences. emoticon


I would definitely like to give a try for it. It's something new today I learned from you.

Thanks for sharing this information.
Gaurav kalia
RE: Save portlet preferences by preferences--parameter--
June 10, 2013 8:07 AM
Answer

Gaurav kalia

Rank: New Member

Posts: 14

Join Date: August 13, 2012

Recent Posts

Hi Jitendra

Any idea how can I use the same mechanism for dropdown if I am selecting multiple values ?

Thanks
Gaurav
Riccardo Rotondo
RE: Save portlet preferences by preferences--parameter--
October 6, 2015 7:41 AM
Answer

Riccardo Rotondo

Rank: Junior Member

Posts: 29

Join Date: June 11, 2010

Recent Posts

Hi, what if the preferences I'm dealing with have multiple values? Any fast way to update the value with preferences--parameters-- ??

I'll explain better with an example. Suppose I have in my portlet.xml

1<preference>
2           <name>MultipleValues</name>
3           <value>Number 2</value>
4           <value>Number 3</value>
5 </preference>


And in my config.jsp

 1<%
 2PortletPreferences preferences = renderRequest.getPreferences();
 3String portletResource = ParamUtil.getString(request, "portletResource");
 4PortletPreferences prefs =
 5           PortletPreferencesFactoryUtil.getPortletSetup(request, portletResource);
 6String [] mul = prefs.getValues("MultipleValues",
 7                                    new String []{"", ""});
 8%>
 9
10<aui:form action="<%= configurationURL %>" method="post" name="fm">
11    <aui:input name="<%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />
12
13    <aui:input name="preferences--MultipleValues--"
14               type="text" value="<%= mul[0] %>" />
15    <aui:input name="preferences--MultipleValues--"
16               type="text" value="<%= mul[1] %>" />
17
18   
19    <aui:button-row>
20       <aui:button type="submit" />
21    </aui:button-row>
22</aui:form>


After the submit the preference "MultipleValues" will be updated only with one value and it changes from a String[2] to a simple String.

Any way to specify a in the aui to refers to the index like preferences-MultipleValues-[0] ??

Thank you in advance for the help.

Cheers
Chandan Sharma
RE: Save portlet preferences by preferences--parameter--
October 6, 2015 8:20 AM
Answer

Chandan Sharma

Rank: Junior Member

Posts: 62

Join Date: May 27, 2012

Recent Posts

sawi _:
Hi
It's working in 6.x Liferay?

<aui:input name="preferences--parameter--" value="" type="text"/>

Because not working for me if I extended asset publishser.

Regards
sawi


I tried with Liferay 6.2 it is not working for me. but it is working in Liferay 6.1.

Thanks
Chandan