org.vostok.vaadin.addon.hintfield
Class HintField<T extends com.vaadin.ui.AbstractField>

java.lang.Object
  extended by com.vaadin.server.AbstractClientConnector
      extended by com.vaadin.ui.AbstractComponent
          extended by com.vaadin.ui.AbstractComponentContainer
              extended by com.vaadin.ui.AbstractLayout
                  extended by com.vaadin.ui.AbstractOrderedLayout
                      extended by com.vaadin.ui.VerticalLayout
                          extended by org.vostok.vaadin.addon.hintfield.HintField<T>
Type Parameters:
T - field to extend, textfield, TextArea, etc...
All Implemented Interfaces:
com.vaadin.data.Buffered, com.vaadin.data.BufferedValidatable, com.vaadin.data.Property, com.vaadin.data.Property.Editor, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer, com.vaadin.data.Validatable, com.vaadin.event.ContextClickEvent.ContextClickNotifier, com.vaadin.event.LayoutEvents.LayoutClickNotifier, com.vaadin.event.MethodEventSource, com.vaadin.server.ClientConnector, com.vaadin.server.Sizeable, com.vaadin.shared.Connector, com.vaadin.ui.Component, com.vaadin.ui.Component.Focusable, com.vaadin.ui.ComponentContainer, com.vaadin.ui.Field, com.vaadin.ui.HasComponents, com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.Layout, com.vaadin.ui.Layout.AlignmentHandler, com.vaadin.ui.Layout.MarginHandler, com.vaadin.ui.Layout.SpacingHandler, java.io.Serializable, java.lang.Iterable<com.vaadin.ui.Component>

public class HintField<T extends com.vaadin.ui.AbstractField>
extends com.vaadin.ui.VerticalLayout
implements com.vaadin.ui.Field

HintField wrap a regular field (textefield, textearea,etc...) and replace the default error message with an hint field underneath..
This override the default error message display.

All rendering is done through css and html tag, therefore, fully customable.

Knows bugs

Message might be partially hidden if HintField's parent doesn't allow it to expand.

IMPORTANT : you can add vaidators etc to the field itself (textFiled,textArea...), but you MUST bind (FieldGroup) to the HintField himself, else hint won't show up.
If you use it outside of a filedGroup, you have to SetErrorComponent before commit (which is automatically done by FieldGroup).
See sample at http://vaadin.vostoksystem.eu

Version:
0.9beta
Author:
levreau.jerome@vostoksystem.eu
See Also:
Field, Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Field
com.vaadin.ui.Field.ValueChangeEvent
 
Nested classes/interfaces inherited from interface com.vaadin.data.Buffered
com.vaadin.data.Buffered.SourceException
 
Nested classes/interfaces inherited from interface com.vaadin.data.Property
com.vaadin.data.Property.Editor, com.vaadin.data.Property.ReadOnlyException, com.vaadin.data.Property.ReadOnlyStatusChangeEvent, com.vaadin.data.Property.ReadOnlyStatusChangeListener, com.vaadin.data.Property.ReadOnlyStatusChangeNotifier, com.vaadin.data.Property.Transactional<T>, com.vaadin.data.Property.ValueChangeListener, com.vaadin.data.Property.ValueChangeNotifier, com.vaadin.data.Property.Viewer
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Component
com.vaadin.ui.Component.ErrorEvent, com.vaadin.ui.Component.Event, com.vaadin.ui.Component.Focusable, com.vaadin.ui.Component.Listener
 
Nested classes/interfaces inherited from interface com.vaadin.server.ClientConnector
com.vaadin.server.ClientConnector.AttachEvent, com.vaadin.server.ClientConnector.AttachListener, com.vaadin.server.ClientConnector.ConnectorErrorEvent, com.vaadin.server.ClientConnector.DetachEvent, com.vaadin.server.ClientConnector.DetachListener
 
Nested classes/interfaces inherited from interface com.vaadin.server.Sizeable
com.vaadin.server.Sizeable.Unit
 
