2012-03-05 72 views
0

我在Portlet首選項中遇到了問題,我無法更改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(無論我清理和發佈我的項目多少次)。

請幫助我。

+0

你可以顯示一段代碼,你改變(試圖改變)首選項? – 2012-03-10 23:10:10

回答

1

3件事:

1. portlet首隻能在動作階段
2.調用setValue方法來改變,然後,以確保更改的偏好被保存
3.只讀的喜好不能儲存被更改,所以請確保您不要在部署描述符中將它們標記爲只讀。