我有这个简单的页面:
<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
不工作,只是刷新页面。但外面的那个正在工作。
如果我改变
value
和 lazy
这边走:<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
奇迹般有效。有人知道为什么吗?
这是一个错误吗?
我上线了
最佳答案
发现惰性数据模型必须是回发请求中的相同实例,即使具有相同值的新实例也不起作用。所以它必须至少由 @ViewScoped
提供 bean 角,扁 bean 。
关于jsf-2 - Primefaces DataTable、延迟加载和每行命令按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11918834/