2012-09-30 57 views
0

我有一個顯示所選擇的家庭(從樹上)描述的編輯器組件setPropertyActionListener不流通權價值

所以編輯程序後,用戶點擊保存按鈕,在那裏,我想利用這個

<f:setPropertyActionListener target="# 
      {projectTestManagementMB.selectedNodeDescription}" 
      value="projectTestManagementMB.selectedFamily.description" /> 

將描述的新值傳遞給這個變量selectedNodeDescription。但是當我檢查它時,我發現它包含舊值projectTestManagementMB.selectedFamily.description而不是新值。

下面的代碼:

<p:editor id="familyDescriptionEditor" value="# 
    {projectTestManagementMB.selectedFamily.description}" width="600"/> 

     <p:commandButton id="submitButton" value="Save" icon="ui-icon-disk" 
     actionListener="#{projectTestManagementMB.saveDescription}"> 
      <f:setPropertyActionListener target="# 
      {projectTestManagementMB.selectedNodeDescription}" 
      value="projectTestManagementMB.selectedFamily.description" /> 

     </p:commandButton> 
+1

爲什麼不ü用空的動作,並將其作爲參數傳遞? – Daniel

+0

相關:http://stackoverflow.com/questions/3909267/differences-between-action-and-actionlistener – BalusC

回答

1

該標籤創建和安裝的ActionListener實例有以下行爲和合同。 第一次創建此標記的組件時,僅創建並註冊ActionListener實例。

所以儘量使用action屬性代替的ActionListener:

<p:commandButton id="submitButton" value="Save" icon="ui-icon-disk" action="# 
     {projectTestManagementMB.saveDescription}" > 
      <f:setPropertyActionListener target="# 
     {projectTestManagementMB.selectedNodeDescription}" value="# 
      {projectTestManagementMB.selectedFamily.description}" /> 
    </p:commandButton>