Class CustomComponent
- java.lang.Object
-
- com.vaadin.server.AbstractClientConnector
-
- com.vaadin.ui.AbstractComponent
-
- com.vaadin.ui.CustomComponent
-
- All Implemented Interfaces:
ContextClickEvent.ContextClickNotifier
,MethodEventSource
,ClientConnector
,Sizeable
,Connector
,Component
,HasComponents
,Serializable
,Iterable<Component>
- Direct Known Subclasses:
ColorPickerHistory
,ColorPickerSelect
,DragAndDropWrapper
public class CustomComponent extends AbstractComponent implements HasComponents
Custom component provides a simple implementation of theComponent
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.
- Since:
- 3.0
- Author:
- Vaadin Ltd.
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
ClientConnector.AttachEvent, ClientConnector.AttachListener, ClientConnector.ConnectorErrorEvent, ClientConnector.DetachEvent, ClientConnector.DetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
-
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
HasComponents.ComponentAttachDetachNotifier, HasComponents.ComponentAttachEvent, HasComponents.ComponentAttachListener, HasComponents.ComponentDetachEvent, HasComponents.ComponentDetachListener
-
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
-
-
Field Summary
-
Fields inherited from class com.vaadin.ui.AbstractComponent
DESIGN_ATTR_PLAIN_TEXT
-
Fields inherited from interface com.vaadin.server.Sizeable
SIZE_UNDEFINED, UNITS_CM, UNITS_EM, UNITS_EX, UNITS_INCH, UNITS_MM, UNITS_PERCENTAGE, UNITS_PICAS, UNITS_PIXELS, UNITS_POINTS
-
-
Constructor Summary
Constructors Constructor Description CustomComponent()
Constructs a new custom component.CustomComponent(Component compositionRoot)
Constructs a new custom component.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.-
Methods inherited from class com.vaadin.ui.AbstractComponent
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, writeDesign
-
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, 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, setResource
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getErrorHandler, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler
-
Methods inherited from interface com.vaadin.ui.Component
addListener, 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, writeDesign
-
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
-
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setHeightUndefined, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthUndefined
-
-
-
-
Constructor Detail
-
CustomComponent
public CustomComponent()
Constructs a new custom component.Note that you must set the composition root before the component can be used, preferably in the constructor.
-
CustomComponent
public CustomComponent(Component compositionRoot)
Constructs a new custom component.- Parameters:
compositionRoot
- the root of the composition component tree. It must not be null.
-
-
Method Detail
-
getCompositionRoot
protected Component getCompositionRoot()
Returns the composition root.- Returns:
- the Component Composition root.
-
setCompositionRoot
protected void setCompositionRoot(Component compositionRoot)
Sets the composition root for the component.You must set the composition root to a non-null value before the component can be used. You can change it later.
- Parameters:
compositionRoot
- the root of the composition component tree.
-
iterator
public Iterator<Component> iterator()
Description copied from interface:HasComponents
Gets an iterator to the collection of contained components. Using this iterator it is possible to step through all components contained in this container.- Specified by:
iterator
in interfaceHasComponents
- Specified by:
iterator
in interfaceIterable<Component>
- Returns:
- the component iterator.
-
getComponentCount
public int getComponentCount()
Gets the number of contained components. Consistent with the iterator returned by#getComponentIterator()
.- Returns:
- the number of contained components (zero or one)
-
-