diff options
author | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-11-05 12:20:07 +0000 |
---|---|---|
committer | Matti Tahvonen <matti.tahvonen@itmill.com> | 2010-11-05 12:20:07 +0000 |
commit | f0756724f0feb641b2f3ea9c5195457aebb4b872 (patch) | |
tree | f6888c93409f51053c5c79a6d8878914c89a2138 /src/com/vaadin | |
parent | 3de6cefec2548609ebabd6b8e3a7cfb46a2614fd (diff) | |
download | vaadin-framework-f0756724f0feb641b2f3ea9c5195457aebb4b872.tar.gz vaadin-framework-f0756724f0feb641b2f3ea9c5195457aebb4b872.zip |
fixes #5955. A bit more intelligent removal of fields from Form + a method that can be overridden for a custom logic.
svn changeset:15880/svn branch:6.5
Diffstat (limited to 'src/com/vaadin')
-rw-r--r-- | src/com/vaadin/ui/Form.java | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/com/vaadin/ui/Form.java b/src/com/vaadin/ui/Form.java index 0e487da603..8aa06d34cc 100644 --- a/src/com/vaadin/ui/Form.java +++ b/src/com/vaadin/ui/Form.java @@ -639,7 +639,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, if (field != null) { propertyIds.remove(id); fields.remove(id); - layout.removeComponent(field); + detachField(field); field.removeListener(fieldValueChangeListener); return true; } @@ -648,6 +648,25 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, } /** + * Called when a form field is detached from a Form. Typically when a new + * Item is assigned to Form via {@link #setItemDataSource(Item)} * + * <p> + * Override this method to control how the fields are removed from the + * layout. + * </p> + * + * + * @param field + * the field to be detached from the forms layout. + */ + protected void detachField(final Field field) { + Component p = field.getParent(); + if (p instanceof ComponentContainer) { + ((ComponentContainer) p).removeComponent(field); + } + } + + /** * Removes all properties and fields from the form. * * @return the Success of the operation. Removal of all fields succeeded if @@ -781,7 +800,7 @@ public class Form extends AbstractField implements Item.Editor, Buffered, Item, final Object[] properties = propertyIds.toArray(); for (int i = 0; i < properties.length; i++) { Field f = getField(properties[i]); - layout.removeComponent(f); + detachField(f); if (newLayout instanceof CustomLayout) { ((CustomLayout) newLayout).addComponent(f, properties[i].toString()); |