2012-07-31 71 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

相关问题