diff options
author | Artur Signell <artur@vaadin.com> | 2016-05-06 18:04:06 +0300 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2016-05-09 12:44:19 +0000 |
commit | d3c617a77dcf6df7cf200f45430fb35b671121ac (patch) | |
tree | b516cea88bc3b4458cdbd67f7a78ea34114946ee /server | |
parent | e5765f1e53b47354b5d0910fe0c19c008734ba53 (diff) | |
download | vaadin-framework-d3c617a77dcf6df7cf200f45430fb35b671121ac.tar.gz vaadin-framework-d3c617a77dcf6df7cf200f45430fb35b671121ac.zip |
Fix null selection to work again (#19787)
Reverts the fix for #15181
Change-Id: I9ec45b1c9aad9788559d0de2b086bf5cf4af6b12
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(); } } } |