]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed problem with Table calling markAsDirty in paint (#10071) 71/171/3
authorArtur Signell <artur@vaadin.com>
Fri, 26 Oct 2012 08:07:38 +0000 (11:07 +0300)
committerVaadin Code Review <review@vaadin.com>
Fri, 26 Oct 2012 09:23:47 +0000 (09:23 +0000)
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

server/src/com/vaadin/server/AbstractCommunicationManager.java
server/src/com/vaadin/ui/Table.java
uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.html [new file with mode: 0644]
uitest/src/com/vaadin/tests/components/table/RemoveItemOnClick.java [new file with mode: 0644]

index 5bbf8f5cea57fd3e3faee6f7420d660116182e66..43a9ced608a70fe95f8ffc97bf3f8b0be04574b4 100644 (file)
@@ -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;
index d9e1403a03a43e25d1f03b92feb7d37a10a380cd..242593c20ddc0fda8a509d39731ec18e5223711d 100644 (file)
@@ -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 (file)
index 0000000..e95dbb3
--- /dev/null
@@ -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 (file)
index 0000000..b13dd37
--- /dev/null
@@ -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;
+    }
+
+}