Save Portlet Preferences in Liferay 6.1

With Liferay 6.1 if you are using configuration mode and if you want to store form elements values in preferences then this post will definitely help you.

You can store form elements value in preferences with less efforts (as compare to version below Liferay 6.1).

You just need to follow few syntax to achieve this functionality. Lets go step by step.

Edit :Create hidden field with the name command so that Controller will automatically understand what you are trying to do.

<input name="<portlet:namespace /><%= Constants.CMD %>" type="hidden" value="<%= Constants.UPDATE %>" />

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

preferences.getValue("showFeedTitle")
// No need to use that syntax to get value  


You can check sample jsp for the same on this link

You can also visit Liferay for same thing . Following is my community blog link. Unique way to save portlet preferences

0 comments :

Post a Comment