This chapter describes the Vaadin Data Model and shows how you can use it to bind components directly to data sources, such as database queries.
The Vaadin Data Model is one of the core concepts of the library. To allow the view (user interface components) to access the data model of an application directly, we have introduced a standard data interface.
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.
The Data Model is realized as a set of interfaces in the
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 relationships of the various interfaces are shown in Figure 9.2, “Interface Relationships in Vaadin Data Model”; the value change event
and listener interfaces are shown only for the
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
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.
In addition to the built-in implementations, many data model implementations, such as containers, are available as add-ons, either from the Vaadin Directory or from independent sources. Both commercial and free implementations exist. The JPAContainer, described in Chapter 19, Vaadin JPAContainer, is the most often used conmmercial container add-on. The installation of add-ons is described in Chapter 17, Using Vaadin Add-ons. Notice that unlike with most regular add-on components, you do not need to compile a widget set for add-ons that include just data model implementations.