to.etc.domui.component.misc
Class DisplayValue<T>

java.lang.Object
  extended by to.etc.domui.dom.css.CssBase
      extended by to.etc.domui.dom.html.NodeBase
          extended by to.etc.domui.dom.html.NodeContainer
              extended by to.etc.domui.dom.html.Span
                  extended by to.etc.domui.component.misc.DisplayValue<T>
All Implemented Interfaces:
java.lang.Iterable<NodeBase>, IModelBinding, IBindable, IConvertable<T>, INodeErrorDelegate, IDisplayControl<T>, IRenderNBSPIfEmpty

public class DisplayValue<T>
extends Span
implements IDisplayControl<T>, IBindable, IConvertable<T>, IRenderNBSPIfEmpty

This is a special control which can be used to display all kinds of values. It behaves as a "span" containing some value that can be converted, translated and whatnot. It is meant for not too complex values that are usually represented as a span.

Author:
Frits Jalvingh Created on Feb 15, 2010

Constructor Summary
DisplayValue(java.lang.Class<T> valueClass)
           
DisplayValue(T literal)
           
 
Method Summary
 IBinder bind()
          Return the binder for this control.
 void createContent()
          Render the content in some way.
 void defineFrom(PropertyMetaModel<?> pmm)
           
 IConverter<T> getConverter()
          See IConvertable.getConverter().
 java.lang.String getEmptyString()
           
 INodeContentRenderer<T> getRenderer()
          The content renderer to use.
 T getValue()
          Returns the current value of this input component.
 java.lang.Class<T> getValueClass()
           
 boolean isBound()
          Returns T if this control is bound to some data value.
 void setConverter(IConverter<T> converter)
          See IConvertable.setConverter(IConverter).
 void setEmptyString(java.lang.String emptyString)
           
 void setRenderer(INodeContentRenderer<T> renderer)
           
 void setValue(T v)
          Set a new value into this control.
 
Methods inherited from class to.etc.domui.dom.html.Span
visit
 
Methods inherited from class to.etc.domui.dom.html.NodeContainer
add, add, add, addTable, canContain, delegateTo, findChildIndex, forceRebuild, getChild, getChildCount, getChildren, getDeepChild, getDeepChildren, getErrorFence, internalCheckNotDirty, internalClearDelta, internalClearDeltaFully, internalGetOldChildren, internalShelve, internalUnshelve, iterator, moveControlToModel, moveModelToControl, onRefresh, removeAllChildren, removeChild, removeChild, replaceChild, setControlsEnabled, setErrorFence, setErrorFence, setText, setValue
 
Methods inherited from class to.etc.domui.dom.html.NodeBase
$, acceptRequestParameter, addCssClass, addGlobalMessage, afterCreateContent, appendAfterMe, appendBeforeMe, appendCreateJS, appendJavascript, build, changed, clearFocusRequested, clearGlobalMessage, clearGlobalMessage, clearGlobalMessage, clearMessage, componentHandleWebAction, findComponentBundle, getActualID, getClicked, getComponentBundle, getCreateJS, getCssClass, getErrorDelegate, getErrorLocation, getMessage, getOnClickJS, getOnMouseDownJS, getPage, getParent, getParent, getParent, getSharedContext, getSpecialAttribute, getSpecialAttributeList, getTag, getTestID, getTitle, getUserObject, handleDrop, hasCssClass, hasError, internalGetOldParent, internalHasChangedAttributes, internalNeedClickHandler, internalOnClicked, internalSetHasChangedAttributes, internalSetHasChangedAttributes, internalSetTag, isBuilt, isFocusRequested, onAddedToPage, onBeforeFullRender, onForceRebuild, onHeaderContributors, onRemoveFromPage, onShelve, onUnshelve, refresh, remove, removeCssClass, renderJavascriptState, replaceWith, setClicked, setComponentBundle, setCssClass, setErrorDelegate, setErrorLocation, setFocus, setMessage, setOnClickJS, setOnMouseDownJS, setSpecialAttribute, setTestID, setTitle, setUserObject, stretchHeight, toString
 
