2014-10-06 84 views
0

我迷路了。我研究了幾乎每個關於setPropertyListener的帖子,我不知道自己做錯了什麼。我有這樣的JSF頁面:f:setPropertyActionListener沒有設置屬性

<ui:define name="content"> 
    <h:form id="itemSearchForm"> 
     <p:commandButton update=":itemForm" 
         icon="ui-icon ui-icon-search"> 
      <f:setPropertyActionListener target="#{itemDetailManagedBean.itemId}" 
             value="test"/> 
      <f:setPropertyActionListener target="#{itemDetailManagedBean.accountType}" 
             value="test"/> 
     </p:commandButton> 
     <p:dataTable id="itemList" 
        paginator="true" 
        var="currentItem" 
        value="#searchItemManagedBean.searchItems}"> 
      . 
      . 
      <p:column headerText="Detail"> 
       <p:commandButton update=":itemForm" 
           oncomplete="PF('itemDetail').show()" 
           icon="ui-icon ui-icon-search"> 
        <f:setPropertyActionListener target="#{itemDetailManagedBean.itemId}" 
               value="test"/> 
        <f:setPropertyActionListener target="#{itemDetailManagedBean.accountType}" 
               value="test"/> 
       </p:commandButton> 
      </p:column> 
     </p:dataTable> 
    </h:form> 
</ui:define> 

和itemDetailManagedean:

public class ItemDetailManagedBean implements Serializable{ 

    private String itemId,accountType; 

    public ItemDetailManagedBean() { 
    } 

    public SearchForItemBean getSearchBean() { 
     return searchBean; 
    } 

    public String getItemId() { 
     return itemId; 
    } 

    public String getAccountType() { 
     return accountType; 
    } 

    public void setItemId(String itemId) { 
     this.itemId = itemId; 
    } 

    public void setAccountType(String accountType) { 
     this.accountType = accountType; 
    } 


} 

的問題是,第一個CommandButton工作,因爲它應該(因此它設置的屬性右)。但第二個commandButton根本不起作用。這兩個按鈕都顯示對話框,因爲它們應該。我在頁面的其他部分有itemForm。

+0

你是什麼意思第二個commandButton不起作用?它設置了不正確的值,或者將null設置爲變量。 – wittakarn 2014-10-07 01:42:55

回答

0

最後得到了溶劑。問題實際上不在JSF中,而是在ServiceBean中,它在加載期間更改了數據表內容。

+0

你做了什麼來解決它? – StudioWorks 2015-07-28 12:59:57

+0

我必須將結果存儲到@PostConstruct方法的屬性中,並且getter只返回「緩存」屬性。 – 2015-10-23 14:19:26

相關問題