summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur.signell@itmill.com>2009-06-23 11:11:09 +0000
committerArtur Signell <artur.signell@itmill.com>2009-06-23 11:11:09 +0000
commit70be73db7d458f17de957043fc28c687c981f03b (patch)
treef17db24aa945b59f967ea4eb15e258574c345cd9
parent8a18616b907ecfdf65ab3d810119219c0a13c90c (diff)
downloadvaadin-framework-70be73db7d458f17de957043fc28c687c981f03b.tar.gz
vaadin-framework-70be73db7d458f17de957043fc28c687c981f03b.zip
Fix for #3081/#3015: Added uniqueness check to generated id in IndexedContainer
svn changeset:8226/svn branch:6.0
-rw-r--r--src/com/vaadin/data/util/IndexedContainer.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java
index 60686abe22..5e52c729ee 100644
--- a/src/com/vaadin/data/util/IndexedContainer.java
+++ b/src/com/vaadin/data/util/IndexedContainer.java
@@ -670,8 +670,19 @@ public class IndexedContainer implements Container.Indexed,
return id;
}
+ /**
+ * Generates an unique identifier for use as an item id. Guarantees that the
+ * generated id is not currently used as an id.
+ *
+ * @return
+ */
private Serializable generateId() {
- return new Integer(nextGeneratedItemId++);
+ Serializable id;
+ do {
+ id = new Integer(nextGeneratedItemId++);
+ } while (items.containsKey(id));
+
+ return id;
}
/* Event notifiers */