Methods inherited from class to.etc.domui.dom.css.CssBase
getBackgroundAttachment, getBackgroundColor, getBackgroundImage, getBackgroundPosition, getBackgroundRepeat, getBorderBottomColor, getBorderBottomStyle, getBorderBottomWidth, getBorderLeftColor, getBorderLeftStyle, getBorderLeftWidth, getBorderRightColor, getBorderRightStyle, getBorderRightWidth, getBorderTopColor, getBorderTopStyle, getBorderTopWidth, getBottom, getCachedStyle, getClear, getColor, getDisplay, getFloat, getFontFamily, getFontSize, getFontSizeAdjust, getFontStyle, getFontVariant, getFontWeight, getHeight, getLeft, getLineHeight, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOverflow, getPosition, getRight, getTextAlign, getTop, getTransform, getVerticalAlign, getVisibility, getWidth, getZIndex, internalSetDisplay, setBackgroundAttachment, setBackgroundColor, setBackgroundImage, setBackgroundPosition, setBackgroundRepeat, setBorder, setBorder, setBorderBottomColor, setBorderBottomStyle, setBorderBottomWidth, setBorderColor, setBorderLeftColor, setBorderLeftStyle, setBorderLeftWidth, setBorderRightColor, setBorderRightStyle, setBorderRightWidth, setBorderStyle, setBorderTopColor, setBorderTopStyle, setBorderTopWidth, setBorderWidth, setBottom, setBottom, setCachedStyle, setClear, setColor, setDisplay, setFloat, setFontFamily, setFontSize, setFontSizeAdjust, setFontStyle, setFontVariant, setFontWeight, setHeight, setLeft, setLeft, setLineHeight, setMargin, setMarginBottom, setMarginLeft, setMarginRight, setMarginTop, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setOverflow, setPosition, setRight, setRight, setTextAlign, setTop, setTop, setTransform, setVerticalAlign, setVisibility, setWidth, setZIndex
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface to.etc.domui.dom.html.IDisplayControl
setTestID
 

Constructor Detail

DisplayValue

public DisplayValue(@Nonnull
                    java.lang.Class<T> valueClass)

DisplayValue

public DisplayValue(T literal)
Method Detail

getValueClass

@Nonnull
public java.lang.Class<T> getValueClass()

createContent

public void createContent()
                   throws java.lang.Exception
Render the content in some way. It uses the following logic: If a converter is present it MUST convert the value, and it's result is shown.

Overrides:
createContent in class NodeBase
Throws:
java.lang.Exception
See Also:
NodeBase.createContent()

getConverter

@Nullable
public IConverter<T> getConverter()
See IConvertable.getConverter(). This returns null if no converter has been set. It also returns null if a default converter is used.

Specified by:
getConverter in interface IConvertable<T>
Returns:

setConverter

public void setConverter(@Nullable
                         IConverter<T> converter)
See IConvertable.setConverter(IConverter).

Specified by:
setConverter in interface IConvertable<T>
Parameters:
converter -

getRenderer

@Nullable
public INodeContentRenderer<T> getRenderer()
The content renderer to use. This gets called only if no converter is set.

Returns:

setRenderer

public void setRenderer(@Nullable
                        INodeContentRenderer<T> renderer)

getEmptyString

@Nullable
public java.lang.String getEmptyString()

setEmptyString

public void setEmptyString(@Nullable
                           java.lang.String emptyString)

bind

@Nonnull
public IBinder bind()
Return the binder for this control.

Specified by:
bind in interface IBindable
Returns:
See Also:
IBindable.bind()

isBound

public boolean isBound()
Returns T if this control is bound to some data value.

Specified by:
isBound in interface IBindable
Returns:
See Also:
IBindable.isBound()

getValue

@Nullable
public T getValue()
Description copied from interface: IDisplayControl
Returns the current value of this input component. If the component contains no value this returns null. All text input components will return null when their value is the empty string! If the component, during conversion or validation of the input value, discovers that the input is invalid it will set itself in "error" mode, post an error message up the form, and throw a ValidationException. This means that this call either delivers correct input (as defined by it's converter and validators), null (when empty) or throws an exception. When a ValidationException occurs the framework mostly ignores it - it does not produce a stacktrace or error in the client. Instead the resulting error as posted by the error handling framework gets displayed on the form when the request completes.

To get the value of a component while ignoring exceptions call #getValueSafe().

Specified by:
getValue in interface IDisplayControl<T>
Returns:
See Also:
IDisplayControl.getValue()

setValue

public void setValue(@Nullable
                     T v)
Description copied from interface: IDisplayControl
Set a new value into this control. Setting a value to null means the control holds no value. This value is converted to a presentable form using any (implicitly) defined converters; it will not be validated though! This means that if you set an invalid value for a validator this will not be seen until the value is gotten from the control again.

Specified by:
setValue in interface IDisplayControl<T>

defineFrom

public void defineFrom(@Nonnull
                       PropertyMetaModel<?> pmm)