0

我在 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());

我得到dataFileDocNameCOM-EXAMPLE-EDIT但如果我将偏好更改为其他内容,我仍然会得到相同的偏好COM-EXAMPLE-EDIT(无论我清理和发布我的项目多少次)。

请帮帮我。

4

1 回答 1

1

3件事:

1. portlet 首选项只能在操作阶段更改
2. 调用 setValue 然后存储以确保保存对首选项的更改
3. 只读首选项不能更改,因此请确保不要在部署描述符。

于 2012-09-18T12:46:47.503 回答