This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Suman Kumar Verma
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 18276
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic