From 6291a5080e2a6d2f0c5a955e5cf9ae984763a5aa Mon Sep 17 00:00:00 2001 From: Risto Yrjänä Date: Fri, 28 Jun 2013 15:53:03 +0300 Subject: Ensure that Slider diffstate always contains "value" (#12133) Force diff state to contain "value", so that value changes from value change listeners work. Change-Id: I5b2c661f1297ec0272c150a5a9ff4ca26f19fefe --- server/src/com/vaadin/ui/Slider.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'server') diff --git a/server/src/com/vaadin/ui/Slider.java b/server/src/com/vaadin/ui/Slider.java index e63fdc5e10..44fc49ba9b 100644 --- a/server/src/com/vaadin/ui/Slider.java +++ b/server/src/com/vaadin/ui/Slider.java @@ -16,6 +16,8 @@ package com.vaadin.ui; +import org.json.JSONException; + import com.vaadin.shared.ui.slider.SliderOrientation; import com.vaadin.shared.ui.slider.SliderServerRpc; import com.vaadin.shared.ui.slider.SliderState; @@ -32,6 +34,21 @@ public class Slider extends AbstractField { @Override public void valueChanged(double value) { + /* + * Client side updates the state before sending the event so we need + * to make sure the cached state is updated to match the client. If + * we do not do this, a reverting setValue() call in a listener will + * not cause the new state to be sent to the client. + * + * See #12133. + */ + try { + getUI().getConnectorTracker().getDiffState(Slider.this) + .put("value", value); + } catch (JSONException e) { + throw new RuntimeException(e); + } + try { setValue(value, true); } catch (final ValueOutOfBoundsException e) { -- cgit v1.2.3