Reputation: 1438
I have a custom portlet which use 2 parameters I wrote in my portlet-conf.properties.
So, I would like change them if I want, by enters two new values into my setup tab, in configuration menu of the portlet.
Tab setup : http://imageshack.us/photo/my-images/155/samplesz.png/
I have my Controller and jsp for my portlet, and a conf.jsp and ConfigurationActionImpl which implements render returning conf.jsp and processAction empty for now, for the tab.
How can I code my jsp and my configAction for have 2 input text which can modify my two parameters in my portlet-conf.properties?
I want, when we click on the submit button, that change the value in a varaible on my property file. If possible, display a default value in the input box, with the actual value.
Regards. Thank you
Upvotes: 2
Views: 574
Reputation: 2193
I don't think you can overwrite the property values, just like that. The property file should be used as the portlet configuration.
You must use PortletPreferences
for the same.
What you can do is that in your conf.jsp
, create 2 input box and submit button. When you click submit button, processAction()
of your ConfigurationActionImpl
will be called. Here in this method, get the PortletPreferences
and save the values into them.
The properties file will be used as the default values of the preferences. So, the flow would be
1) When user comes first time on the configuration of the portlet, you will get the null values in the portlet preferences, so load from the properties file.
2) User can change the values and when he/she clicks the submit button, save that into PortletPreferences
3) Next time, take the values from the PortletPreferences
.
Hope this will help.
Upvotes: 2