wood burning stoves 2.0*
The moose likes JSF and the fly likes Primefaces datatable with specific number of records to load on live scrolling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Primefaces datatable with specific number of records to load on live scrolling" Watch "Primefaces datatable with specific number of records to load on live scrolling" New topic
Author

Primefaces datatable with specific number of records to load on live scrolling

Suman Kumar Verma
Greenhorn

Joined: Sep 20, 2013
Posts: 1
I have a primefaces datatable with live scrolling enabled, i have assigned the attribute scrollRows to 50.But since it is having more than 50 columns it is taking more time for next set of 50 records to get loaded when i reach the end of scrolling.Is there any way by which initially on page load i load only 50 records and then at the end of scroll i load small number of records say 5 or 10.

Thanks in advance
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16022
    
  20

Welcome to the JavaRanch, Suman!

I cannot speak specifically to Primefaces, but I don't do this kind of thing on page load. I do it on the first call to the DataModel "get" method, then cache the results so that subsequent "get"s for that DataModel property return the cached DataModel. That is especially important since the "get" method might get called up to 6 times for a single page render operation - not counting other references made to it on the same View Definition.

So you have 2 parts to what you want to do: one to fetch data and construct DataModel for it, another to handle paging requests. There should be a Primefaces attribute you can set to cause an action to fire when the user clicks a paging button.

Using the cached DataModel method I described, handling the paging is relatively simple: just make the page-navigation method(s) adjust the starting point for the data fetch and null out the DataModel property. Since the first thing that the DataModel's "get" method does is check for a null Model and construct one if it's null, that's where you'd get your refreshed data.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
Consider Paul's rocket mass heater.
 
subject: Primefaces datatable with specific number of records to load on live scrolling