com.vaadin.ui
Class CustomComponent

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.CustomComponent
All Implemented Interfaces:
MethodEventSource, ClientConnector, Sizeable, com.vaadin.shared.Connector, Component, HasComponents, java.io.Serializable, java.lang.Iterable<Component>
Direct Known Subclasses:
ColorPickerHistory, ColorPickerSelect, DragAndDropWrapper, LoginForm

public class CustomComponent
extends AbstractComponent
implements HasComponents

Custom component provides a simple implementation of the 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.

Since:
3.0
Author:
Vaadin Ltd.
See Also:
Serialized Form

Nested Class Summary
 
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.ui.Component
Component.ErrorEvent, Component.Event, Component.Focusable, Component.Listener
 
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.server.Sizeable
Sizeable.Unit
 
Field Summary
 
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
CustomComponent()
          Constructs a new custom component.
CustomComponent(Component compositionRoot)
          Constructs a new custom component.
 
Method Summary
 int getComponentCount()
          Gets the number of contained components.
protected  Component getCompositionRoot()
          Returns the composition root.
 java.util.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
addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, focus, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorMessage, getHeight, getHeightUnits, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getState, getState, getStyleName, getWidth, getWidthUnits, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isReadOnly, isVisible, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setHeight, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setReadOnly, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, fireEvent, getAllChildrenIterable, getConnectorId, getErrorHandler, getExtensions, getListeners, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, hasListeners, isAttached, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeAttachListener, removeDetachListener, removeExtension, removeListener, removeListener, removeListener, removeListener, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setErrorHandler, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getCaption, getDescription, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setParent, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
 
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.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setHeight, setSizeFull, setSizeUndefined, setWidth, setWidth
 

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 must 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 java.util.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 interface HasComponents
Specified by:
iterator in interface java.lang.Iterable<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)


Copyright © 2000-2014 Vaadin Ltd. All Rights Reserved.