From b56b4c629eb5327cc655fab02b6276738802f200 Mon Sep 17 00:00:00 2001 From: Matti Tahvonen Date: Mon, 18 May 2009 10:22:20 +0000 Subject: [PATCH] fixed regression in form due field factory refactoring ( #2499 ). The very old feature browser works again. svn changeset:7846/svn branch:6.0 --- src/com/vaadin/ui/Form.java | 19 ++++++++++++++++--- 1 file 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 @@ -94,6 +94,11 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, */ private final HashMap fields = new HashMap(); + /** + * Form may act as an Item, its own properties are stored here. + */ + private final HashMap ownProperties = new HashMap(); + /** * Field factory for this form. */ @@ -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); -- 2.39.5