简体   繁体   English

使用rich:dataTable和rich:dataTableScroller延迟加载数据

[英]Lazy data loading with rich:dataTable and rich:dataTableScroller

I am using rich:dataTable with rich:dataTableScroller . 我正在使用rich:dataTablerich:dataTableScroller And I don't want load all my data from DB when initialize table, because I have very many records. 而且我不希望在初始化表时从数据库加载所有数据,因为我有很多记录。 I want that that rich:dataTableScroller show me real page count but load page only when I switch on in. I find some solution here But I want use rich:dataTable and rich:dataTableScroller , and don't write my own components. 我想让rich:dataTableScroller向我显示真实的页面计数,但仅在打开电源时才加载页面。我在这里找到了一些解决方案但是我想使用rich:dataTablerich:dataTableScroller ,不要编写自己的组件。 Have somebody some ideas ? 有一些想法吗?

You should create a custom org.richfaces.model.DataProvider , and in getItemsByRange you should fetch the limited data. 您应该创建一个自定义org.richfaces.model.DataProvider ,并在getItemsByRange获取有限的数据。 You should then construct an ExtendedTableDataModel passing your custom DataProvider , and use this model in your <rich:dataTable> - value="#{myBean.myExtendedDataModel}" 然后,您应该构造一个传递自定义DataProviderExtendedTableDataModel ,并在您的<rich:dataTable> value="#{myBean.myExtendedDataModel}"使用此模型

You can create your own "PagedDataModel", which actually returns only the data that will be shown in the page you are seeing. 您可以创建自己的“ PagedDataModel”,它实际上仅返回将在您看到的页面中显示的数据。

I have found an example for this here . 在这里找到了一个例子。

您可以将自己的数据模型编写为richfaces ExtendedDataModel的子模型,该子模型具有以下方法:

protected List<T> loadData(int offset, int limit, List<Order> orders)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM