diff options
author | Artur Signell <artur@vaadin.com> | 2012-06-21 11:27:55 +0300 |
---|---|---|
committer | Artur Signell <artur@vaadin.com> | 2012-06-21 17:11:33 +0300 |
commit | 379bc6f79767d2c4a3fda3b8ecec8474740463a6 (patch) | |
tree | 78eec6d6bac8a311153caf44e4d0a67eb83fdf9a /src/com/vaadin/ui | |
parent | 0010ce4439e90a8da20f61516d3ca8404c17a9af (diff) | |
download | vaadin-framework-379bc6f79767d2c4a3fda3b8ecec8474740463a6.tar.gz vaadin-framework-379bc6f79767d2c4a3fda3b8ecec8474740463a6.zip |
Call attach only once for children (#9005)
Diffstat (limited to 'src/com/vaadin/ui')
-rw-r--r-- | src/com/vaadin/ui/CustomField.java | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/com/vaadin/ui/CustomField.java b/src/com/vaadin/ui/CustomField.java index 269f24fb2c..0998c11612 100644 --- a/src/com/vaadin/ui/CustomField.java +++ b/src/com/vaadin/ui/CustomField.java @@ -62,21 +62,18 @@ public abstract class CustomField<T> extends AbstractField<T> implements */ @Override public void attach() { - root = getContent(); - getContent().setParent(this); - fireComponentAttachEvent(getContent()); + // First call super attach to notify all children (none if content has + // not yet been created) super.attach(); - } - /** - * Notifies the content that the {@link CustomField} is detached from a - * window. - * - * @see com.vaadin.ui.Component#detach() - */ - @Override - public void detach() { - super.detach(); + // If the content has not yet been created, we create and attach it at + // this point. + if (root == null) { + // Ensure content is created and its parent is set. + // The getContent() call creates the content and attaches the + // content + fireComponentAttachEvent(getContent()); + } } /** @@ -87,6 +84,7 @@ public abstract class CustomField<T> extends AbstractField<T> implements protected Component getContent() { if (null == root) { root = initContent(); + root.setParent(this); } return root; } |