PreCreatedFieldsHelper | Vaadin

No more excuses to do data binding manually - build your form layouts as you wish!

NOTE, this add-on was renamed to FormBinder. This add-on will no longer be updated.

This add-on contains a helper class and a custom form implementation to ease using pre created fields pattern. Customizing form layout and setting fields settings has never been easier. Forms can e.g. be designed with Vaadin Visual Editor and they can still take all advantages of the Form component.


Normally when using Vaadin forms, fields are created for item's properties on demand. The task of creating fields for properties is delegated to a FormFieldFactory. These fields are then added to the Form's layout and form binds properties automatically to them. This approach is usually fine and thanks to customizable FormFieldFactory and layout, form can be customized quite a lot.

In practice things may get rather messy and complex if the the layout becomes multilevel or it is e.g. designed with Vaadin Visual Editor. Lots of custom logic is needed to overridden attachField/detachField methods etc.

In pre created fields pattern responsibilities of field factory is narrowed. Instead of creating new fields for requested properties, its job is only to connect properties to existing fields (created manually by developer) in the form (or its layout).

With pre created fields pattern the Form also needs some minor changes: it must be modified to avoid attaching and detaching fields automatically as the developer has already attached them to their appropriate location in the layout. Form changes are practically replacing attachField and detachField implementations with empty methods.

WHAT DOES PreCreatedFieldsForm/PreCreatedFieldsHelper DO

Pre created fields pattern is rather simple to implement manually. The field factory however normally needs a considerable amount of boilerplate code to work. PreCreatedFieldsHelper can be used to avoid this boilerplate code by using simple naming convention and some java reflect magic.

Practically PreCreatedFieldsHelper is a FormFieldFactory that connects properties to corresponding fields from "target" classes (most often subclasses of form/layouts or composites built with Vaadin Visualdesigner). The connecting is done based on Fields name (java fieldname). The helper class can be used as is or behind the scenes by using PreCreatedFieldsForm.

Contributors (in addition to original author): Eduardo Frazão (annotation based field mapping)


Link to this version
BetaReleased 19 September 2011Apache License 2.0
Framework Support
Vaadin 6.0+
Browser Independent
Install with
Release notes - Version 2.0.0

Added annotation based mapping support