From: Joonas Lehtinen Date: Fri, 26 Sep 2008 09:45:46 +0000 (+0000) Subject: Fixed #2119 : Select isn't updated correctly when value changed in the server. Also... X-Git-Tag: 6.7.0.beta1~4081 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=1eb8a7ee03b342087efccd9217e75bbced40d67d;p=vaadin-framework.git Fixed #2119 : Select isn't updated correctly when value changed in the server. Also added support for #2117 to the ticket test. svn changeset:5524/svn branch:trunk --- diff --git a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java index 1cf54693b9..837f8b8f74 100644 --- a/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java +++ b/src/com/itmill/toolkit/terminal/gwt/client/ui/IFilterSelect.java @@ -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()); diff --git a/src/com/itmill/toolkit/tests/tickets/Ticket2119.java b/src/com/itmill/toolkit/tests/tickets/Ticket2119.java index 73dec21ab8..144b631ea4 100644 --- a/src/com/itmill/toolkit/tests/tickets/Ticket2119.java +++ b/src/com/itmill/toolkit/tests/tickets/Ticket2119.java @@ -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; }