Nested classes/interfaces inherited from interface com.vaadin.ui.Layout
com.vaadin.ui.Layout.AlignmentHandler, com.vaadin.ui.Layout.MarginHandler, com.vaadin.ui.Layout.SpacingHandler
 
Nested classes/interfaces inherited from interface com.vaadin.ui.HasComponents
com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier, com.vaadin.ui.HasComponents.ComponentAttachEvent, com.vaadin.ui.HasComponents.ComponentAttachListener, com.vaadin.ui.HasComponents.ComponentDetachEvent, com.vaadin.ui.HasComponents.ComponentDetachListener
 
Field Summary
static java.lang.String COMPONENTTOPCSS
           
static java.lang.String ERRORLABELCSS
           
static java.lang.String OVERFLOWCSS
           
static java.lang.String REQUIREDCSS
           
 
Fields inherited from class com.vaadin.ui.AbstractOrderedLayout
ALIGNMENT_DEFAULT, components
 
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
HintField(T type)
           
 
Method Summary
 void addListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void addValidator(com.vaadin.data.Validator validator)
           
 void addValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void clear()
           
 void commit()
           
 void discard()
           
 void focus()
           
 java.lang.String getCaption()
           
 com.vaadin.server.ErrorMessage getComponentError()
           
 java.lang.String getConversionError()
           
 com.vaadin.data.util.converter.Converter getConverter()
           
 com.vaadin.server.ErrorHandler getErrorHandler()
           
 com.vaadin.server.Resource getIcon()
           
 T getMainField()
           
 com.vaadin.data.Property getPropertyDataSource()
           
 java.lang.String getRequiredError()
           
 int getTabIndex()
           
 java.lang.Class<? extends java.lang.String> getType()
           
 java.util.Collection<com.vaadin.data.Validator> getValidators()
           
 java.lang.Object getValue()
           
 boolean isBuffered()
           
 boolean isEmpty()
           
 boolean isInvalidAllowed()
           
 boolean isInvalidCommitted()
           
 boolean isModified()
           
 boolean isReadOnly()
           
 boolean isRequired()
           
 boolean isValid()
           
 void removeAllValidators()
           
 void removeListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void removeValidator(com.vaadin.data.Validator validator)
           
 void removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
           
 void setBuffered(boolean buffered)
           
 void setCaption(java.lang.String caption)
           
 void setComponentError(com.vaadin.server.ErrorMessage componentError)
          set component error, which is displayed in label, and turn label on
 void setConversionError(java.lang.String value)
           
 void setConvertedValue(java.lang.Object value)
           
 void setConverter(com.vaadin.data.util.converter.Converter<java.lang.Object,java.lang.Object> datamodelType)
          set convert for component, only if supported
 void setErrorHandler(com.vaadin.server.ErrorHandler errorHandler)
           
 void setIcon(com.vaadin.server.Resource icon)
           
 void setInvalidAllowed(boolean invalidValueAllowed)
           
 void setInvalidCommitted(boolean isCommitted)
           
 void setOverflow(boolean overflow)
          Deprecated. 
 void setPropertyDataSource(com.vaadin.data.Property newDataSource)
           
 void setReadOnly(boolean readOnly)
           
 void setRequired(boolean required)
           
 void setRequiredError(java.lang.String requiredMessage)
           
 void setStyleName(java.lang.String style)
           
 void setTabIndex(int tabIndex)
           
 void setValue(java.lang.Object newValue)
           
 void validate()
           
 void valueChange(com.vaadin.data.Property.ValueChangeEvent event)
           
 
Methods inherited from class com.vaadin.ui.VerticalLayout
getState
 
Methods inherited from class com.vaadin.ui.AbstractOrderedLayout
addComponent, addComponent, addComponentAsFirst, addLayoutClickListener, addListener, getComponent, getComponentAlignment, getComponentCount, getComponentIndex, getCustomAttributes, getDefaultComponentAlignment, getExpandRatio, getMargin, getState, isSpacing, iterator, readDesign, removeComponent, removeLayoutClickListener, removeListener, replaceComponent, setComponentAlignment, setDefaultComponentAlignment, setExpandRatio, setMargin, setMargin, setSpacing, writeDesign
 
