diff options
author | Teemu Suo-Anttila <tsuoanttila@users.noreply.github.com> | 2017-08-02 09:12:21 +0300 |
---|---|---|
committer | Henri Sara <henri.sara@gmail.com> | 2017-08-02 09:12:21 +0300 |
commit | f12a23c9c6bb176dd0550f07d6ddeb1e91c84bfc (patch) | |
tree | 70f177f117b87bcb20d6eb1f3fa46ba45251a976 /server | |
parent | 61c3a725bad98b731a8eb6a3186bb66398630022 (diff) | |
download | vaadin-framework-f12a23c9c6bb176dd0550f07d6ddeb1e91c84bfc.tar.gz vaadin-framework-f12a23c9c6bb176dd0550f07d6ddeb1e91c84bfc.zip |
Fix RadioButtonGroup selection updates to client (#9749)
This patch provides a simple fix for the majority of issues. There are still issues that should be fixes by refactoring parts of the logic in AbstractSingleSelect.
This patch does not unify the handling of empty values in the TestBench elements of various AbstractSingleSelects.
Fixes #9494
Diffstat (limited to 'server')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java | 6 | ||||
-rw-r--r-- | server/src/main/java/com/vaadin/ui/ComboBox.java | 23 |
2 files changed, 5 insertions, 24 deletions
diff --git a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java index 2b0e6b7d01..f9eed7fef3 100644 --- a/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java +++ b/server/src/main/java/com/vaadin/ui/AbstractSingleSelect.java @@ -230,10 +230,8 @@ public abstract class AbstractSingleSelect<T> extends AbstractListing<T> T oldSelection = getSelectedItem().orElse(getEmptyValue()); doSetSelectedKey(key); - // Update diffstate so that a change will be sent to the client if the - // selection is changed to its original value - updateDiffstate("selectedItemKey", - key == null ? Json.createNull() : Json.create(key)); + // Set diffstate to something that will always send selection to client + updateDiffstate("selectedItemKey", Json.createObject()); fireEvent(new SingleSelectionEvent<>(AbstractSingleSelect.this, oldSelection, true)); diff --git a/server/src/main/java/com/vaadin/ui/ComboBox.java b/server/src/main/java/com/vaadin/ui/ComboBox.java index 73d9ad84cf..af100e03f1 100644 --- a/server/src/main/java/com/vaadin/ui/ComboBox.java +++ b/server/src/main/java/com/vaadin/ui/ComboBox.java @@ -25,11 +25,11 @@ import java.util.Objects; import java.util.Set; import java.util.stream.Stream; -import com.vaadin.data.ValueProvider; import org.jsoup.nodes.Element; import com.vaadin.data.HasFilterableDataProvider; import com.vaadin.data.HasValue; +import com.vaadin.data.ValueProvider; import com.vaadin.data.provider.CallbackDataProvider; import com.vaadin.data.provider.DataCommunicator; import com.vaadin.data.provider.DataKeyMapper; @@ -57,7 +57,6 @@ import com.vaadin.ui.declarative.DesignAttributeHandler; import com.vaadin.ui.declarative.DesignContext; import com.vaadin.ui.declarative.DesignFormatter; -import elemental.json.Json; import elemental.json.JsonObject; /** @@ -189,7 +188,8 @@ public class ComboBox<T> extends AbstractSingleSelect<T> public ComboBox() { super(new DataCommunicator<T>() { @Override - protected DataKeyMapper<T> createKeyMapper(ValueProvider<T,Object> identifierGetter) { + protected DataKeyMapper<T> createKeyMapper( + ValueProvider<T, Object> identifierGetter) { return new KeyMapper<T>(identifierGetter) { @Override public void remove(T removeobj) { @@ -831,23 +831,6 @@ public class ComboBox<T> extends AbstractSingleSelect<T> q -> sizeCallback.applyAsInt(q.getFilter().orElse("")))); } - @Override - protected void setSelectedFromClient(String key) { - super.setSelectedFromClient(key); - - /* - * The client side for combo box always expects a state change for - * selectedItemKey after it has sent a selection change. This means that - * we must store a value in the diffstate that guarantees that a new - * value will be sent, regardless of what the value actually is at the - * time when changes are sent. - * - * Keys are always strings (or null), so using a non-string type will - * always trigger a diff mismatch and a resend. - */ - updateDiffstate("selectedItemKey", Json.create(0)); - } - /** * Predicate to check {@link ComboBox} item captions against user typed * strings. |