T
- the type of the contentpublic abstract class Composite<T extends Component> extends Component
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.
Modifier | Constructor and Description |
---|---|
protected |
Composite()
Creates a new composite.
|
Modifier and Type | Method and Description |
---|---|
Stream<Component> |
getChildren()
Gets the child components of this composite.
|
T |
getContent()
Gets the content of the composite, i.e.
|
Element |
getElement()
Gets the root element of this composite.
|
protected T |
initContent()
Called when the content of this composite is requested for the first
time.
|
addListener, fireEvent, from, get, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, set, setElement, setId, setVisible
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addAttachListener
addDetachListener
protected Composite()
To define your own composite, extend this class and implement
initContent()
.
protected T initContent()
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.
null
public T getContent()
null
public Element getElement()
For a composite, the root element is the same as the root element of the content of the composite.
getElement
in interface HasElement
getElement
in class Component
public Stream<Component> getChildren()
A composite always has one child component, returned by
initContent()
.
getChildren
in class Component
Id
Copyright © 2019. All rights reserved.