]> source.dussan.org Git - vaadin-framework.git/commitdiff
fixes #5342
authorMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 12 Jul 2010 15:23:00 +0000 (15:23 +0000)
committerMatti Tahvonen <matti.tahvonen@itmill.com>
Mon, 12 Jul 2010 15:23:00 +0000 (15:23 +0000)
svn changeset:14178/svn branch:6.4

src/com/vaadin/ui/Table.java
tests/src/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java [new file with mode: 0644]

index eba9bed27253207b798fcac861eac10e55ee7ee2..284840df51ab8fcd56a3dea3af4a30eeb488b351 100644 (file)
@@ -1864,7 +1864,7 @@ public class Table extends AbstractSelect implements Action.Container,
         Object currentItemId = startItemId;
 
         Container.Ordered ordered = (Container.Ordered) items;
-        while (currentItemId != endItemId) {
+        while ((currentItemId != null) && currentItemId.equals(endItemId)) {
             currentItemId = ordered.nextItemId(currentItemId);
             if (currentItemId != null) {
                 ids.add(currentItemId);
diff --git a/tests/src/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java b/tests/src/com/vaadin/tests/components/table/MultiSelectWithNotIdentityEqualIds.java
new file mode 100644 (file)
index 0000000..62fd53d
--- /dev/null
@@ -0,0 +1,61 @@
+package com.vaadin.tests.components.table;
+
+import com.vaadin.data.Container;
+import com.vaadin.data.Property;
+import com.vaadin.data.Property.ValueChangeEvent;
+import com.vaadin.data.util.IndexedContainer;
+import com.vaadin.tests.components.TestBase;
+import com.vaadin.ui.Table;
+
+@SuppressWarnings("serial")
+public class MultiSelectWithNotIdentityEqualIds extends TestBase {
+
+    @Override
+    protected void setup() {
+        final Table t = new Table();
+        t.setContainerDataSource(getDS());
+        t.setRowHeaderMode(Table.ROW_HEADER_MODE_ID);
+        t.setMultiSelect(true);
+        t.setSelectable(true);
+        t.setImmediate(true);
+        t.addListener(new Property.ValueChangeListener() {
+            public void valueChange(ValueChangeEvent event) {
+                t.getWindow().showNotification(
+                        "Selected: " + event.getProperty());
+
+            }
+        });
+        getLayout().addComponent(t);
+    }
+
+    private Container getDS() {
+
+        IndexedContainer idx = new IndexedContainer() {
+
+            @Override
+            public Object nextItemId(Object itemId) {
+                Integer id = (Integer) super.nextItemId(itemId);
+                return id == null ? null : new Integer(id);
+            }
+
+        };
+        for (int i = 0; i < 10; i++) {
+            idx.addItem();
+        }
+
+        idx.addContainerProperty("Property", String.class, "foo");
+
+        return idx;
+    }
+
+    @Override
+    protected String getDescription() {
+        return "Multiselection should work with container that uses ids that are equal, but not necessary identical. With bug an infinit loop is caused.";
+    }
+
+    @Override
+    protected Integer getTicketNumber() {
+        return 5342;
+    }
+
+}