From 3b0ed7a67553ca48e40f9c78da5655256a1fe5ea Mon Sep 17 00:00:00 2001 From: Denis Anisimov Date: Sun, 24 Aug 2014 14:48:03 +0300 Subject: Update selection after changes in underlying data source (#13580). Change-Id: I6354d85bd6bc37b1cbb69f388559278d5a163256 --- server/src/com/vaadin/ui/AbstractSelect.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'server/src/com') diff --git a/server/src/com/vaadin/ui/AbstractSelect.java b/server/src/com/vaadin/ui/AbstractSelect.java index b083db3183..2c4dd5be5d 100644 --- a/server/src/com/vaadin/ui/AbstractSelect.java +++ b/server/src/com/vaadin/ui/AbstractSelect.java @@ -1675,6 +1675,8 @@ public abstract class AbstractSelect extends AbstractField implements // Clears the item id mapping table itemIdMapper.removeAll(); + adjustSelection(); + // Notify all listeners fireItemSetChange(); } @@ -1712,6 +1714,23 @@ public abstract class AbstractSelect extends AbstractField implements markAsDirty(); } + /** + * Removes orphaned ids from selection. + */ + protected void adjustSelection() { + Object value = getValue(); + if (isMultiSelect() && (value instanceof Collection)) { + Collection collection = (Collection) value; + for (Object id : collection) { + if (!containsId(id)) { + unselect(id); + } + } + } else if (!containsId(value)) { + unselect(value); + } + } + /** * Implementation of item set change event. */ -- cgit v1.2.3