summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2015-05-15 22:02:17 +0300
committerVaadin Code Review <review@vaadin.com>2015-05-18 06:41:32 +0000
commitb9a6402e45d50b0bb265e4b138dc5677c9463af4 (patch)
tree8dabd08d9d67f4d8112866e7a830f727ecfcfbf9 /server
parentc7392301d0c6afde429d7c6e66d3175f36ab5360 (diff)
downloadvaadin-framework-b9a6402e45d50b0bb265e4b138dc5677c9463af4.tar.gz
vaadin-framework-b9a6402e45d50b0bb265e4b138dc5677c9463af4.zip
Fix clear/isEmpty in TextArea/PasswordField/RichTextArea/ProgressBar (#17089)
Change-Id: Ic793cbb7eb36408c765a01cc987ba7fe8800b80c
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/PasswordField.java6
-rw-r--r--server/src/com/vaadin/ui/ProgressBar.java15
-rw-r--r--server/src/com/vaadin/ui/RichTextArea.java5
-rw-r--r--server/src/com/vaadin/ui/TextArea.java6
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/FieldDefaultValues.java11
5 files changed, 31 insertions, 12 deletions
diff --git a/server/src/com/vaadin/ui/PasswordField.java b/server/src/com/vaadin/ui/PasswordField.java
index 1894804775..ff3b1fea1f 100644
--- a/server/src/com/vaadin/ui/PasswordField.java
+++ b/server/src/com/vaadin/ui/PasswordField.java
@@ -113,4 +113,10 @@ public class PasswordField extends AbstractTextField {
DesignAttributeHandler.writeAttribute("value", attr, getValue(),
def.getValue(), String.class);
}
+
+ @Override
+ public void clear() {
+ setValue("");
+ }
+
}
diff --git a/server/src/com/vaadin/ui/ProgressBar.java b/server/src/com/vaadin/ui/ProgressBar.java
index c288695ae1..89baac1e64 100644
--- a/server/src/com/vaadin/ui/ProgressBar.java
+++ b/server/src/com/vaadin/ui/ProgressBar.java
@@ -37,11 +37,13 @@ import com.vaadin.ui.declarative.DesignContext;
public class ProgressBar extends AbstractField<Float> implements
Property.Viewer, Property.ValueChangeListener {
+ private static final float DEFAULT_VALUE = 0f;
+
/**
* Creates a new progress bar initially set to 0% progress.
*/
public ProgressBar() {
- this(0);
+ this(DEFAULT_VALUE);
}
/**
@@ -170,4 +172,15 @@ public class ProgressBar extends AbstractField<Float> implements
DesignAttributeHandler.writeAttribute("value", design.attributes(),
getValue(), defaultValue, Float.class);
}
+
+ @Override
+ public void clear() {
+ setValue(DEFAULT_VALUE);
+ }
+
+ @Override
+ public boolean isEmpty() {
+ return super.isEmpty() || getValue() == DEFAULT_VALUE;
+
+ }
}
diff --git a/server/src/com/vaadin/ui/RichTextArea.java b/server/src/com/vaadin/ui/RichTextArea.java
index 763e42ad8b..7c23cce5cb 100644
--- a/server/src/com/vaadin/ui/RichTextArea.java
+++ b/server/src/com/vaadin/ui/RichTextArea.java
@@ -293,6 +293,11 @@ public class RichTextArea extends AbstractField<String> implements
}
@Override
+ public void clear() {
+ setValue("");
+ }
+
+ @Override
public void readDesign(Element design, DesignContext designContext) {
super.readDesign(design, designContext);
setValue(design.html());
diff --git a/server/src/com/vaadin/ui/TextArea.java b/server/src/com/vaadin/ui/TextArea.java
index c8103f9c5b..b4dfb209e8 100644
--- a/server/src/com/vaadin/ui/TextArea.java
+++ b/server/src/com/vaadin/ui/TextArea.java
@@ -159,4 +159,10 @@ public class TextArea extends AbstractTextField {
super.writeDesign(design, designContext);
design.html(getValue());
}
+
+ @Override
+ public void clear() {
+ setValue("");
+ }
+
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/FieldDefaultValues.java b/server/tests/src/com/vaadin/tests/server/component/FieldDefaultValues.java
index 5c9993e6dd..16bbd7008f 100644
--- a/server/tests/src/com/vaadin/tests/server/component/FieldDefaultValues.java
+++ b/server/tests/src/com/vaadin/tests/server/component/FieldDefaultValues.java
@@ -23,11 +23,7 @@ import org.junit.Test;
import com.vaadin.tests.VaadinClasses;
import com.vaadin.ui.Field;
-import com.vaadin.ui.PasswordField;
-import com.vaadin.ui.ProgressBar;
-import com.vaadin.ui.RichTextArea;
import com.vaadin.ui.Slider;
-import com.vaadin.ui.TextArea;
public class FieldDefaultValues {
@@ -36,13 +32,6 @@ public class FieldDefaultValues {
for (Field<?> field : createFields()) {
Object originalValue = field.getValue();
- // Some fields are not initialized to the "empty" value. #17089
- if (field instanceof PasswordField || field instanceof ProgressBar
- || field instanceof RichTextArea
- || field instanceof TextArea) {
- originalValue = null;
- }
-
field.clear();
Object clearedValue = field.getValue();