diff options
5 files changed, 129 insertions, 0 deletions
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<Boolean> { 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<Float> 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<Double> { 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. diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderValueFromDataSource.html b/uitest/src/com/vaadin/tests/components/slider/SliderValueFromDataSource.html new file mode 100644 index 0000000000..8b5a7067e4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/slider/SliderValueFromDataSource.html @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head profile="http://selenium-ide.openqa.org/profiles/test-case"> +<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> +<link rel="selenium.base" href="http://localhost:8070/" /> +<title>SliderValueFromDataSource</title> +</head> +<body> +<table cellpadding="1" cellspacing="1" border="1"> +<thead> +<tr><td rowspan="1" colspan="3">SliderValueFromDataSource</td></tr> +</thead><tbody> +<tr> + <td>open</td> + <td>/run/SliderValueFromDataSource?restartApplication</td> + <td></td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runSliderValueFromDataSource::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[1]/VProgressIndicator[0]/domChild[0]/domChild[0]@style</td> + <td>regex:.*(width|WIDTH): 50%.*</td> +</tr> +<tr> + <td>assertAttribute</td> + <td>vaadin=runSliderValueFromDataSource::/VVerticalLayout[0]/Slot[1]/VVerticalLayout[0]/Slot[0]/VSlider[0]/domChild[2]/domChild[0]@style</td> + <td>regex:.*(margin-left|MARGIN-LEFT): 94px.*</td> +</tr> + +</tbody></table> +</body> +</html> diff --git a/uitest/src/com/vaadin/tests/components/slider/SliderValueFromDataSource.java b/uitest/src/com/vaadin/tests/components/slider/SliderValueFromDataSource.java new file mode 100644 index 0000000000..141dc5baf4 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/slider/SliderValueFromDataSource.java @@ -0,0 +1,59 @@ +package com.vaadin.tests.components.slider; + +import com.vaadin.data.Item; +import com.vaadin.data.util.BeanItem; +import com.vaadin.server.VaadinRequest; +import com.vaadin.tests.components.AbstractTestUI; +import com.vaadin.ui.ProgressIndicator; +import com.vaadin.ui.Slider; + +public class SliderValueFromDataSource extends AbstractTestUI { + + public static class TestBean { + + private double doubleValue = 10.0; + private float floatValue = 0.5f; + + public double getDoubleValue() { + return doubleValue; + } + + public void setDoubleValue(double doubleValue) { + this.doubleValue = doubleValue; + } + + public float getFloatValue() { + return floatValue; + } + + public void setFloatValue(float floatValue) { + this.floatValue = floatValue; + } + } + + @Override + protected void setup(VaadinRequest request) { + Item item = new BeanItem<TestBean>(new TestBean()); + + Slider slider = new Slider(0, 20); + slider.setWidth("200px"); + slider.setPropertyDataSource(item.getItemProperty("doubleValue")); + addComponent(slider); + + ProgressIndicator pi = new ProgressIndicator(); + pi.setPollingInterval(60 * 1000); + pi.setWidth("200px"); + pi.setPropertyDataSource(item.getItemProperty("floatValue")); + addComponent(pi); + } + + @Override + protected String getTestDescription() { + return "Slider and ProgressIndicator do not properly pass a value from data source to the client"; + } + + @Override + protected Integer getTicketNumber() { + return 10921; + } +} |