原始DataTable,懒惰加载和每行的CommandButton [英] Primefaces DataTable, lazy loading and CommandButton per row

查看:146
本文介绍了原始DataTable,懒惰加载和每行的CommandButton的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个简单的页面:

<h:form id="form">

    <p:dataTable value="#{testBean.unitTypeModel}" var="elem" lazy="true" rows="10">
        <p:column headerText="class">#{elem.class.simpleName}</p:column>
        <p:column headerText="code">#{elem.code}</p:column>
        <p:column headerText="description">#{elem.description}</p:column>
        <p:column headerText="action">
            <p:commandButton action="test2" icon="ui-icon ui-icon-wrench" value="edit">
                <f:setPropertyActionListener target="#{testBean.selection}" value="#{elem}"/>
            </p:commandButton>
        </p:column>
    </p:dataTable>

    <p:commandButton action="test2" icon="ui-icon ui-icon-wrench"/>

</h:form>

CommandButton 里面 DataTable 不工作,只是刷新页面。
,但外面的人正在工作。

and the CommandButton inside DataTable is not working, just refreshes page. but the one outside is working.

如果我更改懒惰这样:

<h:form id="form">

    <p:dataTable value="#{testBean.unitTypeModel.load(0, 10, null, null, null)}" var="elem" lazy="false" rows="10">
        <p:column headerText="class">#{elem.class.simpleName}</p:column>
        <p:column headerText="code">#{elem.code}</p:column>
        <p:column headerText="description">#{elem.description}</p:column>
        <p:column headerText="action">
            <p:commandButton action="test2" icon="ui-icon ui-icon-wrench" value="edit">
                <f:setPropertyActionListener target="#{testBean.selection}" value="#{elem}"/>
            </p:commandButton>
        </p:column>
    </p:dataTable>

    <p:commandButton action="test2" icon="ui-icon ui-icon-wrench"/>

</h:form>

CommanButton 里面 DataTable 像一个魅力一样。

the CommanButton inside DataTable works like a charm.

有人知道为什么?

是一个bug?

我在


  • Glassfish 3.1.2

  • JSF 2.1.11(Mojarra)

  • PrimeFaces 3.4-SNAPSHOT

推荐答案

发现懒惰的数据模型在回发请求时必须是相同的实例,即使是具有相同值的新实例也不会工作。所以它必须从至少一个 @ViewScoped bean提供。

found out that the lazy datamodel must be the same instance on postback request, even a new instance with the very same values will not work. so it must be provided from at least a @ViewScoped bean.

这篇关于原始DataTable,懒惰加载和每行的CommandButton的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