Book Image

Primefaces Cookbook Second Edition

Book Image

Primefaces Cookbook Second Edition

Overview of this book

Table of Contents (20 chapters)
PrimeFaces Cookbook Second Edition
Credits
Foreword
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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 inline, the component starts to listen to the scroll event of the dataScroller container.

Providing buffer

The buffer attribute states the percentage height of the buffer between the bottom of the page and the scroll position to initiate...