com.vaadin.ui
Class CustomField<T>

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractField<T>
              extended by com.vaadin.ui.CustomField<T>
Type Parameters:
T - field value type
All Implemented Interfaces:
Buffered, BufferedValidatable, Property<T>, Property.Editor, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer, Validatable, Action.ShortcutNotifier, MethodEventSource, ClientConnector, RpcTarget, Sizeable, com.vaadin.shared.Connector, Component, Component.Focusable, Field<T>, HasComponents, java.io.Serializable, java.lang.Iterable<Component>

public abstract class CustomField<T>
extends AbstractField<T>
implements HasComponents

A Field whose UI content can be constructed by the user, enabling the creation of e.g. form fields by composing Vaadin components. Customization of both the visual presentation and the logic of the field is possible. Subclasses must implement AbstractField.getType() and initContent(). Most custom fields can simply compose a user interface that calls the methods AbstractField.setInternalValue(Object) and AbstractField.getInternalValue() when necessary. It is also possible to override AbstractField.validate(), AbstractField.setInternalValue(Object), AbstractField.commit(), AbstractField.setPropertyDataSource(Property), AbstractField.isEmpty() and other logic of the field. Methods overriding AbstractField.setInternalValue(Object) should also call the corresponding superclass method.

Since:
7.0
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractField
AbstractField.FocusShortcut, AbstractField.ReadOnlyStatusChangeEvent
 
Nested classes/interfaces inherited from class com.vaadin.ui.AbstractComponent
AbstractComponent.ComponentErrorEvent, AbstractComponent.ComponentErrorHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
Component.ErrorEvent, Component.ErrorListener, Component.Event, Component.Focusable, Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
Sizeable.Unit
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.Transactional<T>, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer
 
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
CustomField()
          Constructs a new custom field.
 
Method Summary
 void attach()
          Constructs the content and notifies it that the CustomField is attached to a window.
 java.util.Iterator<Component> getComponentIterator()
          Deprecated. As of 7.0, use iterator() instead.
protected  Component getContent()
          Returns the content (UI) of the custom component.
protected abstract  Component initContent()
          Create the content component or layout for the field.
 boolean isComponentVisible(Component childComponent)
          Checks if the child component is visible.
 java.util.Iterator<Component> iterator()
          Gets an iterator to the collection of contained components.
 void setHeight(float height, Sizeable.Unit unit)
          Sets the height of the object.
 void setWidth(float height, Sizeable.Unit unit)
          Sets the width of the object.
 
Methods inherited from class com.vaadin.ui.AbstractField
addListener, addListener, addReadOnlyStatusChangeListener, addValidator, addValueChangeListener, beforeClientResponse, commit, detach, discard, fireReadOnlyStatusChange, fireValueChange, focus, getConversionError, getConversionError, getConvertedValue, getConverter, getCurrentBufferedSourceException, getErrorMessage, getInternalValue, getPropertyDataSource, getRequiredError, getState, getTabIndex, getType, getValidators, getValue, isBuffered, isEmpty, isInvalidAllowed, isInvalidCommitted, isModified, isReadOnly, isRequired, isValid, isValidationVisible, readOnlyStatusChange, removeAllValidators, removeListener, removeListener, removeReadOnlyStatusChangeListener, removeValidator, removeValueChangeListener, setBuffered, setConversionError, setConvertedValue, setConverter, setConverter, setCurrentBufferedSourceException, setInternalValue, setInvalidAllowed, setInvalidCommitted, setPropertyDataSource, setReadOnly, setRequired, setRequiredError, setTabIndex, setValidationVisible, setValue, setValue, shouldHideErrors, toString, validate, validate, valueChange
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addListener, addListener, addListener, addListener, addShortcutListener, addStyleName, findAncestor, fireComponentErrorEvent, fireComponentEvent, fireEvent, getActionManager, getCaption, getComponentError, getData, getDebugId, getDescription, getErrorHandler, getHeight, getHeightUnits, getIcon, getId, getListeners, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, handleError, hasListeners, isConnectorEnabled, isEnabled, isImmediate, isVisible, removeListener, removeListener, removeListener, removeListener, removeListener, removeShortcutListener, removeStyleName, setCaption, setComponentError, setData, setDebugId, setDescription, setEnabled, setErrorHandler, setHeight, setIcon, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addExtension, addMethodInvocationToQueue, createState, encodeState, getAllChildrenIterable, getConnectorId, getExtensions, getResource, getRpcManager, getRpcProxy, getSession, getStateType, getUI, handleConnectorRequest, markAsDirty, markAsDirtyRecursive, registerRpc, registerRpc, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setResource
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, getCaption, getIcon, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isReadOnly, isVisible, removeListener, removeStyleName, setCaption, setEnabled, setIcon, setId, setPrimaryStyleName, setReadOnly, setStyleName, setVisible
 
