aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <teemusa@vaadin.com>2015-11-18 12:53:03 +0100
committerHenri Sara <hesara@vaadin.com>2016-01-15 15:11:15 +0200
commit3ecb2cab7c35118fb21699953518eaaa04e92d9e (patch)
treece8a16e85ea2fb1706880e338e8ae9763296ea84
parentf22eb521fb5d7778abccbec87d3996774a9ca752 (diff)
downloadvaadin-framework-3ecb2cab7c35118fb21699953518eaaa04e92d9e.tar.gz
vaadin-framework-3ecb2cab7c35118fb21699953518eaaa04e92d9e.zip
Support non-indexed containers in RpcDataProvider (#19266)
Any other type of container is supported by getting all the item ids and finding out the part we need to send to the client. This is not optimal, but should work. Change-Id: I02f05f31beddf506fc47a64bc21c98d142e809e0
-rw-r--r--server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java18
1 files changed, 13 insertions, 5 deletions
diff --git a/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java b/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java
index a6cecbb99d..6aaeec42b0 100644
--- a/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java
+++ b/server/src/com/vaadin/server/communication/data/RpcDataProviderExtension.java
@@ -26,7 +26,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import com.vaadin.data.Container.Indexed;
+import com.vaadin.data.Container;
import com.vaadin.data.Container.Indexed.ItemAddEvent;
import com.vaadin.data.Container.Indexed.ItemRemoveEvent;
import com.vaadin.data.Container.ItemSetChangeEvent;
@@ -213,7 +213,7 @@ public class RpcDataProviderExtension extends AbstractExtension {
}
}
- private final Indexed container;
+ private final Container container;
private DataProviderRpc rpc;
@@ -275,7 +275,7 @@ public class RpcDataProviderExtension extends AbstractExtension {
* @param container
* the container to make available
*/
- public RpcDataProviderExtension(Indexed container) {
+ public RpcDataProviderExtension(Container container) {
this.container = container;
rpc = getRpcProxy(DataProviderRpc.class);
@@ -356,8 +356,16 @@ public class RpcDataProviderExtension extends AbstractExtension {
fullRange = newRange.combineWith(cached);
}
- List<?> itemIds = container.getItemIds(fullRange.getStart(),
- fullRange.length());
+ List<?> itemIds;
+ if (container instanceof Container.Indexed) {
+ itemIds = ((Container.Indexed) container).getItemIds(
+ fullRange.getStart(), fullRange.length());
+ } else {
+ // This is nowhere near optimal. You should really use Indexed
+ // containers.
+ itemIds = new ArrayList<Object>(container.getItemIds()).subList(
+ fullRange.getStart(), fullRange.getEnd());
+ }
JsonArray rows = Json.createArray();