summaryrefslogtreecommitdiffstats
path: root/server/src/com/vaadin/data
diff options
context:
space:
mode:
authorHenri Sara <hesara@vaadin.com>2012-09-04 16:47:42 +0300
committerHenri Sara <hesara@vaadin.com>2012-09-04 16:47:42 +0300
commite8a5f2082d854085fc9da33d5f837900ef347f4f (patch)
treeebb7cb59236a8605252de61d5fd00d6facdaa6c1 /server/src/com/vaadin/data
parent99a423cea5a273d7ddcc39a959895931d12533df (diff)
downloadvaadin-framework-e8a5f2082d854085fc9da33d5f837900ef347f4f.tar.gz
vaadin-framework-e8a5f2082d854085fc9da33d5f837900ef347f4f.zip
Fix SQLContainer indexed access and related tests (#9472)
Diffstat (limited to 'server/src/com/vaadin/data')
-rw-r--r--server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java14
1 files changed, 11 insertions, 3 deletions
diff --git a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
index 7a63e8c6c2..1b479a21d8 100644
--- a/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
+++ b/server/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java
@@ -661,7 +661,8 @@ public class SQLContainer implements Container, Container.Filterable,
throw new IndexOutOfBoundsException("Index is negative! index="
+ index);
}
-
+ // make sure the size field is valid
+ updateCount();
if (index < size) {
if (itemIndexes.keySet().contains(index)) {
return itemIndexes.get(index);
@@ -671,7 +672,9 @@ public class SQLContainer implements Container, Container.Filterable,
} else {
// The index is in the added items
int offset = index - size;
- return addedItems.get(offset).getId();
+ // TODO this is very inefficient if looping - should improve
+ // getItemIds(int, int)
+ return getFilteredAddedItems().get(offset).getId();
}
}
@@ -694,7 +697,12 @@ public class SQLContainer implements Container, Container.Filterable,
@Override
public Object nextItemId(Object itemId) {
- return getIdByIndex(indexOfId(itemId) + 1);
+ int index = indexOfId(itemId) + 1;
+ try {
+ return getIdByIndex(index);
+ } catch (IndexOutOfBoundsException e) {
+ return null;
+ }
}
/*