]> source.dussan.org Git - vaadin-framework.git/commitdiff
test case and fix for #2014 (toggling empty container in table)
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 29 Sep 2008 14:01:34 +0000 (14:01 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 29 Sep 2008 14:01:34 +0000 (14:01 +0000)
svn changeset:5547/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IScrollTable.java
src/com/itmill/toolkit/tests/tickets/Ticket2126.java [new file with mode: 0644]

index bebd1cd476f9f46dad3cb00ea93045cc817db2ca..a0b0885c8048f79a6eff0624876814903173160e 100644 (file)
@@ -1319,10 +1319,13 @@ public class IScrollTable extends Composite implements Table, ScrollListener,
         }
 
         public void clear() {
-            super.clear();
+            for (Iterator iterator = availableCells.keySet().iterator(); iterator
+                    .hasNext();) {
+                String cid = (String) iterator.next();
+                removeCell(cid);
+            }
             availableCells.clear();
             availableCells.put("0", new RowHeadersHeaderCell());
-
         }
 
         public void updateCellsFromUIDL(UIDL uidl) {
diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2126.java b/src/com/itmill/toolkit/tests/tickets/Ticket2126.java
new file mode 100644 (file)
index 0000000..11dfedd
--- /dev/null
@@ -0,0 +1,61 @@
+package com.itmill.toolkit.tests.tickets;\r
+\r
+import com.itmill.toolkit.data.Item;\r
+import com.itmill.toolkit.data.util.IndexedContainer;\r
+import com.itmill.toolkit.ui.Button;\r
+import com.itmill.toolkit.ui.Component;\r
+import com.itmill.toolkit.ui.Label;\r
+import com.itmill.toolkit.ui.Table;\r
+import com.itmill.toolkit.ui.Window;\r
+\r
+/**\r
+ * \r
+ * Toggling container with an empty one may result duplicate header cell in\r
+ * client.\r
+ * \r
+ */\r
+public class Ticket2126 extends com.itmill.toolkit.Application {\r
+\r
+    Window main = new Window();\r
+    Table table = new Table();\r
+\r
+    public void init() {\r
+        setMainWindow(main);\r
+\r
+        final IndexedContainer container1 = new IndexedContainer();\r
+        container1.addContainerProperty("text", Component.class, null);\r
+        final IndexedContainer container2 = new IndexedContainer();\r
+\r
+        // Case #2 Try to comment the following line for another type of strange\r
+        // behaviour\r
+        container2.addContainerProperty("text", Component.class, null);\r
+\r
+        for (int i = 0; i < 100; i++) {\r
+            Item item = container1.addItem(i);\r
+            item.getItemProperty("text").setValue(new Label("Test " + i));\r
+        }\r
+\r
+        table.setContainerDataSource(container1);\r
+\r
+        // workaround for case #2\r
+        // table.setWidth("300px");\r
+        // table.setHeight("300px");\r
+\r
+        Button refreshTable = new Button("Switch table container");\r
+        refreshTable.addListener(new Button.ClickListener() {\r
+            boolean full = true;\r
+\r
+            public void buttonClick(Button.ClickEvent e) {\r
+                if (full) {\r
+                    table.setContainerDataSource(container2);\r
+                } else {\r
+                    table.setContainerDataSource(container1);\r
+                }\r
+                full = !full;\r
+            }\r
+        });\r
+\r
+        main.addComponent(table);\r
+        main.addComponent(refreshTable);\r
+    }\r
+}
\ No newline at end of file