Vaadin 8 Binding reload value from Bean

Version: 8.0.0.beta1

I want to reload a value of a field that is linked with a binder to a bean.
If i use binder.readBean(bean)
then this method is invoked for each binding:

private void initFieldValue(BEAN bean) { assert bean != null; assert onValueChange != null; onValueChange.remove(); try { getField().setValue(convertDataToFieldType(bean)); } finally { onValueChange = getField() .addValueChangeListener(this::handleFieldValueChange); } } Problem here is that the valueChangeListener that links the value of the field to the bean is first removed and then added again. Thus the order of the valueChangeListeners is changed.

I would like to see a method in the binding interface that just calls

getField().setValue(convertDataToFieldType(getBinder().getBean())); FYI: I use a workaround that calls this methods by reflection

Vaadin 8.4.1: still no method to reload values from Bean so I extended Binder and added method:

public void refreshFromBean() {
	BEAN bean = getBean();
	if (bean != null) {
		getBindings().forEach(binding -> binding.read(bean));
	}
}
  • at least in this Vaadin version they added binding.read(bean) so no reflection is needed

binding.read(bean) seams to work. Thanks