Overview

    The model allows binding user interface components directly to the data that they display and possibly allow to edit. There are three nested levels of hierarchy in the data model: property, item, and container. Using a spreadsheet application as an analogy, these would correspond to a cell, a row, and a table, respectively.

    Vaadin Data Model

    Notice that the Data Model does not define data representation, but only interfaces. This leaves the representation fully to the implementation of the containers. The representation can be almost anything, such as a plain old Java object (POJO) structure, a filesystem, or a database query.

    The Data Model is used heavily in the core user interface components of Vaadin, especially the field components, that is, components that implement the Field interface or more typically extend AbstractField, which defines many common features. A key feature of all the built-in field components is that they can either maintain their data by themselves or be bound to an external data source. The value of a field is always available through the Property interface. As more than one component can be bound to the same data source, it is easy to implement various viewer-editor patterns.

    The relationships of the various interfaces are shown in Interface Relationships in Vaadin Data Model; the value change event and listener interfaces are shown only for the Property interface, while the notifier interfaces are omitted altogether.

    Interface Relationships in Vaadin Data Model

    The Data Model has many important and useful features, such as support for change notification. Especially containers have many helper interfaces, including ones that allow indexing, ordering, sorting, and filtering the data. Also Field components provide a number of features involving the data model, such as buffering, validation, and lazy loading.

    Vaadin provides a number of built-in implementations of the data model interfaces. The built-in implementations are used as the default data models in many field components.