aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2021-03-18 18:12:37 +0200
committerGitHub <noreply@github.com>2021-03-18 18:12:37 +0200
commit01c72e9e6c0678980bc39112f4b97454de6916c7 (patch)
tree535e5f7f01b48a0e3a3befe0eeaa2b18824b2917 /server/src/test
parent49ea04a13c0d9a19c1d9ca041ff34574f910bb67 (diff)
downloadvaadin-framework-01c72e9e6c0678980bc39112f4b97454de6916c7.tar.gz
vaadin-framework-01c72e9e6c0678980bc39112f4b97454de6916c7.zip
feat: Add API to control whether Binder converts back to presentation (#12246)
#12132 fixed an old bug, conversion was not done back, which was a regression from Vaadin 7. However since the bug has been present long time, it has become established behavior, thus there may be need to disable conversion back to presentation sometimes, thus this API as added.
Diffstat (limited to 'server/src/test')
-rw-r--r--server/src/test/java/com/vaadin/data/BinderTest.java15
1 files changed, 15 insertions, 0 deletions
diff --git a/server/src/test/java/com/vaadin/data/BinderTest.java b/server/src/test/java/com/vaadin/data/BinderTest.java
index 0332572203..98f72e1197 100644
--- a/server/src/test/java/com/vaadin/data/BinderTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderTest.java
@@ -518,6 +518,21 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
}
@Test
+ public void withConverter_writeBackValueDisabled() {
+ TextField rentField = new TextField();
+ rentField.setValue("");
+ Binding<Person, BigDecimal> binding = binder.forField(rentField)
+ .withConverter(new EuroConverter(""))
+ .withNullRepresentation(BigDecimal.valueOf(0d))
+ .bind(Person::getRent, Person::setRent);
+ binder.setBean(item);
+ binding.setConvertBackToPresentation(false);
+ rentField.setValue("10");
+
+ assertNotEquals("€ 10.00", rentField.getValue());
+ }
+
+ @Test
public void beanBinder_nullRepresentationIsNotDisabled() {
Binder<Person> binder = new Binder<>(Person.class);
binder.forField(nameField).bind("firstName");