Book Image

Data-Centric Applications with Vaadin 8

By : Alejandro Duarte
Book Image

Data-Centric Applications with Vaadin 8

By: Alejandro Duarte

Overview of this book

Vaadin is an open-source Java framework used to build modern user interfaces. Vaadin 8 simplifies application development and improves user experience. The book begins with an overview of the architecture of Vaadin applications and the way you can organize your code in modules.Then it moves to the more advanced topics about advanced topics such as internationalization, authentication, authorization, and database connectivity. The book also teaches you how to implement CRUD views, how to generate printable reports, and how to manage data with lazy loading. By the end of this book you will be able to architect, implement, and deploy stunning Vaadin applications, and have the knowledge to master web development with Vaadin.
Table of Contents (11 chapters)

Lazy loading with the Grid component

A Grid component can take advantage of the offset and limit parameters described in the previous section by using the setDataProvider method, as follows:

grid.setDataProvider(
    (sortOrders, offset, limit) ->
            CallRepository.findAll(offset, limit).stream(),
    () -> CallRepository.count()
);

The previous code defines two lambda expressions:

  • (sortOrders, offset, limit) -> service.find(...): This lambda expression should return all the items used in slice defined by the offset and limit parameters (we will see how to use the sortOrders parameters later)
  • () -> service.count(): This lambda expression should return the total count of items available with no slices

The setDataProvider method we used in the previous example receives an instance of FetchItemsCallback, a functional interface that defines a method to fetch...