public class CustomComponent extends AbstractComponent implements HasComponents
Component
interface to allow creating new UI components by composition of existing
server-side components.
The component is used by inheriting the CustomComponent class and setting the
composition root component. The composition root must be set with
setCompositionRoot(Component) before the CustomComponent is used,
such as by adding it to a layout, so it is preferable to set it in the
constructor.
The composition root itself can contain more components. The advantage of wrapping it in a CustomComponent is that its details, such as interfaces, are hidden from the users of the component, thereby contributing to information hiding.
The CustomComponent does not display the caption of the composition root, so if you want to have it shown in the layout where the custom component is contained, you need to set it as caption of the CustomComponent.
The component expands horizontally and has undefined height by default.
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListenerComponent.ErrorEvent, Component.Event, Component.Focusable, Component.ListenerClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListenerSizeable.UnitDESIGN_ATTR_PLAIN_TEXTSIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS| Constructor and Description |
|---|
CustomComponent()
Constructs a new custom component.
|
CustomComponent(Component compositionRoot)
Constructs a new custom component.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getComponentCount()
Gets the number of contained components.
|
protected Component |
getCompositionRoot()
Returns the composition root.
|
Iterator<Component> |
iterator()
Gets an iterator to the collection of contained components.
|
protected void |
setCompositionRoot(Component compositionRoot)
Sets the composition root for the component.
|
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getCustomAttributes, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getState, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isResponsive, isVisible, readDesign, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setCaptionAsHtml, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setHeightUndefined, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setStyleName, setVisible, setWidth, setWidth, setWidthUndefined, writeDesignaddAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hashCode, hasListeners, isAttached, isThis, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResourceclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitaddListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, readDesign, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible, writeDesignaddAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandlergetConnectorIdgetHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefinedforEach, spliteratorpublic CustomComponent()
Note that you must set the composition root before the component can be used, preferably in the constructor.
public CustomComponent(Component compositionRoot)
compositionRoot - the root of the composition component tree. It must not be
null.protected Component getCompositionRoot()
protected void setCompositionRoot(Component compositionRoot)
You must set the composition root to a non-null value before the component can be used. You can change it later.
compositionRoot - the root of the composition component tree.public Iterator<Component> iterator()
HasComponentsiterator in interface HasComponentsiterator in interface Iterable<Component>public int getComponentCount()
#getComponentIterator().Copyright © 2022 Vaadin Ltd. All rights reserved.