Setting portlet preferences in configuration mode

There two cases when the following post becomes interesting:

1. You hook some liferay portlet and want to modify a the portlets configuration jsp without hooking the appropriate struts action.

2. Creating a configuration view for your custom portlet by implementing a ConfigurationAction that extends com.liferay.portal.kernel.portlet.DefaultConfigurationAction and adding the following line to yoor liferay-portlet.xml:


 ...
 /icon.png
 
 de.blogspot.blog.liferay.ConfigurationAction
  
 true
 ...



When using AUI input fields just choose their names according the pattern "preferences--paramName--" and the DefaultConfigurationAction class will handle all parameters and store them in portlet preferences. There is no need to implement any line of code. Example input field:
< aui:input 
name="preferences--hideToolbar--" 
type="checkbox" value="<%= hideToolbar %>" />
Choosing the name "preferences--hideToolbar--" for your input field, the DefaultConfigurationAction will store the "hideToolbar" value in your portlet preferences when the user submits the configuration form.

Leave a Reply