From: Artur Signell Date: Thu, 21 Jun 2012 08:27:55 +0000 (+0300) Subject: Call attach only once for children (#9005) X-Git-Tag: 7.0.0.alpha3~79 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=379bc6f79767d2c4a3fda3b8ecec8474740463a6;p=vaadin-framework.git Call attach only once for children (#9005) --- 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 extends AbstractField 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 extends AbstractField implements protected Component getContent() { if (null == root) { root = initContent(); + root.setParent(this); } return root; }