summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java3
-rw-r--r--shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java2
-rw-r--r--uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediate.java62
-rw-r--r--uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediateTest.java53
-rw-r--r--uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java10
5 files changed, 130 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
index 63984ff225..9e689f3314 100644
--- a/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
+++ b/client/src/com/vaadin/client/ui/checkbox/CheckBoxConnector.java
@@ -158,6 +158,9 @@ public class CheckBoxConnector extends AbstractFieldConnector implements
.getElement());
getRpcProxy(CheckBoxServerRpc.class).setChecked(getState().checked,
details);
+ if (getState().immediate) {
+ getConnection().sendPendingVariableChanges();
+ }
}
}
}
diff --git a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java
index 0041da4dfa..f4124100e0 100644
--- a/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java
+++ b/shared/src/com/vaadin/shared/ui/checkbox/CheckBoxServerRpc.java
@@ -16,8 +16,10 @@
package com.vaadin.shared.ui.checkbox;
import com.vaadin.shared.MouseEventDetails;
+import com.vaadin.shared.annotations.Delayed;
import com.vaadin.shared.communication.ServerRpc;
public interface CheckBoxServerRpc extends ServerRpc {
+ @Delayed
public void setChecked(boolean checked, MouseEventDetails mouseEventDetails);
}
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediate.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediate.java
new file mode 100644
index 0000000000..fec753d5af
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediate.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.checkbox;
+
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.CheckBox;
+import com.vaadin.ui.Label;
+
+public class CheckBoxImmediate extends AbstractTestUI {
+ private int count = 0;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ final Label status = new Label("Events received: " + count);
+ status.setId("count");
+ addComponent(status);
+
+ CheckBox cb = new CheckBox("Non-immediate");
+ ValueChangeListener listener = new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ count++;
+ status.setValue("Events received: " + count);
+ }
+ };
+ cb.addValueChangeListener(listener);
+ cb.setImmediate(false);
+ addComponent(cb);
+
+ cb = new CheckBox("Immediate");
+ cb.addValueChangeListener(listener);
+ cb.setImmediate(true);
+ addComponent(cb);
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Test for verifying that a non-immediate CheckBox does not send value change to server immediately.";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 18102;
+ }
+
+}
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediateTest.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediateTest.java
new file mode 100644
index 0000000000..826b43b9cc
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxImmediateTest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2000-2014 Vaadin Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.vaadin.tests.components.checkbox;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.openqa.selenium.By;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.elements.CheckBoxElement;
+import com.vaadin.testbench.elements.LabelElement;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class CheckBoxImmediateTest extends MultiBrowserTest {
+
+ @Test
+ public void testNonImmediateCheckBox() {
+ openTestURL();
+
+ CheckBoxElement checkBoxElement = $(CheckBoxElement.class).first();
+ WebElement inputElem = checkBoxElement.findElement(By.tagName("input"));
+ final WebElement countElem = $(LabelElement.class).id("count");
+
+ inputElem.click();
+ assertEquals("Events received: 0", countElem.getText());
+ }
+
+ @Test
+ public void testImmediateCheckBox() {
+ openTestURL();
+
+ CheckBoxElement checkBoxElement = $(CheckBoxElement.class).get(1);
+ WebElement inputElem = checkBoxElement.findElement(By.tagName("input"));
+ final WebElement countElem = $(LabelElement.class).id("count");
+
+ inputElem.click();
+ assertEquals("Events received: 1", countElem.getText());
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java
index bd44e8a074..f909f97996 100644
--- a/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java
+++ b/uitest/src/com/vaadin/tests/components/checkbox/CheckBoxRpcCount.java
@@ -15,6 +15,8 @@
*/
package com.vaadin.tests.components.checkbox;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
import com.vaadin.server.VaadinRequest;
import com.vaadin.shared.MouseEventDetails;
import com.vaadin.shared.ui.checkbox.CheckBoxServerRpc;
@@ -46,6 +48,14 @@ public class CheckBoxRpcCount extends AbstractTestUI {
});
}
};
+ cb.addValueChangeListener(new ValueChangeListener() {
+
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ // Adding an empty ValueChangeListener just to ensure that
+ // immediate mode is set to true
+ }
+ });
addComponent(cb);
}