Java Database Application Library

Get JDAL (Java Database Application Library) at Fast, secure and Free Open Source software downloads



AbstractView is the principal template ( Template , GoF) of JDAL for dealing with forms.

AbstractView permits you condense the development work of forms in one unique job: Implement the method buildPanel().

AbstractView supports the automatic way of the following commune jobs in the development of Vaadin forms:

The process of building a form based on Abstractview can be summarised in the following steps:

Data Binding

JDAL binding is based on JDAL core library and do not use the new Vaadin 7 FieldGroups.

AbstractView supports at the moment two forms of realizing the binding of data between user interface controls and the domain models:

In both cases, in creating binding between a Vaadin component and a property of the model, it will undertake the following actions:

Finally, AbstractView provides three template methods to customize the data binding process:


AbstractView delegates much of the work in strategies or support classes of JDAL. It is interesting to take a look as you might be interested in using them directly o personalising the behaviours.


Performs all work in data binding between the conttols and models. It can be used independently outside of AbstractView. It is not necessary to extend JDAL classes to dispose of data binding system. You can find more information in the data binding chapter..


Processing strategy of binding errors. The implementation by default, BackgroundErrorProcessor changes the colour of the background of the controls that have failed and add a tooltip with the information of the error.


PropertyBinder factory, CompositeBinder uses it to find the Binder appropriate for each type of control.


Allow access to generic Swing controls. That is to say, perform control operations without the specific knowledge of the type of control.


Strategy of control initialization, usually with data from the respositories or other entities. The implementatión by default DefaultControlInitializer is able to detect annotationes JPA and the annotation @Reference of JDAL Core.



We will create a View for the following Book entity:

public class Book implements Serializable {
	private Long id;
	private String name = "";
	private Author author;
	private Category category;
	private String isbn = "";
	private Date publishedDate;
	public String toString() {
		return name;
	// Getters and Setters


The target objective is to create a form to edit books with data binding, internacionalization and validation of the backing model

The following is the code of the book editor form using AbstracView

public class BookView extends AbstractView<Book> {
	// We use autobind jdal feature, name the controls like Book properties
	private TextField name = new TextField();
	private TextField isbn = new TextField();
	@Property(name="publishedDate") // map to publishedDate model property (the default)
	private DateField publishedDate = new DateField();
	@Initializer(orderBy="name")    // autofill with authors, sorted by name
	private ComboBox author = new ComboBox();
	@Initializer(orderBy="name")   // autofill with categories, sorted by name
	private ComboBox category = new ComboBox();
	public BookView() {
		this(new Book());
	public BookView(Book model) {
	public void init()  {
		// Just our binding code!
	protected Component buildPanel() {
		BoxFormBuilder fb = new BoxFormBuilder();
		fb.add(name, getMessage("Book.title"));
		fb.add(author, getMessage(""));
		fb.add(category, getMessage("Book.category"));
		fb.add(isbn, getMessage("Book.isbn"));
		fb.add(publishedDate, getMessage("Book.publishedDate"), 120);
		return fb.getForm();
	 // The view name is shown as title on ViewDialog.
	public String getName() { 
		Book model = getModel();
		if (model != null && model.getId() != null) {
			return model.getName();
		return null;

Context Configuration

The book editor looks simple, but need some spring configuration to work. the most important is the abstract view bean definition that inject the validator, error processor and control initializer to views. Instead declaring all views in context bean definition files, we could use the JDAL @Parent annotation to inherit xml abstract bean definition when using the Spring auto scan packages for beans feature.
   <!-- Register default Vaadin components -->
   <vaadin:defaults />
   <!-- Vaadin scoped beans are linked to UI class instances, Use with care, is still a beta component. -->
   <bean id="vaadinScopeConfigurer" class="org.springframework.beans.factory.config.CustomScopeConfigurer">
       <property name="scopes">
                <entry key="ui" value="org.jdal.vaadin.beans.VaadinScope" />
   <!-- Abstract definition for Views -->
   <bean id="view" abstract="true">
        <property name="controlInitializer" ref="controlInitializer"/>
        <property name="errorProcessors">
                   <ref bean="errorProcessor" />
        <property name="validator" ref="validator" />
   <!-- Default control initializer -->
   <bean id="controlInitializer" class="org.jdal.vaadin.ui.bind.VaadinControlInitializer">
        <property name="persistentService" ref="contextPersistentService" />
    <!-- Spring JSR-303 validator -->
   <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
       <jdal:serializable-proxy />
   <!-- Error Processor -->
   <bean id="errorProcessor" class="org.jdal.vaadin.ui.bind.UserErrorProcessor" />  
   <!-- View Dialog Prototype -->
   <bean id="viewDialog" class="org.jdal.vaadin.ui.form.ViewDialog" scope="prototype"/>
   <!-- Book Form Editor -->
   <bean id="bookEditor" class="org.jdal.samples.vaadin.BookView" parent="view" scope="prototype" >
        <property name="width" value="600" />
        <property name="height" value="300" />
        <property name="persistentService" ref="bookService" />
   <!-- Book DAO -->
   <jdal:service entity="org.jdal.samples.model.Book" />

Now, we can get instances of the project editor by the bean "bookEditor".

For a full sample application see vaadin-sample-jpa.