to.etc.domui.component.form
Class DisplayOnlyPropertyBinding<T>

java.lang.Object
  extended by to.etc.domui.component.form.DisplayOnlyPropertyBinding<T>
All Implemented Interfaces:
IModelBinding, INodeErrorDelegate, IActionControl, IControl<T>, IDisplayControl<T>, IHasChangeListener

public class DisplayOnlyPropertyBinding<T>
extends java.lang.Object
implements IModelBinding, IControl<T>

A property binding specific for display-only controls. This binding will abort any attempt to put the associated displayonly field into a state that is not allowed (like setting it to editable, enabled or not-readonly).

Author:
Frits Jalvingh Created on Feb 15, 2010

Constructor Summary
DisplayOnlyPropertyBinding(IReadOnlyModel<?> model, PropertyMetaModel<T> propertyMeta, IDisplayControl<T> control)
           
 
Method Summary
 void clearMessage()
          Remove this-component's "current" error message, if present.
 java.lang.String getErrorLocation()
          When set this contains a user-understandable tekst indicating which control has the error.
 UIMessage getMessage()
           
 IValueChanged<?> getOnValueChanged()
          
 T getValue()
          Returns the current value of this input component.
 T getValueSafe()
          Like IDisplayControl.getValue() this returns the value of the component, but this returns null if the value was invalid.
 boolean hasError()
          Returns T if this control is currently in error state, meaning it's input is in some way invalid.
 boolean isDisabled()
          Returns T if the control is currently in disabled.
 boolean isMandatory()
          Returns T if this control is a mandatory input.
 boolean isReadOnly()
          Returns T if the control is currently in readonly mode.
 void moveControlToModel()
           
 void moveModelToControl()
           
 void setControlsEnabled(boolean on)
           
 void setDisabled(boolean d)
          Set the input to disabled mode.
 void setErrorLocation(java.lang.String errorLocation)
          When set this contains a user-understandable tekst indicating which control has the error.
 void setMandatory(boolean ro)
          Make the control mandatory.
 UIMessage setMessage(UIMessage m)
          This sets a message (an error, warning or info message) on this control.
 void setOnValueChanged(IValueChanged<?> listener)
          
 void setReadOnly(boolean ro)
          Sets the input to readonly-mode.
 void setTestID(java.lang.String testID)
          Set the testID for external test software.
 void setValue(T value)
          Set a new value into this control.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DisplayOnlyPropertyBinding

public DisplayOnlyPropertyBinding(IReadOnlyModel<?> model,
                                  PropertyMetaModel<T> propertyMeta,
                                  IDisplayControl<T> control)
Method Detail

moveControlToModel

public void moveControlToModel()
                        throws java.lang.Exception
Specified by:
moveControlToModel in interface IModelBinding
Throws:
java.lang.Exception

moveModelToControl

public void moveModelToControl()
                        throws java.lang.Exception
Specified by:
moveModelToControl in interface IModelBinding
Throws:
java.lang.Exception

setControlsEnabled

public void setControlsEnabled(boolean on)
Specified by:
setControlsEnabled in interface IModelBinding

getValue

public T getValue()
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:

setValue

public void setValue(T value)
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>

getValueSafe

public T getValueSafe()
Like IDisplayControl.getValue() this returns the value of the component, but this returns null if the value was invalid. For this method NULL either means the value was invalid OR it's content was empty. To distinguish between the two call IControl.hasError() or use IDisplayControl.getValue() instead of this call.

Specified by:
getValueSafe in interface IControl<T>
Returns:
See Also:
IControl.getValueSafe()

getOnValueChanged

public IValueChanged<?> getOnValueChanged()

Specified by:
getOnValueChanged in interface IHasChangeListener
See Also:
IHasChangeListener.getOnValueChanged()

setOnValueChanged

public void setOnValueChanged(IValueChanged<?> listener)

Specified by:
setOnValueChanged in interface IHasChangeListener

hasError

public boolean hasError()
Returns T if this control is currently in error state, meaning it's input is in some way invalid. This call internally calls getValue() to ensure it's error state is valid for the current data held.

Specified by:
hasError in interface IControl<T>
Returns:
See Also:
IControl.hasError()

isDisabled

public boolean isDisabled()
Description copied from interface: IControl
Returns T if the control is currently in disabled. Controls that do not have a readonly ability (comboboxes) will use disabled as the readonly state. For those controls the readonly state mirrors the disabled state.

Specified by:
isDisabled in interface IControl<T>
Returns:

setDisabled

public void setDisabled(boolean d)
Set the input to disabled mode.

Specified by:
setDisabled in interface IActionControl
See Also:
IActionControl.setDisabled(boolean)

isMandatory

public boolean isMandatory()
Description copied from interface: IControl
Returns T if this control is a mandatory input.

Specified by:
isMandatory in interface IControl<T>
Returns:

setMandatory

public void setMandatory(boolean ro)
Make the control mandatory.

Specified by:
setMandatory in interface IControl<T>
See Also:
IControl.setMandatory(boolean)

isReadOnly

public boolean isReadOnly()
Description copied from interface: IControl
Returns T if the control is currently in readonly mode. Controls that do not have a readonly ability (comboboxes) will use disabled as the readonly state. For those controls the readonly state mirrors the disabled state.

Specified by:
isReadOnly in interface IControl<T>
Returns:

setReadOnly

public void setReadOnly(boolean ro)
Sets the input to readonly-mode. Components that do not implement readonly mode (comboboxes) will usually set themselves to disabled which works much the same.

Specified by:
setReadOnly in interface IControl<T>
See Also:
IControl.setReadOnly(boolean)

setTestID

public void setTestID(java.lang.String testID)
Set the testID for external test software.

Specified by:
setTestID in interface IActionControl
Specified by:
setTestID in interface IDisplayControl<T>

clearMessage

public void clearMessage()
Description copied from interface: INodeErrorDelegate
Remove this-component's "current" error message, if present.

Specified by:
clearMessage in interface INodeErrorDelegate
See Also:
INodeErrorDelegate.clearMessage()

getMessage

public UIMessage getMessage()
Specified by:
getMessage in interface INodeErrorDelegate

setMessage

public UIMessage setMessage(UIMessage m)
Description copied from interface: INodeErrorDelegate
This sets a message (an error, warning or info message) on this control. If the control already has an error then we check if the severity of the new error is higher than the severity of the existing one; only in that case will the error be removed. To clear the error message call clearMessage().

Specified by:
setMessage in interface INodeErrorDelegate

getErrorLocation

public java.lang.String getErrorLocation()
Description copied from interface: IControl
When set this contains a user-understandable tekst indicating which control has the error. It usually contains the "label" associated with the control, and is set automatically by form builders if possible.

Specified by:
getErrorLocation in interface IControl<T>
Returns:

setErrorLocation

public void setErrorLocation(java.lang.String errorLocation)
Description copied from interface: IControl
When set this contains a user-understandable tekst indicating which control has the error. It usually contains the "label" associated with the control, and is set automatically by form builders if possible.

Specified by:
setErrorLocation in interface IControl<T>