Class Composite<T extends Component>
- Type Parameters:
T
- the type of the content
- All Implemented Interfaces:
AttachNotifier
,DetachNotifier
,HasElement
,HasStyle
,Serializable
- Direct Known Subclasses:
AbstractCompositeField
,CollaborationAvatarGroup
,CollaborationMessageInput
,CollaborationMessageList
Component
tree to allow creation of new
components by composing existing components. By encapsulating the component,
its API can be hidden or presented in a different way for the user of the
composite.
The encapsulated component tree is available through getContent()
.
Composite will by default look at the generic type declaration of its
subclass to find the content type and create an instance if the type has a
no-args constructor. You can also override initContent()
to manually
create the component tree. The encapsulated component itself can contain more
components.
Composite is a way to hide API on the server side. It does not contribute any
element to the Element
tree.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGets the child components of this composite.Gets the content of the composite, i.e.Gets the root element of this composite.protected T
Called when the content of this composite is requested for the first time.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListener
Methods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListener
Methods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
Composite
protected Composite()Creates a new composite.To define your own composite, extend this class and implement
initContent()
.
-
-
Method Details
-
initContent
Called when the content of this composite is requested for the first time.This method should initialize the component structure for the composite and return the root component.
By default, this method uses reflection to instantiate the component based on the generic type of the sub class.
- Returns:
- the root component which this composite wraps, never
null
-
getContent
Gets the content of the composite, i.e. the component the composite is wrapping.- Returns:
- the content for the composite, never
null
-
getElement
Gets the root element of this composite.For a composite, the root element is the same as the root element of the content of the composite.
- Specified by:
getElement
in interfaceHasElement
- Overrides:
getElement
in classComponent
- Returns:
- the root element of this component
-
getChildren
Gets the child components of this composite.A composite always has one child component, returned by
initContent()
.- Overrides:
getChildren
in classComponent
- Returns:
- the child component of this composite
- See Also:
-