Reputation: 1
I am facing a problem in portlet preference where i am unable to change portlet preference value i.e the preference value is not getting changed.
I have changed the value in portlet and then crossed checked in portlet.xml
, where it is changed. But when i am trying to get this portlet preference value using its key it always gives me the earlier value.
My portlet.xml looks like this:
<portlet-preferences>
<preference>
<name>DATA_FILE_DOC_NAME</name>// the name of the preference
<value>COM-EXAMPLE-EDIT</value>// the corresponding value
<read-only>false</read-only>// extra attribute
</preference>
</portlet-preferences>
And in Java file i am retrieving this preference like this:
....
//Getting the portal prefernce object.
PortletPreferences portletPreference = portletRequest.getPreferences();
// get the data file doc name.
dataFileDocName = portletPreference.getValue(
"DATA_FILE_DOC_NAME", "Not Found!!");
System.out.println("Data file doc name is : "+dataFileDocName.toUpperCase());
I am getting dataFileDocName
as COM-EXAMPLE-EDIT but if I change the preference to something else, still I get the same preference COM-EXAMPLE-EDIT (no matter how many times i clean and publish my project).
Please help me out.
Upvotes: 0
Views: 1434
Reputation: 383
3 things:
1. portlet preferences can be changed only in action phase
2. call setValue and then store in order to ensure changes to preference are saved
3. read-only preferences cannot be changed, so make sure you dont mark them as read-only in the deployment descriptor.
Upvotes: 1