CustomField on bean with collection - databinding & double buffering

Hi,
I am trying to edit bean with few attributes including collection of other beans. E.g.:

class TopBean {
String name;
List values;
}
class SubBean {
Date date;
Integer amount;
String description;
}

I am aware of the tutorial on https://vaadin.com/wiki/-/wiki/Main/Creating%20a%20custom%20field%20for%20editing%20the%20address%20of%20a%20person but that doesn’t cover encapsulated collections (which I guess should be mapped to Table) and doesn’t deal with buffering and events.

My idea was to create extension of CustomField but I am failing to do so. Please do you have a solution ot a hint how to edit such a structure ?

HI Jiri

I’m currently using the following classes to edit collection properties in models:

However, they are tied to JDAL that doesn’t use the Vaadin FieldGroup for data binding.
You could use them to get ideas or use directly wiht JDAL Views that support automatic binding too.

For example:

public class TopBeanView extends AbstractView<TopBean> {
    
    private TextField name = new TextField();
    @Resource
    private TableEditor<SubBean> values;

    
    @PostConstruct
    public void init() {
        autobind();
    }
    
    protected Component buildPanel() {
        BoxFormBuilder fb = new BoxFormBuilder();
        fb.setDefaultWidth(BoxFormBuilder.SIZE_FULL);
        
        fb.row();
        fb.add(name, getMessage("name"));
        fb.row(BoxFormBuilder.SIZE_FULL);
        fb.add(this.values, getMessage("values"));
        
        return fb.getForm();
    }

}

Will make the form that you are looking for (with a little configuration of spring context, required by JDAL).

The following figure shows a TableEditor used to editing Task in a Project model