Hi, I’m not aware of any “setEntity” method in Vaadin Framework’s API. Sounds like just a helper method coded in the examples themselves to encapsulate some logic related to data binding. But I don’t really know what examples are you talking about. Maybe if you post the links to the docs you are refering to, I could have a look at them.
use BeanFieldGroup
final BeanFieldGroup binder = new BeanFieldGroup(beanclass);
binder.setItemDataSource(new BeanItem(bean));
binder.bindMemberFields(frmUser);
so what is the difference between 1, 2, 3, 4 ?
also, how to deal with forms created with designer, I can’t add @PropertyId for the fields in the form.
Shall I inherit a class and annotate the getters?
Ok, thanks. That
setEntity method is defined in the Viritin add-on which I have no experience with. As a short anwser I’d say that the different ways are just convenient APIs on top of the
Vaadin Data Model which is based on Properties, Items, and Containers. So, if you study and understand the model it should help you to understand when to use each aproach.
Alejandro, you really should get some experience with Viritin as well. Seriously.
AbstractForm in Viritin (the “setEntity” option) uses an enhanced BeanFieldGroup behind the scenes. This way you don’t need to “think in Container-Item-Property” at all, but just bind your entities/beans to your UI components. The closest thing with “vanilla Vaadin” is:
BeanFieldGroup.bindFieldsUnbuffered(bean, objectWithMemberFields);
This is most of the time the thing you wan to do, instead of manually wrapping your beans into BeanItems or using FieldGroup directly. It is really rare situation when using Item/Property API brings any value for you, infact, I don’t even remember when I would have used them in my real world Vaadin apps.
Hi Matti! BeanFieldGroup.bindFieldsUnbuffered(bean, objectWithMemberFields), bind Entity to Form and the opposite? How to bind Form to Entity, is there a command like bindFieldsUnbuffered?