我在portlet首选项中遇到问题,我无法更改portlet首选项值,即首选项值没有更改。
我已经更改了portlet中的值,然后在portlet.xml
中进行了交叉检查,并在其中进行了更改。但是,当我尝试使用其键获取此portlet首选项值时,它总是给我更早的值。
我的portlet.xml如下所示:
<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>
在Java文件中,我正在检索这样的首选项:
....
//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());
我将dataFileDocName
作为 COM-EXAMPLE-EDIT 但是如果我将偏好更改为其他内容,我仍然会获得相同的偏好 COM-EXAMPLE-EDIT (无论我清理和发布我的项目多少次。)
请帮帮我。
答案 0 :(得分:1)
3件事:
1.只有在行动阶段才能改变portlet首选项 2.调用setValue然后存储以确保保存对首选项的更改 3.无法更改只读首选项,因此请确保不要在部署描述符中将它们标记为只读。