diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/server/KeyMapper.java | 14 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/ui/AbstractSelect.java | 17 |
2 files changed, 24 insertions, 7 deletions
diff --git a/server/src/main/java/com/vaadin/server/KeyMapper.java b/server/src/main/java/com/vaadin/server/KeyMapper.java index 0e4b7edc77..709c3e0c2d 100644 --- a/server/src/main/java/com/vaadin/server/KeyMapper.java +++ b/server/src/main/java/com/vaadin/server/KeyMapper.java @@ -93,4 +93,18 @@ public class KeyMapper<V> implements Serializable { objectKeyMap.clear(); keyObjectMap.clear(); } + + /** + * Checks if the given key is mapped to an object. + * + * @since + * + * @param key + * the key to check + * @return <code>true</code> if the key is currently mapped, + * <code>false</code> otherwise + */ + public boolean containsKey(String key) { + return keyObjectMap.containsKey(key); + } } diff --git a/server/src/main/java/com/vaadin/ui/AbstractSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSelect.java index 2714e0cbf5..882458c531 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSelect.java @@ -530,18 +530,21 @@ public abstract class AbstractSelect extends AbstractField<Object> implements setValue(null, true); } } else { - final Object id = itemIdMapper - .get(clientSideSelectedKeys[0]); - - if (id != null) { - if (isNullSelectionAllowed() + String clientSelectedKey = clientSideSelectedKeys[0]; + if ("null".equals(clientSelectedKey) + || itemIdMapper.containsKey(clientSelectedKey)) { + // Happens to work for nullselection + // (get ("null") -> null)) + final Object id = itemIdMapper.get(clientSelectedKey); + + if (!isNullSelectionAllowed() && id == null) { + markAsDirty(); + } else if (id != null && id.equals(getNullSelectionItemId())) { setValue(null, true); } else { setValue(id, true); } - } else { - markAsDirty(); } } } |