【问题标题】:PrimeFaces panel inside a jstl <c:forEach loop is keeping the previous index of the collapsed panel on updating the panel from an external linkjstl <c:forEach 循环内的 PrimeFaces 面板在从外部链接更新面板时保留折叠面板的先前索引
【发布时间】:2012-12-08 07:22:00
【问题描述】:

我有一个网页,其中包含一个 jstl forEach 循环内的面板列表。所有面板在加载页面时都会折叠。在展开每个面板时,我将折叠状态保存到 bean 以便以后参考。我从 p:commandLink 更新面板,但面板显示为基于先前的 index 展开,而不是 bean 值。我的要求是panel的collapsed属性应该根据之前设置的bean值更新,目前panels是根据之前展开的panel的索引来展开的,而不是根据它的bean属性值。

看一下代码sn-p。

<h:form id="form">
        <c:forEach items="#{items}" var="name">
            <p:panel header="#{name}" toggleable="true"
                toggleTitle="#{bean.toggleStatus.get(name)}"
                collapsed="#{bean.toggleStatus.get(name)}" toggleSpeed="500"
                id="panel#{name}" widgetVar="panel#{name}">
                <h:outputText value="#{name}"/>
            </p:panel>
        </c:forEach>
        <p:commandLink id="Search" style="margin-left :5px;"
            action="#{bean.search}" update="form" ajax="true"/>
    </h:form>

【问题讨论】:

  • 需要支持 bean 代码。特别是,toggleStatus.get(name)

标签: jsf primefaces jstl


【解决方案1】:

从您的代码看来,#{bean.toggleStatus.get(name)} 返回一个 String 对象。

&lt;p:panel collapsed=""&gt; 需要一个布尔值。

您必须发布您的支持 bean 代码,才能看到该方法的返回值。

【讨论】:

    猜你喜欢
    • 2015-02-02
    • 1970-01-01
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多