O'Reilly logo

PrimeFaces Cookbook - Second Edition by Oleg Varaksin, Mert Çalışkan

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Visualizing data with dataScroller

The dataScroller component offers lazy loading of a collection via AJAX when the page is scrolled down.

How to do it…

A basic definition of the dataScroller component would be as shown here:

<p:dataScroller value="#{dataScrollerBean.cars}" 
  var="car" chunkSize="10">
  #{car.name}
</p:dataScroller>

The data gets loaded with specified chunks where its size is determined with the chunkSize attribute, and then the retrieved content will be appended at the bottom of the component.

There's more…

The AJAX loading takes place when the page is scrolled down, and this is achieved by monitoring the vertical scrollbar. This can be modified by the mode attribute, which has document as its default value. When its value is set to

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required