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)

Preparing the backend for lazy loading

Lazy loading (and filtering) capabilities should be delegated to the backend as much as possible. Although the Grid class itself is able to cache some of the data and send it to the client only when needed, it cannot prevent you from querying the whole database, for example. In order to support lazy loading, backend services should provide the means to lazily load the data.

Typically, the UI gets the data from a service or repository class. Let's see an example of how a repository class can provide methods with lazy loading capabilities. The CallRepository class could define a findAll method that queries a slice of the rows in the Call table, as follows:

public class CallRepository {

    public static List<Call> findAll(int offset, int limit) {
        ...
    }

public static int count() {
...
} }

In the previous...