summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/vaadin/data/util/IndexedContainer.java12
-rw-r--r--src/com/vaadin/ui/Form.java8
2 files changed, 15 insertions, 5 deletions
diff --git a/src/com/vaadin/data/util/IndexedContainer.java b/src/com/vaadin/data/util/IndexedContainer.java
index 617fe93e14..60686abe22 100644
--- a/src/com/vaadin/data/util/IndexedContainer.java
+++ b/src/com/vaadin/data/util/IndexedContainer.java
@@ -125,6 +125,8 @@ public class IndexedContainer implements Container.Indexed,
private HashMap<Object, Object> defaultPropertyValues;
+ private int nextGeneratedItemId = 1;
+
/* Container constructors */
public IndexedContainer() {
@@ -305,7 +307,7 @@ public class IndexedContainer implements Container.Indexed,
public Object addItem() {
// Creates a new id
- final Object id = new Object();
+ final Object id = generateId();
// Adds the Item into container
addItem(id);
@@ -569,7 +571,7 @@ public class IndexedContainer implements Container.Indexed,
public Object addItemAfter(Object previousItemId) {
// Creates a new id
- final Object id = new Object();
+ final Object id = generateId();
return addItemAfter(previousItemId, id);
}
@@ -660,7 +662,7 @@ public class IndexedContainer implements Container.Indexed,
public Object addItemAt(int index) {
// Creates a new id
- final Object id = new Object();
+ final Object id = generateId();
// Adds the Item into container
addItemAt(index, id);
@@ -668,6 +670,10 @@ public class IndexedContainer implements Container.Indexed,
return id;
}
+ private Serializable generateId() {
+ return new Integer(nextGeneratedItemId++);
+ }
+
/* Event notifiers */
/**
diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java
index 393c94cf9e..1741fe591f 100644
--- a/src/com/vaadin/ui/Form.java
+++ b/src/com/vaadin/ui/Form.java
@@ -836,11 +836,15 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item,
newField.setItemCaptionPropertyId("desc");
for (int i = 0; i < values.length; i++) {
Object id = values[i];
+ final Item item;
if (id == null) {
- id = new Object();
+ id = newField.addItem();
+ item = newField.getItem(id);
newField.setNullSelectionItemId(id);
+ } else {
+ item = newField.addItem(id);
}
- final Item item = newField.addItem(id);
+
if (item != null) {
item.getItemProperty("desc").setValue(
descriptions[i].toString());