From 1746dff124c644f4348ccf3ecf55d250a8869d75 Mon Sep 17 00:00:00 2001 From: Pekka Hyvönen Date: Mon, 5 Nov 2012 14:00:21 +0200 Subject: 10030 Button.DisableOnClick not working properly Change-Id: I0514bc4da186360a84d9cdb48140245108847115 --- server/src/com/vaadin/ui/Button.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'server/src/com') diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java index d248efd570..b4b7bf64be 100644 --- a/server/src/com/vaadin/ui/Button.java +++ b/server/src/com/vaadin/ui/Button.java @@ -19,6 +19,8 @@ package com.vaadin.ui; import java.io.Serializable; import java.lang.reflect.Method; +import org.json.JSONException; + import com.vaadin.event.Action; import com.vaadin.event.FieldEvents; import com.vaadin.event.FieldEvents.BlurEvent; @@ -55,10 +57,17 @@ public class Button extends AbstractComponent implements } @Override - public void disableOnClick() { - // Could be optimized so the button is not repainted because of - // this (client side has already disabled the button) + public void disableOnClick() throws RuntimeException { setEnabled(false); + // Makes sure the enabled=false state is noticed at once - otherwise + // a following setEnabled(true) call might have no effect. see + // ticket #10030 + try { + getUI().getConnectorTracker().getDiffState(Button.this) + .put("enabled", false); + } catch (JSONException e) { + throw new RuntimeException(e); + } } }; -- cgit v1.2.3