* 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
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);
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;
+ }
}
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.
--- /dev/null
+<?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>
--- /dev/null
+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;
+ }
+}