虽然这个问题有点重复,但我在网上搜索仍然无法找到我想要的确切结果。在我的情况下,我使用具有CRUD功能的Primefaces在JSF中开发项目。我在p:dataTable
中有超过3k的记录。如果我想更新选定的5条记录,我只能更新整个dataTable(需要很长时间)。
情境:
1)选择Datatable中的记录
2)单击p:commandButton
以执行业务逻辑,并将提供所选记录的结果。
(在p:commandButton
我使用数据表更新)
注意:
我只能强迫使用Primefaces
。 (我发现omniFaces
有解决方案,但我不应该使用)
请帮助我!
答案 0 :(得分:0)
PrimeFaces允许您使用PrimeFacesSelectors(PFS)基于styleClass
更新组件。
update="@(.mystyle)"
您可以使用它来更新特定数据行的目的
这是策略:
1.为每一行的每列设置唯一rowKey
作为styleClass
2.在PFS中使用rowKey
作为update
属性。
以下是一段简短的代码段:
<p:dataTable var="mov" value="#{repeatUIBean.mList}" ro>
<p:column headerText="mov Name">
<h:outputText styleClass="#{mov.uniqueId}" value="#{mov.name}"/>
</p:column>
<p:column headerText="mov Release Year">
<h:outputText styleClass="#{mov.uniqueId}" value="#{mov.year}"/>
</p:column>
<p:column headerText="Edit mov">
<p:commandButton value="Edit" update="@(.#{mov.uniqueId})"/>
</p:column>
</p:dataTable>