summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2014-12-18 18:01:37 +0200
committerVaadin Code Review <review@vaadin.com>2014-12-18 20:40:11 +0000
commit3f1295a9d540e223fe7cc2c39f84cf904df8b60b (patch)
tree9d31b84faa23cafd5b53f0e51ab9f69588f9c911 /server
parente1d84638ff22503d2fc8dd883802536770a21409 (diff)
downloadvaadin-framework-3f1295a9d540e223fe7cc2c39f84cf904df8b60b.tar.gz
vaadin-framework-3f1295a9d540e223fe7cc2c39f84cf904df8b60b.zip
Make is possible to click a detached button again (#12781)
Partial revert of the earlier fix Change-Id: I67d016f1ea073189fdb53fc99f7c1b45b21ac124
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/ui/Button.java2
-rw-r--r--server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java34
2 files changed, 19 insertions, 17 deletions
diff --git a/server/src/com/vaadin/ui/Button.java b/server/src/com/vaadin/ui/Button.java
index 677f29ba13..6beb6ed686 100644
--- a/server/src/com/vaadin/ui/Button.java
+++ b/server/src/com/vaadin/ui/Button.java
@@ -365,7 +365,7 @@ public class Button extends AbstractComponent implements
* No action is taken is the button is disabled.
*/
public void click() {
- if (isConnectorEnabled() && !isReadOnly()) {
+ if (isEnabled() && !isReadOnly()) {
fireClick();
}
}
diff --git a/server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java b/server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java
index b41e93900f..3d5fe77f8e 100644
--- a/server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java
+++ b/server/tests/src/com/vaadin/tests/server/component/button/ButtonClick.java
@@ -3,9 +3,11 @@ package com.vaadin.tests.server.component.button;
import org.junit.Assert;
import org.junit.Test;
+import com.vaadin.data.util.ObjectProperty;
import com.vaadin.server.VaadinRequest;
import com.vaadin.ui.Button;
import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
import com.vaadin.ui.UI;
/**
@@ -15,6 +17,22 @@ public class ButtonClick {
private boolean clicked = false;
@Test
+ public void clickDetachedButton() {
+ Button b = new Button();
+ final ObjectProperty<Integer> counter = new ObjectProperty<Integer>(0);
+ b.addClickListener(new ClickListener() {
+
+ @Override
+ public void buttonClick(ClickEvent event) {
+ counter.setValue(counter.getValue() + 1);
+ }
+ });
+
+ b.click();
+ Assert.assertEquals(Integer.valueOf(1), counter.getValue());
+ }
+
+ @Test
public void testClick() {
getButton().click();
Assert.assertTrue("Button doesn't fire clicks", clicked);
@@ -36,22 +54,6 @@ public class ButtonClick {
Assert.assertFalse("Read only button fires click events", clicked);
}
- @Test
- public void testClickConnectorDisabled() {
- Button b = new Button() {
- @Override
- public boolean isConnectorEnabled() {
- return false;
- }
- };
- UI ui = createUI();
- b.setParent(ui);
- addClickListener(b);
- b.click();
- Assert.assertFalse("Button with disabled connector fires click events",
- clicked);
- }
-
private Button getButton() {
Button b = new Button();
UI ui = createUI();