【问题标题】:Primefaces commandButton only working on first entry of a carousel componentPrimefaces commandButton 仅适用于轮播组件的第一个条目
【发布时间】:2012-07-31 07:09:35
【问题描述】:

我使用 Primefaces 轮播组件来显示项目列表。我想做的是在每个轮播项目上显示一个命令按钮,它会触发 bean 上的一个方法来确认或拒绝条目。

现在它只适用于轮播的第一个条目。单击另一个条目不会调用操作 confirmResource。我想这与ID有关,但我无法弄清楚。

这是表格:

<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>

【问题讨论】:

    标签: jsf primefaces carousel


    【解决方案1】:

    我在这里看到两个可能的问题:

    1. process="@this" 可能是一个问题,因为这只会调用 commandButton 的调用操作的过程,而不是轮播组件中的更改。请尝试将此属性设置为 resourceCarousel 或 @form。

    2. 如果您仍然遇到问题并使用 JSF 2 + EL 2.2,那么您可以将参数 var 传递给 @,而不是依赖 setPropertyActionListener 设置托管属性的值987654326@ 方法通过 EL 表达式。

    这是一个例子:

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

    【讨论】:

    • 设置过程="@form" 它就像一个魅力!以为我之前尝试过;-)..感谢您的解决方案!
    猜你喜欢
    • 2017-07-27
    • 2013-12-31
    • 2018-07-25
    • 2023-03-19
    • 1970-01-01
    • 2017-11-10
    • 2017-11-01
    • 1970-01-01
    • 2022-01-01
    相关资源
    最近更新 更多