diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-02-02 12:46:56 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-02-03 12:23:25 +0200 |
commit | 4b7b21d35cbf80ddfa6e16f62bc4ff65008a4cd5 (patch) | |
tree | 8a16cd09fd01eeb8e2f9be2ff63af66c7eeca302 /client | |
parent | e25dd72efe36de7e59780cda0de472c1183be028 (diff) | |
download | vaadin-framework-4b7b21d35cbf80ddfa6e16f62bc4ff65008a4cd5.tar.gz vaadin-framework-4b7b21d35cbf80ddfa6e16f62bc4ff65008a4cd5.zip |
Add simple data update support to DataProvider
This patch adds the option of updating an existing data object. Update
is done on the next client response to catch any possible changes before
and after the update is initiated.
Change-Id: I30ca4803dd7c47befcb8e5ae761860c09cbdb8bd
Diffstat (limited to 'client')
-rw-r--r-- | client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java b/client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java index 1d4521c5b3..59d7f38811 100644 --- a/client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java +++ b/client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java @@ -98,6 +98,23 @@ public class DataSourceConnector extends AbstractExtensionConnector { sendDroppedKeys(); } } + + @Override + public void updateData(JsonArray data) { + List<JsonObject> list = ds.asList(); + for (int i = 0; i < data.length(); ++i) { + JsonObject json = data.getObject(i); + String key = getKey(json); + + if (keyToJson.containsKey(key)) { + int index = list.indexOf(keyToJson.get(key)); + list.set(index, json); + } else { + dropKey(key); + } + } + sendDroppedKeys(); + } }); ServerConnector parent = getParent(); @@ -117,8 +134,8 @@ public class DataSourceConnector extends AbstractExtensionConnector { * dropped key */ private void dropKey(String key) { + droppedKeys.add(key); if (keyToJson.containsKey(key)) { - droppedKeys.add(key); keyToJson.remove(key); } } |