tags:

views:

1501

answers:

3

I am using rich:dataTable with rich: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 andrich:dataTableScroller, and don't write my own components. Have somebody some ideas ?

A: 

You can write your own datamodel as child of richfaces ExtendedDataModel, which has method:

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

MarrLiss
there is no such method
Bozho
He meant that "your own" datamodel should have this method. Similar as `ScrollableTableDataModel` has.
BalusC
and if he just defines that method, and noone calls it, it would be useless. Furthermore, the last argument in `ScrollableTableDataModel` is the SortOrder, not a list
Bozho
A: 

You should create a custom org.richfaces.model.DataProvider, and in getItemsByRange you should fetch the limited data. You should then construct an ExtendedTableDataModel passing your custom DataProvider, and use this model in your <rich:dataTable> - value="#{myBean.myExtendedDataModel}"

Bozho
A: 

You can create your own "PagedDataModel", which actually returns only the data that will be shown in the page you are seeing.

I have found two complete examples for this:

Here and here. The second one also supports column sorting.

Markos Fragkakis