Methods inherited from class com.vaadin.ui.AbstractLayout
readMargin, writeMargin
 
Methods inherited from class com.vaadin.ui.AbstractComponentContainer
addComponentAttachListener, addComponentDetachListener, addComponents, addListener, addListener, fireComponentAttachEvent, fireComponentDetachEvent, getComponentIterator, moveComponentsFrom, removeAllComponents, removeComponentAttachListener, removeComponentDetachListener, removeListener, removeListener, setHeight, setWidth
 
Methods inherited from class com.vaadin.ui.AbstractComponent
addContextClickListener, addListener, addShortcutListener, addStyleName, attach, beforeClientResponse, detach, findAncestor, fireComponentErrorEvent, fireComponentEvent, getActionManager, getData, getDebugId, getDescription, getErrorMessage, getExplicitImmediateValue, getHeight, getHeightUnits, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getWidth, getWidthUnits, isCaptionAsHtml, isConnectorEnabled, isEnabled, isImmediate, isOrHasAncestor, isResponsive, isVisible, removeContextClickListener, removeListener, removeShortcutListener, removeStyleName, setCaptionAsHtml, setData, setDebugId, setDescription, setEnabled, setHeight, setHeightUndefined, setId, setImmediate, setLocale, setParent, setPrimaryStyleName, setResponsive, setSizeFull, setSizeUndefined, setStyleName, setVisible, setWidth, setWidthUndefined
 
Methods inherited from class com.vaadin.server.AbstractClientConnector
addAttachListener, addDetachListener, addExtension, addListener, addListener, addListener, addMethodInvocationToQueue, createState, encodeState, equals, fireEvent, getAllChildrenIterable, getConnectorId, 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, setResource
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.vaadin.ui.Component
addListener, addStyleName, attach, getDescription, getId, getLocale, getParent, getPrimaryStyleName, getStyleName, getUI, isEnabled, isVisible, readDesign, removeListener, removeStyleName, setEnabled, setId, setParent, setPrimaryStyleName, setVisible, writeDesign
 
Methods inherited from interface com.vaadin.server.ClientConnector
addAttachListener, addDetachListener, beforeClientResponse, detach, encodeState, getExtensions, getRpcManager, getStateType, handleConnectorRequest, isAttached, isConnectorEnabled, markAsDirty, markAsDirtyRecursive, removeAttachListener, removeDetachListener, removeExtension, requestRepaint, requestRepaintAll, retrievePendingRpcCalls
 
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
 
Methods inherited from interface com.vaadin.ui.ComponentContainer
addComponents, addListener, addListener, getComponentIterator, moveComponentsFrom, removeAllComponents, removeListener, removeListener
 
Methods inherited from interface com.vaadin.ui.HasComponents.ComponentAttachDetachNotifier
addComponentAttachListener, addComponentDetachListener, removeComponentAttachListener, removeComponentDetachListener
 

Field Detail

ERRORLABELCSS

public static final java.lang.String ERRORLABELCSS
See Also:
Constant Field Values

REQUIREDCSS

public static final java.lang.String REQUIREDCSS
See Also:
Constant Field Values

COMPONENTTOPCSS

public static final java.lang.String COMPONENTTOPCSS
See Also:
Constant Field Values

OVERFLOWCSS

public static final java.lang.String OVERFLOWCSS
See Also:
Constant Field Values
Constructor Detail

HintField

public HintField(T type)
Parameters:
type - T inner field
Method Detail

getMainField

public T getMainField()
Returns:
t inner field

setStyleName

public void setStyleName(java.lang.String style)
Specified by:
setStyleName in interface com.vaadin.ui.Component
Overrides:
setStyleName in class com.vaadin.ui.AbstractComponent

setOverflow

@Deprecated
public void setOverflow(boolean overflow)
Deprecated. 

BETA, if the hint must show 'embed' or 'over' other component.
default to false (embed), hintfield expand as must as needed this is done with css and its beta (expect display bugs !) deprecated : doesn't work

