diff options
author | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-02-03 13:55:00 +0200 |
---|---|---|
committer | Teemu Suo-Anttila <teemusa@vaadin.com> | 2016-02-03 14:08:19 +0200 |
commit | 607e17afe508e6da32086e513c863b192d4e2baa (patch) | |
tree | beaa3d58f8aede29b905c0c1fe8c4c4342dafef3 | |
parent | 84d9b40c7b80283095a242972fbbdb4b6b5552df (diff) | |
download | vaadin-framework-607e17afe508e6da32086e513c863b192d4e2baa.tar.gz vaadin-framework-607e17afe508e6da32086e513c863b192d4e2baa.zip |
Fix SimpleDataProvider clean up and client-side data tracking on edit
Change-Id: I9807717df9cbae47c6532e43a58dd6bb693eaa85
3 files changed, 18 insertions, 12 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 2636a40a3a..8f9527c8e0 100644 --- a/client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java +++ b/client/src/com/vaadin/client/connectors/data/typed/DataSourceConnector.java @@ -109,6 +109,7 @@ public class DataSourceConnector extends AbstractExtensionConnector { if (keyToJson.containsKey(key)) { int index = list.indexOf(keyToJson.get(key)); list.set(index, json); + keyToJson.put(key, json); } else { dropKey(key); } diff --git a/server/src/com/vaadin/server/communication/data/typed/SimpleDataProvider.java b/server/src/com/vaadin/server/communication/data/typed/SimpleDataProvider.java index e5973ff6dd..ebf3734f51 100644 --- a/server/src/com/vaadin/server/communication/data/typed/SimpleDataProvider.java +++ b/server/src/com/vaadin/server/communication/data/typed/SimpleDataProvider.java @@ -89,20 +89,17 @@ public class SimpleDataProvider<T> extends DataProvider<T> { if (initial || reset) { getRpcProxy(DataProviderClientRpc.class).resetSize(data.size()); pushData(0, data); - reset = false; - updatedData.clear(); - } - - if (updatedData.isEmpty()) { - return; + } else if (!updatedData.isEmpty()) { + JsonArray dataArray = Json.createArray(); + int i = 0; + for (T data : updatedData) { + dataArray.set(i++, getDataObject(data)); + } + rpc.updateData(dataArray); } - JsonArray dataArray = Json.createArray(); - int i = 0; - for (T data : updatedData) { - dataArray.set(i++, getDataObject(data)); - } - rpc.updateData(dataArray); + reset = false; + updatedData.clear(); } @Override diff --git a/uitest/src/com/vaadin/tests/dataprovider/DummyDataProviderTest.java b/uitest/src/com/vaadin/tests/dataprovider/DummyDataProviderTest.java index 2a92743215..3821428ab2 100644 --- a/uitest/src/com/vaadin/tests/dataprovider/DummyDataProviderTest.java +++ b/uitest/src/com/vaadin/tests/dataprovider/DummyDataProviderTest.java @@ -181,5 +181,13 @@ public class DummyDataProviderTest extends SingleBrowserTest { text = findElements(By.className("v-label")).get(1).getText(); assertEquals("Modified data did not match", json, text); + + $(ButtonElement.class).id("edit").click(); + + text = findElements(By.className("v-label")).get(1).getText(); + assertEquals("Running edit again shouldn't change anything", json, text); + + assertNoErrorNotifications(); + } } |