]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fix for #2242 - Changing an AbstractSelect container data source should not fire...
authorArtur Signell <artur.signell@itmill.com>
Mon, 1 Dec 2008 13:35:29 +0000 (13:35 +0000)
committerArtur Signell <artur.signell@itmill.com>
Mon, 1 Dec 2008 13:35:29 +0000 (13:35 +0000)
svn changeset:6050/svn branch:trunk

src/com/itmill/toolkit/tests/tickets/Ticket2242.java [new file with mode: 0644]
src/com/itmill/toolkit/ui/AbstractSelect.java

diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2242.java b/src/com/itmill/toolkit/tests/tickets/Ticket2242.java
new file mode 100644 (file)
index 0000000..cd5f75d
--- /dev/null
@@ -0,0 +1,115 @@
+package com.itmill.toolkit.tests.tickets;
+
+import com.itmill.toolkit.Application;
+import com.itmill.toolkit.data.Item;
+import com.itmill.toolkit.data.Property.ValueChangeEvent;
+import com.itmill.toolkit.data.Property.ValueChangeListener;
+import com.itmill.toolkit.data.util.IndexedContainer;
+import com.itmill.toolkit.data.util.ObjectProperty;
+import com.itmill.toolkit.ui.Button;
+import com.itmill.toolkit.ui.OrderedLayout;
+import com.itmill.toolkit.ui.Table;
+import com.itmill.toolkit.ui.Window;
+import com.itmill.toolkit.ui.Button.ClickEvent;
+import com.itmill.toolkit.ui.Button.ClickListener;
+
+public class Ticket2242 extends Application implements ValueChangeListener {
+
+    private Object tableValue = null;
+    private Table t;
+    private String valueDataSource = "-";
+    private ObjectProperty prop;
+
+    public void init() {
+        Window w = new Window(getClass().getSimpleName());
+        setMainWindow(w);
+        // setTheme("tests-tickets");
+        createUI((OrderedLayout) w.getLayout());
+    }
+
+    private void createUI(OrderedLayout layout) {
+        Button b = new Button("Change container datasource",
+                new ClickListener() {
+
+                    public void buttonClick(ClickEvent event) {
+                        for (int i = 0; i < 5; i++) {
+                            t.setContainerDataSource(createContainer());
+                            // prop.setValue("ipsum");
+                        }
+                    }
+
+                });
+
+        layout.addComponent(b);
+
+        t = new Table("A table");
+        prop = new ObjectProperty(valueDataSource);
+        t.setPropertyDataSource(prop);
+        t.setSelectable(true);
+        t.setImmediate(true);
+        t.setPageLength(5);
+        t.setContainerDataSource(createContainer());
+        tableValue = t.getValue();
+        t.addListener(this);
+
+        layout.addComponent(t);
+    }
+
+    private IndexedContainer createContainer() {
+        IndexedContainer ic = new IndexedContainer();
+        ic.addContainerProperty("a", String.class, null);
+
+        for (String s : new String[] { "Lorem", "ipsum", "dolor", "sit",
+                "amet", "consectetuer" }) {
+            Item item = ic.addItem(s);
+            item.getItemProperty("a").setValue(s);
+
+        }
+
+        return ic;
+    }
+
+    private static class TestObject {
+        public TestObject(int a, String b, Long c) {
+            super();
+            this.a = a;
+            this.b = b;
+            this.c = c;
+        }
+
+        private int a;
+        private String b;
+        private Long c;
+
+        public int getA() {
+            return a;
+        }
+
+        public void setA(int a) {
+            this.a = a;
+        }
+
+        public String getB() {
+            return b;
+        }
+
+        public void setB(String b) {
+            this.b = b;
+        }
+
+        public Long getC() {
+            return c;
+        }
+
+        public void setC(Long c) {
+            this.c = c;
+        }
+    }
+
+    public void valueChange(ValueChangeEvent event) {
+        System.out.println("Value change from " + tableValue + " to "
+                + t.getValue());
+        tableValue = t.getValue();
+    }
+
+}
index bad8f863da33eead7700d35e07e39522114a9f91..753113203963ee9b709a4ecc935ad3f69319b633 100644 (file)
@@ -879,8 +879,7 @@ public abstract class AbstractSelect extends AbstractField implements
                 }
             }
 
-            // TODO: This should be conditional
-            fireValueChange(false);
+            requestRepaint();
         }
     }