Vaadin 7 alpha 1 - Improved Data Binding for Enterprise Applications

Vaadin 7 alpha 1 introduces significant changes and extensions to data binding.


Separation of form layout from data binding

With Vaadin 6, creating customized layouts for forms was difficult, often requiring users to either bypass the Form component and implement related logic in the applications or to subclass Form to customize how fields are placed on the UI.

With Vaadin 7 alpha 1, creation of fields and binding them to the data model has been separated from their layout. The new class FieldGroup manages binding of fields and optionally their creation, but does not add them to a layout. Instead, the user application can freely handle layouting of forms. This also makes it easy to e.g. use the visual editor to design a form layout and then simply ask FieldGroup to bind it. FieldGroup can also manage committing form contents etc.


Typed Properties and Fields, Conversions

In Vaadin 7 alpha 1, both Property and Field are parametrized with generics and only support the correct data types, e.g. a TextField always has the data type String. A more generic and customizable Converter mechanism replaces the limited constructor call based conversions that Vaadin 6 performed in some fields, properties and validators.

Each Field can have a converter that maps values between the field type and the underlying data type (often a data model type). Furthermore, formatting of the underlying data model types to Strings can be configured using Converters for columns of the Table component.

In most cases, a suitable converter is automatically selected when binding a data model to a Field - e.g. binding a Property to a TextField automatically configures a suitable converter for the values.


Validation

Validation is now performed on the data model type instead of the field type. Converters also act as implicit validators, checking that the data can be converted, so e.g. separate validators checking that the value of a TextField can be parsed as an integer are unnecessary.

Bean Validation (JSR-303) support has been integrated in Vaadin core in the form of BeanValidator. However, using it requires a JSR-303 implementation (e.g. Hibernate Validator or Apache Bean Validation) to be present on the project class path.


CustomField

The CustomField component is now included in Vaadin core and permits easy creation of fields with customized UI and logic. The UI created in the initContent() method of a custom field can get and set the field value as well as override other logic when necessary, and most of the required logic for fields is handled by CustomField.


Transactional commits of forms

Two-phase commits are supported using Property.Transactional and automatically handled by FieldGroup. This means that if committing the value of a field fails, the other related fields are automatically rolled back to their pre-commit values.

For short examples on how to use the new features, check out the Vaadin 7 minitutorials:
https://vaadin.com/wiki/-/wiki/Main/Vaadin+7

For information on how to migrate from Vaadin 6 to Vaadin 7, see
http://dev.vaadin.com/wiki/Vaadin7/MigrationGuide

This is an alpha release so we expect there to be bugs and still expect changes will be made to the API and functionality before the final 7.0.0 release. All your comments on the new features are welcome. Please post all Vaadin 7 related comments in the Vaadin 7 category of the forum.

Hi Artur,

are there any plans for integrated server push and improved thread safety?

Regards,
Philip

Better support for push add-ons and an integrated reference implementation are currently planned for alpha 3.

No plans concerning changes to the thread safety policy - background threads must synchronize to the application instance when touching Vaadin components or their containers. There has been talk about a “worker” mechanism that would simplify the simpler cases where background processing is needed, but it has not been targeted to any release at the moment if I remember correctly.