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

Managing events with schedule by leveraging lazy loading


The Schedule component provides a calendar to manage events, such as Outlook Calendar and iCal. By default, a whole set of events is eagerly provided via the ScheduleModel class. That means all events are loaded at once on page load. The lazy loading feature helps to improve performance if we have a huge dataset of events or if events take too much time to load. In the lazy loading mode, only events that belong to the displayed timeframe are fetched.

In this recipe, we will implement a small example for the Schedule component's lazy loading feature.

How to do it…

A basic definition of schedule would be as shown here:

<p:schedule id="lazySchedule"
  value="#{scheduleBean.lazyScheduleModel}"/>

The visual output of the component with two randomly generated events will be as shown here:

By default, the month view is displayed, so the user sees a whole month and can switch between months. Assume that we have to load events for 12 months...