Directory

PreCreatedFieldsHelper - Vaadin Add-on Directory

No more excuses to do data binding manually - build your form layouts as you wish! PreCreatedFieldsHelper - Vaadin Add-on Directory
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. WHAT IS "PRE CREATED FIELDS PATTERN" 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)
Author Homepage
Source Code
Demo/test source using visually created layout for a form

PreCreatedFieldsHelper version 1.0.0
null

PreCreatedFieldsHelper version 2.0.0
Added annotation based mapping support