From c4a0bc318ec9c6b41d652e7020ee39784cc1eb10 Mon Sep 17 00:00:00 2001 From: Johannes Dahlström Date: Mon, 11 Feb 2013 17:04:15 +0200 Subject: Properly pass the AbstractField internal value to shared state in Slider and ProgressIndicator (#10921) * In case of a null value, 0 is stored to shared state. This is consistent with how CheckBox is already implemented. * This somewhat hacky solution should be replaced with a better one once AbstractField itself is migrated. See #11064. Change-Id: I2b313af8491a6deccdc7a509dcd1b718482cdcd4 --- server/src/com/vaadin/ui/CheckBox.java | 7 +++++++ server/src/com/vaadin/ui/ProgressIndicator.java | 15 +++++++++++++++ server/src/com/vaadin/ui/Slider.java | 16 ++++++++++++++++ 3 files changed, 38 insertions(+) (limited to 'server/src') diff --git a/server/src/com/vaadin/ui/CheckBox.java b/server/src/com/vaadin/ui/CheckBox.java index 22b90b224f..0ace0a4f26 100644 --- a/server/src/com/vaadin/ui/CheckBox.java +++ b/server/src/com/vaadin/ui/CheckBox.java @@ -110,6 +110,13 @@ public class CheckBox extends AbstractField { return (CheckBoxState) super.getState(); } + /* + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. + * + * See tickets #10921 and #11064. + */ @Override protected void setInternalValue(Boolean newValue) { super.setInternalValue(newValue); diff --git a/server/src/com/vaadin/ui/ProgressIndicator.java b/server/src/com/vaadin/ui/ProgressIndicator.java index 96c2d2814a..c481aa1e8f 100644 --- a/server/src/com/vaadin/ui/ProgressIndicator.java +++ b/server/src/com/vaadin/ui/ProgressIndicator.java @@ -157,4 +157,19 @@ public class ProgressIndicator extends AbstractField implements return getState().pollingInterval; } + /* + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. + * + * See tickets #10921 and #11064. + */ + @Override + protected void setInternalValue(Float newValue) { + super.setInternalValue(newValue); + if (newValue == null) { + newValue = 0.0f; + } + getState().state = newValue; + } } diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index 2bf05f895c..e63fdc5e10 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -263,6 +263,22 @@ public class Slider extends AbstractField { getState().value = newFieldValue; } + /* + * Overridden to keep the shared state in sync with the AbstractField + * internal value. Should be removed once AbstractField is refactored to use + * shared state. + * + * See tickets #10921 and #11064. + */ + @Override + protected void setInternalValue(Double newValue) { + super.setInternalValue(newValue); + if (newValue == null) { + newValue = 0.0; + } + getState().value = newValue; + } + /** * Thrown when the value of the slider is about to be set to a value that is * outside the valid range of the slider. -- cgit v1.2.3