if (bean == null) {
clearFields();
} else {
- changedBindings.clear();
getBindings().forEach(binding -> {
// Some bindings may have been removed from binder
// during readBean. We should skip those bindings to
binding.initFieldValue(bean, false);
}
});
+ changedBindings.clear();
getValidationStatusHandler().statusChange(
BinderValidationStatus.createUnresolvedStatus(this));
fireStatusChangeEvent(false);
assertEquals(new Double(2000), item.getSalaryDouble());
}
+ // See: https://github.com/vaadin/framework/issues/9581
+ @Test
+ public void withConverter_hasChangesFalse() {
+ TextField nameField = new TextField();
+ nameField.setValue("");
+ TextField rentField = new TextField();
+ rentField.setValue("");
+ rentField.addValueChangeListener(event -> {
+ nameField.setValue("Name");
+ });
+ item.setRent(BigDecimal.valueOf(10));
+ binder.forField(nameField).bind(Person::getFirstName, Person::setFirstName);
+ binder.forField(rentField).withConverter(new EuroConverter(""))
+ .withNullRepresentation(BigDecimal.valueOf(0d))
+ .bind(Person::getRent, Person::setRent);
+ binder.readBean(item);
+
+ assertFalse(binder.hasChanges());
+ assertEquals("€ 10.00", rentField.getValue());
+ assertEquals("Name", nameField.getValue());
+ }
+
private TextField createNullAnd42RejectingFieldWithEmptyValue(
String emptyValue) {
return new TextField() {