*/
@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());
+ }
}
/**
protected Component getContent() {
if (null == root) {
root = initContent();
+ root.setParent(this);
}
return root;
}