Parameters:
overflow -

isRequired

public boolean isRequired()
Specified by:
isRequired in interface com.vaadin.ui.Field

setRequired

public void setRequired(boolean required)
Specified by:
setRequired in interface com.vaadin.ui.Field

setRequiredError

public void setRequiredError(java.lang.String requiredMessage)
Specified by:
setRequiredError in interface com.vaadin.ui.Field

getRequiredError

public java.lang.String getRequiredError()
Specified by:
getRequiredError in interface com.vaadin.ui.Field

isReadOnly

public boolean isReadOnly()
Specified by:
isReadOnly in interface com.vaadin.data.Property
Specified by:
isReadOnly in interface com.vaadin.ui.Component
Overrides:
isReadOnly in class com.vaadin.ui.AbstractComponent

setReadOnly

public void setReadOnly(boolean readOnly)
Specified by:
setReadOnly in interface com.vaadin.data.Property
Specified by:
setReadOnly in interface com.vaadin.ui.Component
Overrides:
setReadOnly in class com.vaadin.ui.AbstractComponent

getCaption

public java.lang.String getCaption()
Specified by:
getCaption in interface com.vaadin.ui.Component
Overrides:
getCaption in class com.vaadin.ui.AbstractComponent

setCaption

public void setCaption(java.lang.String caption)
Specified by:
setCaption in interface com.vaadin.ui.Component
Overrides:
setCaption in class com.vaadin.ui.AbstractComponent

getIcon

public com.vaadin.server.Resource getIcon()
Specified by:
getIcon in interface com.vaadin.ui.Component
Overrides:
getIcon in class com.vaadin.ui.AbstractComponent

setIcon

public void setIcon(com.vaadin.server.Resource icon)
Specified by:
setIcon in interface com.vaadin.ui.Component
Overrides:
setIcon in class com.vaadin.ui.AbstractComponent

getErrorHandler

public com.vaadin.server.ErrorHandler getErrorHandler()
Specified by:
getErrorHandler in interface com.vaadin.server.ClientConnector
Overrides:
getErrorHandler in class com.vaadin.server.AbstractClientConnector

setErrorHandler

public void setErrorHandler(com.vaadin.server.ErrorHandler errorHandler)
Specified by:
setErrorHandler in interface com.vaadin.server.ClientConnector
Overrides:
setErrorHandler in class com.vaadin.server.AbstractClientConnector

isInvalidCommitted

public boolean isInvalidCommitted()
Specified by:
isInvalidCommitted in interface com.vaadin.data.BufferedValidatable

setInvalidCommitted

public void setInvalidCommitted(boolean isCommitted)
Specified by:
setInvalidCommitted in interface com.vaadin.data.BufferedValidatable

commit

public void commit()
            throws com.vaadin.data.Buffered.SourceException,
                   com.vaadin.data.Validator.InvalidValueException
Specified by:
commit in interface com.vaadin.data.Buffered
Throws:
com.vaadin.data.Buffered.SourceException
com.vaadin.data.Validator.InvalidValueException

discard

public void discard()
             throws com.vaadin.data.Buffered.SourceException
Specified by:
discard in interface com.vaadin.data.Buffered
Throws:
com.vaadin.data.Buffered.SourceException

setBuffered

public void setBuffered(boolean buffered)
Specified by:
setBuffered in interface com.vaadin.data.Buffered

isBuffered

public boolean isBuffered()
Specified by:
isBuffered in interface com.vaadin.data.Buffered

isModified

public boolean isModified()
Specified by:
isModified in interface com.vaadin.data.Buffered

addValidator

public void addValidator(com.vaadin.data.Validator validator)
Specified by:
addValidator in interface com.vaadin.data.Validatable

removeValidator

public void removeValidator(com.vaadin.data.Validator validator)
Specified by:
removeValidator in interface com.vaadin.data.Validatable

removeAllValidators

public void removeAllValidators()
Specified by:
removeAllValidators in interface com.vaadin.data.Validatable

