]> source.dussan.org Git - vaadin-framework.git/commitdiff
Fixed #2119 : Select isn't updated correctly when value changed in the server. Also...
authorJoonas Lehtinen <joonas.lehtinen@itmill.com>
Fri, 26 Sep 2008 09:45:46 +0000 (09:45 +0000)
committerJoonas Lehtinen <joonas.lehtinen@itmill.com>
Fri, 26 Sep 2008 09:45:46 +0000 (09:45 +0000)
svn changeset:5524/svn branch:trunk

src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java
src/com/itmill/toolkit/tests/tickets/Ticket2119.java

index 1cf54693b9d3889ba2b7dafc5ef6141666bdd798..837f8b8f74227a9efe996606fa22ada201ee7e44 100644 (file)
@@ -476,6 +476,10 @@ public class IFilterSelect extends Composite implements Paintable, Field,
 
     // shown in unfocused empty field, disappears on focus (e.g "Search here")
     private String emptyText = "";
+    // Set true when popupopened has been clicked. Cleared on each UIDL-update.
+    // This handles the special case where are not filtering yet and the
+    // selected value has changed on the server-side. See #2119
+    private boolean popupOpenerClicked;
     private static final String CLASSNAME_EMPTY = "empty";
     private static final String ATTR_EMPTYTEXT = "emptytext";
 
@@ -582,7 +586,7 @@ public class IFilterSelect extends Composite implements Paintable, Field,
                     optionUidl);
             currentSuggestions.add(suggestion);
             if (optionUidl.hasAttribute("selected")) {
-                if (!filtering) {
+                if (!filtering || popupOpenerClicked) {
                     tb.setText(suggestion.getReplacementString());
                     selectedOptionKey = "" + suggestion.getOptionKey();
                 }
@@ -596,7 +600,7 @@ public class IFilterSelect extends Composite implements Paintable, Field,
             captions += suggestion.getReplacementString();
         }
 
-        if (!filtering && uidl.hasVariable("selected")
+        if ((!filtering || popupOpenerClicked) && uidl.hasVariable("selected")
                 && uidl.getStringArrayVariable("selected").length == 0) {
             // select nulled
             tb.setText(emptyText);
@@ -620,6 +624,8 @@ public class IFilterSelect extends Composite implements Paintable, Field,
         DOM.setStyleAttribute(spacer, "overflow", "hidden");
         DOM.appendChild(panel.getElement(), spacer);
 
+        popupOpenerClicked = false;
+
     }
 
     public void onSuggestionSelected(FilterSelectSuggestion suggestion) {
@@ -741,6 +747,7 @@ public class IFilterSelect extends Composite implements Paintable, Field,
             // auto close feature
             if (!suggestionPopup.isJustClosed()) {
                 filterOptions(-1, "");
+                popupOpenerClicked = true;
                 lastFilter = "";
             }
             DOM.eventPreventDefault(DOM.eventGetCurrentEvent());
index 73dec21ab8404f851bf33675a71d6c4d18c039a3..144b631ea458cacc2394d6c05fbbc7ce6e079b9e 100644 (file)
@@ -3,6 +3,7 @@ package com.itmill.toolkit.tests.tickets;
 import com.itmill.toolkit.Application;
 import com.itmill.toolkit.data.Property;
 import com.itmill.toolkit.data.util.ObjectProperty;
+import com.itmill.toolkit.terminal.ExternalResource;
 import com.itmill.toolkit.ui.Button;
 import com.itmill.toolkit.ui.Label;
 import com.itmill.toolkit.ui.Layout;
@@ -34,6 +35,7 @@ public class Ticket2119 extends Application {
             // If no window found, create it
             w = createWindow();
             addWindow(w);
+            w.open(new ExternalResource(w.getURL()));
         }
         return w;
     }