summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2012-10-26 11:07:38 +0300
committerVaadin Code Review <review@vaadin.com>2012-10-26 09:23:47 +0000
commit0fb5ddb96c889086178ff3d381d58076257a866a (patch)
tree5110f81cad5ae6e353c41294fee4f70a4444ff17
parent4bda2ef6a6fa84f05a032ac837f2037bd3d502bf (diff)
downloadvaadin-framework-0fb5ddb96c889086178ff3d381d58076257a866a.tar.gz
vaadin-framework-0fb5ddb96c889086178ff3d381d58076257a866a.zip
Fixed problem with Table calling markAsDirty in paint (#10071)
AbstractCommunicationManager now sets the writingResponse flag after calling beforeClientResponse to adhere to beforeClientResponse javadoc which says markAsDirty is ignored if called from beforeClientResponse. Change-Id: I58f4d009c85bef6756e2f2938d6f42ed88e11143
-rw-r--r--server/src/com/vaadin/server/AbstractCommunicationManager.java27
-rw-r--r--server/src/com/vaadin/ui/Table.java9
-rw-r--r--uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html71
-rw-r--r--uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java70
4 files changed, 163 insertions, 14 deletions
diff --git a/server/src/com/vaadin/server/AbstractCommunicationManager.java b/server/src/com/vaadin/server/AbstractCommunicationManager.java
index 5bbf8f5cea..43a9ced608 100644
--- a/server/src/com/vaadin/server/AbstractCommunicationManager.java
+++ b/server/src/com/vaadin/server/AbstractCommunicationManager.java
@@ -820,22 +820,21 @@ public abstract class AbstractCommunicationManager implements Serializable {
requireLocale(session.getLocale().toString());
}
- uiConnectorTracker.setWritingResponse(true);
- try {
+ dirtyVisibleConnectors
+ .addAll(getDirtyVisibleConnectors(uiConnectorTracker));
- dirtyVisibleConnectors
- .addAll(getDirtyVisibleConnectors(uiConnectorTracker));
-
- getLogger().log(
- Level.FINE,
- "Found " + dirtyVisibleConnectors.size()
- + " dirty connectors to paint");
- for (ClientConnector connector : dirtyVisibleConnectors) {
- boolean initialized = uiConnectorTracker
- .isClientSideInitialized(connector);
- connector.beforeClientResponse(!initialized);
- }
+ getLogger().log(
+ Level.FINE,
+ "Found " + dirtyVisibleConnectors.size()
+ + " dirty connectors to paint");
+ for (ClientConnector connector : dirtyVisibleConnectors) {
+ boolean initialized = uiConnectorTracker
+ .isClientSideInitialized(connector);
+ connector.beforeClientResponse(!initialized);
+ }
+ uiConnectorTracker.setWritingResponse(true);
+ try {
outWriter.print("\"changes\":[");
List<InvalidLayout> invalidComponentRelativeSizes = null;
diff --git a/server/src/com/vaadin/ui/Table.java b/server/src/com/vaadin/ui/Table.java
index d9e1403a03..242593c20d 100644
--- a/server/src/com/vaadin/ui/Table.java
+++ b/server/src/com/vaadin/ui/Table.java
@@ -2867,6 +2867,15 @@ public class Table extends AbstractSelect implements Action.Container,
}
}
+ @Override
+ public void beforeClientResponse(boolean initial) {
+ super.beforeClientResponse(initial);
+
+ // Ensure pageBuffer is filled before sending the response to avoid
+ // calls to markAsDirty during paint
+ getVisibleCells();
+ }
+
/*
* (non-Javadoc)
*
diff --git a/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html
new file mode 100644
index 0000000000..e95dbb3a65
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html
@@ -0,0 +1,71 @@
+<?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:8888/" />
+<title>DisableEnableCascadeStyles</title>
+</head>
+<body>
+<table cellpadding="1" cellspacing="1" border="1">
+<thead>
+<tr><td rowspan="1" colspan="3">DisableEnableCascadeStyles</td></tr>
+</thead><tbody>
+<tr>
+ <td>open</td>
+ <td>/run/com.vaadin.tests.components.table.RemoveItemOnClick?restartApplication</td>
+ <td></td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
+ <td>This is item 3</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
+ <td>60,11</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[3]/domChild[0]/domChild[0]</td>
+ <td>This is item 4</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[0]</td>
+ <td>60,11</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[6]/domChild[0]/domChild[0]</td>
+ <td>This is item 8</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>This is item 0</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>68,12</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>68,12</td>
+</tr>
+<tr>
+ <td>mouseClick</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>68,12</td>
+</tr>
+<tr>
+ <td>assertText</td>
+ <td>vaadin=runcomvaadintestscomponentstableRemoveItemOnClick::/VVerticalLayout[0]/VOrderedLayout$Slot[1]/VVerticalLayout[0]/VOrderedLayout$Slot[0]/VScrollTable[0]/domChild[1]/domChild[0]/domChild[1]/domChild[0]/domChild[0]/domChild[0]/domChild[0]</td>
+ <td>This is item 4</td>
+</tr>
+</tbody></table>
+</body>
+</html>
diff --git a/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java
new file mode 100644
index 0000000000..b13dd37060
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2011 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.table;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Item;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.Property.ValueChangeListener;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Table;
+
+public class RemoveItemOnClick extends AbstractTestUI {
+
+ private Table table;
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ table = new Table();
+ IndexedContainer ic = new IndexedContainer();
+ populate(ic);
+ table.setContainerDataSource(ic);
+ table.setPageLength(20);
+ table.setSelectable(true);
+ table.setImmediate(true);
+ table.addValueChangeListener(new ValueChangeListener() {
+ @Override
+ public void valueChange(ValueChangeEvent event) {
+ table.removeItem(table.getValue());
+ }
+ });
+ addComponent(table);
+ }
+
+ private void populate(Container container) {
+ container.addContainerProperty("property1", String.class, "foo");
+ container.addContainerProperty("property2", Integer.class, 1210);
+ container.addContainerProperty("property3", String.class, "bar");
+
+ for (int i = 0; i < 100; i++) {
+ Item item = container.addItem("Item " + i);
+ item.getItemProperty("property1").setValue("This is item " + i);
+ }
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "Selecting a row should remove that row from the table";
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 10071;
+ }
+
+}