getValidators

public java.util.Collection<com.vaadin.data.Validator> getValidators()
Specified by:
getValidators in interface com.vaadin.data.Validatable

isValid

public boolean isValid()
Specified by:
isValid in interface com.vaadin.data.Validatable

validate

public void validate()
              throws com.vaadin.data.Validator.InvalidValueException
Specified by:
validate in interface com.vaadin.data.Validatable
Throws:
com.vaadin.data.Validator.InvalidValueException

isInvalidAllowed

public boolean isInvalidAllowed()
Specified by:
isInvalidAllowed in interface com.vaadin.data.Validatable

setInvalidAllowed

public void setInvalidAllowed(boolean invalidValueAllowed)
                       throws java.lang.UnsupportedOperationException
Specified by:
setInvalidAllowed in interface com.vaadin.data.Validatable
Throws:
java.lang.UnsupportedOperationException

setComponentError

public void setComponentError(com.vaadin.server.ErrorMessage componentError)
set component error, which is displayed in label, and turn label on

Overrides:
setComponentError in class com.vaadin.ui.AbstractComponent
Parameters:
componentError -

getComponentError

public com.vaadin.server.ErrorMessage getComponentError()
Overrides:
getComponentError in class com.vaadin.ui.AbstractComponent

getValue

public java.lang.Object getValue()
Specified by:
getValue in interface com.vaadin.data.Property

setValue

public void setValue(java.lang.Object newValue)
              throws com.vaadin.data.Property.ReadOnlyException
Specified by:
setValue in interface com.vaadin.data.Property
Throws:
com.vaadin.data.Property.ReadOnlyException

getType

public java.lang.Class<? extends java.lang.String> getType()
Specified by:
getType in interface com.vaadin.data.Property

addValueChangeListener

public void addValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
addValueChangeListener in interface com.vaadin.data.Property.ValueChangeNotifier

addListener

public void addListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
addListener in interface com.vaadin.data.Property.ValueChangeNotifier

removeValueChangeListener

public void removeValueChangeListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
removeValueChangeListener in interface com.vaadin.data.Property.ValueChangeNotifier

removeListener

public void removeListener(com.vaadin.data.Property.ValueChangeListener listener)
Specified by:
removeListener in interface com.vaadin.data.Property.ValueChangeNotifier

setPropertyDataSource

public void setPropertyDataSource(com.vaadin.data.Property newDataSource)
Specified by:
setPropertyDataSource in interface com.vaadin.data.Property.Viewer

getPropertyDataSource

public com.vaadin.data.Property getPropertyDataSource()
Specified by:
getPropertyDataSource in interface com.vaadin.data.Property.Viewer

focus

public void focus()
Specified by:
focus in interface com.vaadin.ui.Component.Focusable
Overrides:
focus in class com.vaadin.ui.AbstractComponent

getTabIndex

public int getTabIndex()
Specified by:
getTabIndex in interface com.vaadin.ui.Component.Focusable

setTabIndex

public void setTabIndex(int tabIndex)
Specified by:
setTabIndex in interface com.vaadin.ui.Component.Focusable

valueChange

public void valueChange(com.vaadin.data.Property.ValueChangeEvent event)
Specified by:
valueChange in interface com.vaadin.data.Property.ValueChangeListener

setConverter

public void setConverter(com.vaadin.data.util.converter.Converter<java.lang.Object,java.lang.Object> datamodelType)
set convert for component, only if supported

Parameters:
datamodelType -
See Also:
TextField

setConvertedValue

public void setConvertedValue(java.lang.Object value)
Parameters:
value -

setConversionError

public void setConversionError(java.lang.String value)
Parameters:
value - String for conversion message

getConversionError

public java.lang.String getConversionError()
Returns:
String from conversion message

getConverter

public com.vaadin.data.util.converter.Converter getConverter()
Returns:
Converter

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface com.vaadin.ui.Field
Returns:
Since:
1.3.0

clear

public void clear()
Specified by:
clear in interface com.vaadin.ui.Field
Since:
1.3.0