summaryrefslogtreecommitdiffstats
path: root/server/src/com
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-09-24 17:56:36 +0300
committerVaadin Code Review <review@vaadin.com>2014-09-26 12:40:14 +0000
commit99b1c1a7936f250885e647983d7e30fd3a7f1018 (patch)
tree51141abb0ed9c1dbca20b31702ab014a559a377e /server/src/com
parentd516791e28e861893fb5082472a1c0ca59f0dfd7 (diff)
downloadvaadin-framework-99b1c1a7936f250885e647983d7e30fd3a7f1018.tar.gz
vaadin-framework-99b1c1a7936f250885e647983d7e30fd3a7f1018.zip
Add clear() for fields and field group (#14755)
Change-Id: If9372ccceeaacd0826f8b1ed07f64af12bf47fc6
Diffstat (limited to 'server/src/com')
-rw-r--r--server/src/com/vaadin/data/fieldgroup/FieldGroup.java15
-rw-r--r--server/src/com/vaadin/ui/AbstractField.java13
-rw-r--r--server/src/com/vaadin/ui/Form.java15
3 files changed, 43 insertions, 0 deletions
diff --git a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
index e647bdbf6d..2873d07c5d 100644
--- a/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
+++ b/server/src/com/vaadin/data/fieldgroup/FieldGroup.java
@@ -28,6 +28,7 @@ import com.vaadin.data.Item;
import com.vaadin.data.Property;
import com.vaadin.data.Validator.InvalidValueException;
import com.vaadin.data.util.TransactionalPropertyWrapper;
+import com.vaadin.ui.AbstractField;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
@@ -1095,4 +1096,18 @@ public class FieldGroup implements Serializable {
}
return memberFieldInOrder;
}
+
+ /**
+ * Clears the value of all fields.
+ *
+ * @since
+ */
+ public void clear() {
+ for (Field<?> f : getFields()) {
+ if (f instanceof AbstractField) {
+ ((AbstractField) f).clear();
+ }
+ }
+
+ }
}
diff --git a/server/src/com/vaadin/ui/AbstractField.java b/server/src/com/vaadin/ui/AbstractField.java
index bb70c0c57b..369ad1253c 100644
--- a/server/src/com/vaadin/ui/AbstractField.java
+++ b/server/src/com/vaadin/ui/AbstractField.java
@@ -1513,6 +1513,19 @@ public abstract class AbstractField<T> extends AbstractComponent implements
}
/**
+ * Clear the value of the field.
+ * <p>
+ * The field value is typically reset to the initial value of the field but
+ * this is not mandatory. Calling {@link #isEmpty()} on a cleared field must
+ * always returns true.
+ *
+ * @since
+ */
+ public void clear() {
+ setValue(null);
+ }
+
+ /**
* Is automatic, visible validation enabled?
*
* If automatic validation is enabled, any validators connected to this
diff --git a/server/src/com/vaadin/ui/Form.java b/server/src/com/vaadin/ui/Form.java
index 391ee45536..7b0c49ec95 100644
--- a/server/src/com/vaadin/ui/Form.java
+++ b/server/src/com/vaadin/ui/Form.java
@@ -1202,6 +1202,21 @@ public class Form extends AbstractField<Object> implements Item.Editor,
return true;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see com.vaadin.ui.AbstractField#clear()
+ */
+ @Override
+ public void clear() {
+ for (Iterator<Field<?>> i = fields.values().iterator(); i.hasNext();) {
+ Field<?> f = i.next();
+ if (f instanceof AbstractField) {
+ ((AbstractField<?>) f).clear();
+ }
+ }
+ }
+
/**
* Adding validators directly to form is not supported.
*