diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-05-18 10:22:20 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2009-05-18 10:22:20 +0000 |
commit | b56b4c629eb5327cc655fab02b6276738802f200 (patch) | |
tree | 21c55a4b38d1d48aa331f59844a48f6c6eb60978 | |
parent | 1eaa8f718d089413314aaf4dd903cae00d6f2320 (diff) | |
download | vaadin-framework-b56b4c629eb5327cc655fab02b6276738802f200.tar.gz vaadin-framework-b56b4c629eb5327cc655fab02b6276738802f200.zip |
fixed regression in form due field factory refactoring ( #2499 ). The very old feature browser works again.
svn changeset:7846/svn branch:6.0
-rw-r--r-- | src/com/vaadin/ui/Form.java | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java index a256de6389..393c94cf9e 100644 --- a/src/com/vaadin/ui/Form.java +++ b/src/com/vaadin/ui/Form.java @@ -95,6 +95,11 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, private final HashMap<Object, Field> fields = new HashMap<Object, Field>(); /** + * Form may act as an Item, its own properties are stored here. + */ + private final HashMap<Object, Property> ownProperties = new HashMap<Object, Property>(); + + /** * Field factory for this form. */ private FormFieldFactory fieldFactory; @@ -453,8 +458,11 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, return false; } + propertyIds.add(id); + ownProperties.put(id, property); + // Gets suitable field - final Field field = fieldFactory.createField(this, property, this); + final Field field = fieldFactory.createField(this, id, this); if (field == null) { return false; } @@ -505,7 +513,10 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, if (propertyId != null && field != null) { fields.put(propertyId, field); field.addListener(fieldValueChangeListener); - propertyIds.addLast(propertyId); + if (!propertyIds.contains(propertyId)) { + // adding a field directly + propertyIds.addLast(propertyId); + } field.setReadThrough(readThrough); field.setWriteThrough(writeThrough); if (isImmediate() && field instanceof AbstractComponent) { @@ -536,7 +547,8 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, public Property getItemProperty(Object id) { final Field field = fields.get(id); if (field == null) { - return null; + // field does not exist or it is not (yet) created for this property + return ownProperties.get(id); } final Property property = field.getPropertyDataSource(); @@ -568,6 +580,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, * @see com.vaadin.data.Item#removeItemProperty(Object) */ public boolean removeItemProperty(Object id) { + ownProperties.remove(id); final Field field = fields.get(id); |