diff options
author | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-09-08 10:53:55 +0000 |
---|---|---|
committer | Jonatan Kronqvist <jonatan.kronqvist@itmill.com> | 2011-09-08 10:53:55 +0000 |
commit | e21098304736e32a74f359e8dfb80e587337085d (patch) | |
tree | 4de8044ae3e45b123a591eda9c54a80f109aef9c /src | |
parent | 5fc9f775f3b256c31204cc681c640513559184c9 (diff) | |
download | vaadin-framework-e21098304736e32a74f359e8dfb80e587337085d.tar.gz vaadin-framework-e21098304736e32a74f359e8dfb80e587337085d.zip |
Applied patch fixing #7391
svn changeset:20926/svn branch:6.7
Diffstat (limited to 'src')
-rw-r--r-- | src/com/vaadin/data/util/sqlcontainer/SQLContainer.java | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java b/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java index f25252b8c0..f6b22bfecb 100644 --- a/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java +++ b/src/com/vaadin/data/util/sqlcontainer/SQLContainer.java @@ -1199,7 +1199,18 @@ public class SQLContainer implements Container, Container.Filterable, } /* Cache item */ itemIndexes.put(rowCount, id); - cachedItems.put(id, new RowItem(this, id, itemProperties)); + + // if an item with the id is contained in the modified + // cache, then use this record and add it to the cached + // items. Otherwise create a new item + int modifiedIndex = indexInModifiedCache(id); + if (modifiedIndex != -1) { + cachedItems.put(id, modifiedItems.get(modifiedIndex)); + } else { + cachedItems.put(id, new RowItem(this, id, + itemProperties)); + } + rowCount++; } } @@ -1229,6 +1240,24 @@ public class SQLContainer implements Container, Container.Filterable, } } + /** + * Returns the index of the item with the given itemId for the modified + * cache. + * + * @param itemId + * @return the index of the item with the itemId in the modified cache. Or + * -1 if not found. + */ + private int indexInModifiedCache(Object itemId) { + for (int ix = 0; ix < modifiedItems.size(); ix++) { + RowItem item = modifiedItems.get(ix); + if (item.getId().equals(itemId)) { + return ix; + } + } + return -1; + } + private int sizeOfAddedItems() { return getFilteredAddedItems().size(); } |