Vaadin 8 / CustomField / Binder issue

Hello,

There is a custom field. The custom field has a combo box. The combo box has some items type of
MyItemBean
. The value of the custom field is set in the combo box’s value change listener by
.setValue(…)
as below.


Item Bean
:

[code]
public class MyItemBean {

...
private String valueA;
...


public MyItemBean() {}


...
public String getValueA() { return this.valueA; }
public void setValueA(String value) { this.valueA = value; }
...

}
[/code]
CustomField
:

[code]
public class MyCustomField extends CustomField {

...
private final ComboBox<MyItemBean> myComboBox = new ComboBox<>();
...


public MyCustomField() { ... }


private void myComboBoxValueChangeListener(ValueChangeEvent<MyItemBean> event) {
    this.setValue(event.getValue().getValueA(), event.isUserOriginated());
}

@override
protected component initContent() {
    
    ...
    this.myComboBox.addValueChangeListener(this::myComboBoxValueChangeListener);
    ...

}

}
[/code]The custom field is placed in a detail window (simply master / detail approach) and bound to a bean type of
MyDetailBean
by
Binder
as below.


Detail Bean
:

[code]
public class MyDetailBean {

...
private String detailA;
...


public MyDetailBean() {}


...
public String getDetailA() { return this.detailA; }
public void setDetailA(String value) { this.detailA = value; }
...

}
[/code]
Detail window
:

[code]
public class Detail extends Window {

...
private final Binder<MyDetailBean> binder = new Binder<>();
private final MyCustomField myCustomField = new MyCustomField();
...


public Detail() {
    ...
    this.binder.bind(this.myCustomField, MyDetailBean::getDetailA(), MyDetailBean::setDetailA());
    ...
}

...

}
[/code]Expected behavior is
MyDetailBean
should be updated when user selects another item in the custom field but the binder doesn’t notice the value change in the custom field.

The detail window has some other elements like text fields, check boxes, etc. All Vaadin elements updates the detail bean immediately but the custom field doesn’t.

How can I solve this issue?

Thank you…

Hi, I have the same issue. Any idea how to solve this?
Thanks!

You need to overwrite the addValueChangeListener() method. Because the binder itself adds a value change listener to get informed about value changes.