Methods inherited from interface com.vaadin.server.ClientConnector
beforeClientResponse, detach, encodeState, getExtensions, getStateType, handleConnectorRequest, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls, setParent
 
Methods inherited from interface com.vaadin.shared.Connector
getConnectorId
 
Methods inherited from interface com.vaadin.server.RpcTarget
getRpcManager
 
Methods inherited from interface com.vaadin.server.Sizeable
getHeight, getHeightUnits, getWidth, getWidthUnits, setHeight, setSizeFull, setSizeUndefined, setWidth
 
Methods inherited from interface com.vaadin.event.Action.ShortcutNotifier
addShortcutListener, removeShortcutListener
 

Constructor Detail

CustomField

public CustomField()
Constructs a new custom field.

The component is implemented by wrapping the methods of the composition root component given as parameter. The composition root must be set before the component can be used.

Method Detail

attach

public void attach()
Constructs the content and notifies it that the CustomField is attached to a window.

Specified by:
attach in interface ClientConnector
Specified by:
attach in interface Component
Overrides:
attach in class AbstractField<T>
See Also:
Component.attach()

getContent

protected Component getContent()
Returns the content (UI) of the custom component.

Returns:
Component

initContent

protected abstract Component initContent()
Create the content component or layout for the field. Subclasses of CustomField should implement this method. Note that this method is called when the CustomField is attached to a layout or when getContent() is called explicitly for the first time. It is only called once for a CustomField.

Returns:
Component representing the UI of the CustomField

setHeight

public void setHeight(float height,
                      Sizeable.Unit unit)
Description copied from interface: Sizeable
Sets the height of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setHeight in interface Sizeable
Overrides:
setHeight in class AbstractComponent
Parameters:
height - the height of the object.
unit - the unit used for the width.

setWidth

public void setWidth(float height,
                     Sizeable.Unit unit)
Description copied from interface: Sizeable
Sets the width of the object. Negative number implies unspecified size (terminal is free to set the size).

Specified by:
setWidth in interface Sizeable
Overrides:
setWidth in class AbstractComponent
Parameters:
height - the width of the object.
unit - the unit used for the width.

getComponentIterator

@Deprecated
public java.util.Iterator<Component> getComponentIterator()
Deprecated. As of 7.0, use iterator() instead.


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.

isComponentVisible

public boolean isComponentVisible(Component childComponent)
Description copied from interface: HasComponents
Checks if the child component is visible. This method allows hiding a child component from updates and communication to and from the client. This is useful for components that show only a limited number of its children at any given time and want to allow updates only for the children that are visible (e.g. TabSheet has one tab open at a time).

Note that this will prevent updates from reaching the child even though the child itself is set to visible. Also if a child is set to invisible this will not force it to be visible.

Specified by:
isComponentVisible in interface HasComponents
Parameters:
childComponent - The child component to check
Returns:
true if the child component is visible to the user, false otherwise


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