2012-07-31 69 views
2

我使用Primefaces輪播組件顯示項目列表。我想要做的是在每個傳送帶項目上顯示一個commandButton,它觸發bean上的一個方法來確認或拒絕該條目。Primefaces commandButton僅適用於輪播組件的第一個條目

現在它僅適用於輪播的第一個條目。點擊另一個條目不會調用操作confirmResource。我想這與身份證有關,但我無法弄清楚。

這裏的形式:

<h:form id="form" prependId="false"> 
<p:carousel id="resourceCarousel" value="#{resourceRatingBean.resourceProposalList}" var="var" rows="1" itemStyle="width:500px; height: 400px; text-align:center;" circular="true"> 
    <p:column> 

     <h:panelGrid columns="1" cellpadding="3"> 
      <p:graphicImage value="/cache/images/#{var.imagePath}" width="100"/> 
      <h:outputText value="#{var.imagePath}" /> 
      <h:outputText value="#{var.name}" /> 
      <h:outputText value="#{var.description}" /> 
     </h:panelGrid> 

     <p:commandButton value="confirm" action="#{resourceRatingBean.confirmResource}" process="@this"> 
      <f:setPropertyActionListener value="#{var}" target="#{resourceRatingBean.ratedResource}" /> 
     </p:commandButton> 

    </p:column> 
</p:carousel> 
</h:form> 

回答

3

我看到這裏有兩個可能的問題:

  1. process="@this"可能是一個問題,因爲這隻會調用過程的調用命令按鈕的作用而不是傳送帶組件的變化。嘗試將此屬性設置爲resourceCarousel@form

  2. 如果仍然有問題,並使用JSF 2 + EL 2.2,然後代替取決於setPropertyActionListener設置託管屬性的值,則代替可以將參數var通過EL表達式傳遞給actionListener方法。

下面是一個例子:

<p:commandButton value="confirm" actionListener="${resourceRatingBean.confirmResourceListener(var)}" 
    this="resourceCarousel" /> 
+0

設置過程= 「@形式」,它就像一個魅力!以爲我曾嘗試過;-) ..感謝您的解決方案! – tobiasdenzler 2012-07-31 11:42:34

相關問題