Binding between Vaadin 7 and 8

Hello,
In my Vaadin 7 project, I have something very like the below code ( note the simplicity of it ):

[code]
public class FakeClass {
protected final TextField description = new TextField(“Description”);
private final TextField revision = new TextField(“Revision”);
private final FormCheckBox consignment = new FormCheckBox(“Consignment”);
protected final ComboBox notificationPreference = new ComboBox(“Notification Preference”);

public FakeClass() {
    description.setNullRepresentation("");
    description.setReadOnly(true);
    description.setMaxLength(45);
    description.addStyleName("partDescription");

    revision.setNullRepresentation("");
    revision.setReadOnly(true);

   // Setup notificationPreference dropdown - not important to my question, so removed

  FormLayout form1 = new FormLayout();
  form1.addComponents( description, revision, notificationPreference, consignment );
}

public void setData( FakeBean data )
{
         fieldGroup = BeanFieldGroup.bindFieldsUnbuffered(data, this);
}

}
[/code]Most of the Vaadin 7 documentation for some reason uses a much more complex method, but this method was used a lit inf a demo program Vaadin provided, and it worked well for me, so I used it. Of special interest is that in the simplest case, the FormCheckBox, I only had to create the field, I did not have to do anything else to get it to bind to the corresponding value in data bean. From what I have seen of the Vaadin 8 documentation, it does not offer such simplicity, such a short solution for such a simple case. Am I missing something?

I have a LOT of code like this, so trying to see if I can simplify the conversion from Vaadin 7 to 8 somehow.

I think you are looking for

Binder

and specifically the method

binder.bindInstanceFields(this);

within it. It will automatically match the bean fields against the class fields, so if FakeBean has

getConsigment



()

and

setConsigment()

, it would be bound to

FormCheckBox



consigment

. You can see an example of this at
https://vaadin.com/docs/v8/framework/datamodel/datamodel-forms.html
under the topic
"Using Binder with Declarative Layouts "
. I know you are not using Declarative format but the same rules should apply still.

Ok, totally missed your post. Got side tracked by another project. Thanks so much for pointing that out. That will make converting to v8 a little easier in some cases for me. I have lots and lots of forms in my app, so the thought of doing all that manual work for such simple cases was not appealing. I guess I missed that in the documentation because it was at the bottom - did not scroll down far enough, or something like that.