summaryrefslogtreecommitdiffstats
path: root/uitest/src/com/vaadin/tests/tickets/Ticket2179.java
diff options
context:
space:
mode:
Diffstat (limited to 'uitest/src/com/vaadin/tests/tickets/Ticket2179.java')
-rw-r--r--uitest/src/com/vaadin/tests/tickets/Ticket2179.java54
1 files changed, 54 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/tickets/Ticket2179.java b/uitest/src/com/vaadin/tests/tickets/Ticket2179.java
new file mode 100644
index 0000000000..622488dc0f
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/tickets/Ticket2179.java
@@ -0,0 +1,54 @@
+package com.vaadin.tests.tickets;
+
+import com.vaadin.Application;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Validator;
+import com.vaadin.ui.UI.LegacyWindow;
+import com.vaadin.ui.TextField;
+
+public class Ticket2179 extends Application.LegacyApplication {
+
+ TextField f = new TextField("Test fiel ( must contain 1 & 2 )");
+ LegacyWindow main = new LegacyWindow("Dual validator test");
+
+ @Override
+ public void init() {
+
+ f.setImmediate(true);
+ f.setRequired(true);
+ f.addValidator(new ContainsValidator("1"));
+ f.addValidator(new ContainsValidator("2"));
+
+ setMainWindow(main);
+ main.addComponent(f);
+
+ f.addListener(new Property.ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ main.showNotification("Test field is "
+ + (f.isValid() ? "valid" : "invalid"));
+ }
+ });
+
+ }
+
+ static class ContainsValidator implements Validator {
+ private final String c;
+
+ public ContainsValidator(String c) {
+ this.c = c;
+ }
+
+ @Override
+ public void validate(Object value) throws InvalidValueException {
+ if (value == null || !value.toString().contains(c)) {
+ throw new InvalidValueException("Value does not contain " + c);
+ }
+
+ }
+
+ }
+
+}