JSF 保留旧数据
JSF keeps the old data
我有一个 PrimeFaces 按钮,它应该通过 Java 处理数据并将其显示在数据表中。
这是代码:
<p:dataTable rowIndexVar="rowIndex" var="report"
id="TableResult"
style="height:685px;width: 97vw;"
value="#{reportResultController.resultRows}"
resizableColumns="true"
scrollable="true"
scrollHeight="95%"
scrollRows="30"
liveScroll="true"
lazy="false"/>
按钮呈现 table () 的数据:
<p:commandButton value="Report "
action="#{ReportController.produceReport}" id="produce_report"
update="TableResult"
process="TableResult"/>
这是Java部分
public void produceReport() {
resultRows = reportResultUtils.runReport(rph, rowsLimit); //Returning List of rows
}
public List<Object[]> getResultRows() {
return resultRows;
}
数据处理工作正常。
问题是,在我为相同的数据按下按钮两次的情况下,我第一次看到结果,而下一次我看到它两次而不是一次。
第一次
ID 名称
1 大卫
2 乔
第二次
ID 名称
1 大卫
2 乔
1 大卫
2 乔
第三次和第四次只保持第二次的两倍。
如果我更改参数以获得不同的 table,那么它会清除 table 而不会混淆数据。
在 resultRows var 中设置新数据之前,如何才能仅显示一次或删除 table 中的数据?
好的
原来是PrimeFace的bug.
确实如@Kukeltje 所述,问题出在 liveScroll="true"
。
当我删除它时,它起作用了。
因此解决方法是将 Rows
属性添加到与 scrollRows
大小相同的 DataTable:
<p:dataTable rowIndexVar="rowIndex" var="report"
id="TableResult"
style="height:685px;width: 97vw;"
value="#{reportResultController.resultRows}"
resizableColumns="true"
scrollable="true"
scrollHeight="95%"
scrollRows="30"
rows="30" <!-- This is the solution-->
liveScroll="true"
lazy="false"/>
我有一个 PrimeFaces 按钮,它应该通过 Java 处理数据并将其显示在数据表中。
这是代码:
<p:dataTable rowIndexVar="rowIndex" var="report"
id="TableResult"
style="height:685px;width: 97vw;"
value="#{reportResultController.resultRows}"
resizableColumns="true"
scrollable="true"
scrollHeight="95%"
scrollRows="30"
liveScroll="true"
lazy="false"/>
按钮呈现 table () 的数据:
<p:commandButton value="Report "
action="#{ReportController.produceReport}" id="produce_report"
update="TableResult"
process="TableResult"/>
这是Java部分
public void produceReport() {
resultRows = reportResultUtils.runReport(rph, rowsLimit); //Returning List of rows
}
public List<Object[]> getResultRows() {
return resultRows;
}
数据处理工作正常。 问题是,在我为相同的数据按下按钮两次的情况下,我第一次看到结果,而下一次我看到它两次而不是一次。
第一次
ID 名称
1 大卫
2 乔
第二次
ID 名称
1 大卫
2 乔
1 大卫
2 乔
第三次和第四次只保持第二次的两倍。
如果我更改参数以获得不同的 table,那么它会清除 table 而不会混淆数据。
在 resultRows var 中设置新数据之前,如何才能仅显示一次或删除 table 中的数据?
好的
原来是PrimeFace的bug.
确实如@Kukeltje 所述,问题出在 liveScroll="true"
。
当我删除它时,它起作用了。
因此解决方法是将 Rows
属性添加到与 scrollRows
大小相同的 DataTable:
<p:dataTable rowIndexVar="rowIndex" var="report"
id="TableResult"
style="height:685px;width: 97vw;"
value="#{reportResultController.resultRows}"
resizableColumns="true"
scrollable="true"
scrollHeight="95%"
scrollRows="30"
rows="30" <!-- This is the solution-->
liveScroll="true"
lazy="false"/>