aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/test
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2019-12-02 11:08:01 +0200
committerAnna Koskinen <Ansku@users.noreply.github.com>2019-12-02 11:08:01 +0200
commit252ef116342a6b0363b48d157de33a932d44752f (patch)
treef774cbb0be756ee6cd38e5c02c5c6238f456e2f8 /server/src/test
parentdda9b052604967b8d8cfec5c20d06e72f6f78d33 (diff)
downloadvaadin-framework-252ef116342a6b0363b48d157de33a932d44752f.tar.gz
vaadin-framework-252ef116342a6b0363b48d157de33a932d44752f.zip
Make asRequired conditional on binding.setAsRequiredEnabled(..) (#11834)
It is a very common use case in complex form that whether a field is required or not, it depends on input on other fields. Hypothetical use case sample could be that we have form for a Product and price of the product is needed except in case the Product's type is Sample. So in that kind of scenarios it would be needed to turn off asRequired() validation easily. The purpose of this enhancement and new binding.setAsRequiredEnabled(..) API is to help implementation of this kind of use cases more easily. https://github.com/vaadin/framework/issues/10709
Diffstat (limited to 'server/src/test')
-rw-r--r--server/src/test/java/com/vaadin/data/BinderTest.java9
1 files changed, 6 insertions, 3 deletions
diff --git a/server/src/test/java/com/vaadin/data/BinderTest.java b/server/src/test/java/com/vaadin/data/BinderTest.java
index 401cc07017..b3fe5a8194 100644
--- a/server/src/test/java/com/vaadin/data/BinderTest.java
+++ b/server/src/test/java/com/vaadin/data/BinderTest.java
@@ -473,13 +473,13 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
TextField textField = new TextField();
assertFalse(textField.isRequiredIndicatorVisible());
- BindingBuilder<Person, String> binding = binder.forField(textField);
+ BindingBuilder<Person, String> bindingBuilder = binder.forField(textField);
assertFalse(textField.isRequiredIndicatorVisible());
- binding.asRequired("foobar");
+ bindingBuilder.asRequired("foobar");
assertTrue(textField.isRequiredIndicatorVisible());
- binding.bind(Person::getFirstName, Person::setFirstName);
+ Binding<Person, String> binding = bindingBuilder.bind(Person::getFirstName, Person::setFirstName);
binder.setBean(item);
assertNull(textField.getErrorMessage());
@@ -491,6 +491,9 @@ public class BinderTest extends BinderTestBase<Binder<Person>, Person> {
textField.setValue("value");
assertNull(textField.getErrorMessage());
assertTrue(textField.isRequiredIndicatorVisible());
+
+ binding.setAsRequiredEnabled(false);
+ assertFalse(textField.isRequiredIndicatorVisible());
}
@Test