Primefaces LazyModel 数据表始终要求first=0 pageSize=10
我正在使用 LazyDataModel 在 10 页中填充 33 个项目(一长串部件的子集,可以增长或缩小)的表。表减速如下
<p:dataTable var="spare" value="#{sitePartController.selectParts}" paginator="true" lazy="true"
currentPageReportTemplate="(Entries: {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"
paginatorTemplate="{CurrentPageReport}{FirstPageLink}{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rows="10" selection="#{sitePartController.selectedParts}"
paginatorAlwaysVisible="false"
dynamic="true"
>
分页工作正常,用 33 个项目填充 currentPageTemplate 4第 1-10 页等。当我按下链接时,所有分页输出都会正确更改(第 2/4 页等)。然而表中的数据没有改变,只是继续显示记录0-9。我的重写 Load 方法如下。
selectParts = new LazyDataModel() {
@Override
public List<SitePart> load(int first, int pageSize, String string, boolean bln, Map map) {
return getSiteSpares(first,first+pageSize);
}
};
int totalRowCount = getSparesCount();
selectParts.setRowCount(totalRowCount);
当我在加载方法中停止调试时,无论我选择哪个数据表分页链接; first 始终为 0,page 为 10(如预期)。我如何让数据表发送正确的第一个索引,或者我在过去 6 个小时的谷歌搜索和尝试各种替代方案中错过了一些基本的东西。
I am using the LazyDataModel to populate a a table with 33 items(A sub set of a long list of parts and can grow or shrink) in pages of 10. the table deceleration is as follows
<p:dataTable var="spare" value="#{sitePartController.selectParts}" paginator="true" lazy="true"
currentPageReportTemplate="(Entries: {startRecord} - {endRecord} of {totalRecords}, Page: {currentPage}/{totalPages})"
paginatorTemplate="{CurrentPageReport}{FirstPageLink}{PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink}"
rows="10" selection="#{sitePartController.selectedParts}"
paginatorAlwaysVisible="false"
dynamic="true"
>
The pagination works fine filling the currentPageTemplate with 33 items 4 pages 1- 10 etc. When i press a link all the pagination output changes correctly(page 2/4 etc). However the data in the table does not change, just continues to show records 0-9. My override Load method is as follows.
selectParts = new LazyDataModel() {
@Override
public List<SitePart> load(int first, int pageSize, String string, boolean bln, Map map) {
return getSiteSpares(first,first+pageSize);
}
};
int totalRowCount = getSparesCount();
selectParts.setRowCount(totalRowCount);
When I stop my debug in the load method no matter which datatable pagination link I select; first is always 0 and page is 10 (as expected). How do I get the datatable to send the correct first index or have I missed something fundamental in the last 6 hours of googleing and trying various alternatives.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定是否会导致问题,但不应该是:
Not sure if it could cause the issue, but shouldn't it be:
尝试将 p:dataTable 放入 h:form 中
Try to put p:dataTable inside h:form