public class UiDataBindingNone extends Object implements UiDataBinding<Void>
UiDataBinding for no value (Void).getInstance()| Modifier and Type | Field and Description |
|---|---|
private static UiDataBindingNone |
INSTANCE |
| Constructor and Description |
|---|
UiDataBindingNone()
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeHandler(UiHandlerEventValueChange<Void> handler)
This method adds the given
UiHandlerEventValueChange to this object. |
void |
addValidator(ValueValidator<? super Void> validator)
This method adds the given
ValueValidator to this object. |
void |
addValidatorMandatory()
This is a convenience method for adding the most common validator
ValidatorMandatory. |
<P> void |
bind(TypedProperty<P> property,
UiWidgetWithValue<P> widget)
This method binds the given widget to the given property.
|
<P> UiWidgetWithValue<P> |
createAndBind(TypedProperty<P> property)
This method creates a
value based widget that is to be added as
child of the
widget owning this data-binding. |
<P> UiWidgetWithValue<P> |
createAndBind(TypedProperty<P> property,
String label)
This method is like
UiDataBinding.createAndBind(TypedProperty) but using the given label instead
of deriving it automatically. |
PropertyAccessor<Void,?> |
createPropertyAccessor(String property) |
<P> PropertyAccessor<Void,P> |
createPropertyAccessor(TypedProperty<P> property) |
boolean |
doValidate(ValidationState state,
Void value)
This method performs the actual validation using the
registered validators. |
static UiDataBinding<Void> |
getInstance() |
String |
getLabel(TypedProperty<?> property)
Determines the label to use for the given
property (including I18N, etc.). |
Void |
getOriginalValue()
This method gets the last value that has been
set. |
Void |
getRecentValue() |
Boolean |
getValidity() |
Void |
getValue()
This method gets the value of this object.
|
Void |
getValueAndValidate(ValidationState state)
This method is a combination of
AttributeReadValueAdvanced.getValue() and AbstractValidatableObject.validate(ValidationState). |
Void |
getValueDirect(Void template,
ValidationState state)
This method is a combination of
AttributeReadValueAdvanced.getValueOrException(Object) and
AbstractValidatableObject.validate(ValidationState). |
Void |
getValueOrException(Void template)
This method is like
AttributeReadValueAdvanced.getValue() but does NOT catch exceptions while parsing the value from the
user input. |
boolean |
isMandatory()
This method determines if
ValidatorMandatory (or a sub-class) has
been added to this object. |
boolean |
isModified()
This method determines if this object (or more precisely its value) is modified.
|
boolean |
removeChangeHandler(UiHandlerEventValueChange<Void> handler)
This method removes the given
UiHandlerEventValueChange from this object. |
boolean |
removeValidator(ValueValidator<? super Void> validator)
This method removes the given
ValueValidator from this object. |
void |
resetValue()
This method resets this widget.
|
void |
setModified(boolean modified)
This method sets the
modified attribute programatically. |
void |
setValidity(Boolean valid)
This method sets the value of
UiDataBinding.getValidity(). |
void |
setValue(Void value)
This method sets the
value. |
void |
setValue(Void value,
boolean forUser)
This is the generic variant of
AttributeWriteValueAdvanced.setValue(Object) and AttributeWriteValueAdvanced.setValueForUser(Object). |
void |
setValueForUser(Void value)
This method is like
AttributeWriteValueAdvanced.setValue(Object) but will NOT set the original
value and will set the modified to true (instead
of false). |
boolean |
validate(ValidationState state)
This method performs the actual validation.
|
private static final UiDataBindingNone INSTANCE
getInstance()public static UiDataBinding<Void> getInstance()
public Void getValueAndValidate(ValidationState state)
AttributeReadValueAdvanced.getValue() and AbstractValidatableObject.validate(ValidationState). It is
designed for API users implementing higher level dialog logic and is therefore easy to use. It performs a
validation and only on success it returns the value. null is not a valid value. Never call this method with
null as argument if <VALUE> is Void or anything else that considers
null as a valid value. It should be used for high-level UI nodes such as entire input forms
or (sub-)dialogs.getValueAndValidate in interface UiFeatureValueAndValidation<Void>state - is the ValidationState. Shall initially be created as new instance and passed on in
case of recursive validations. May also be null and will then be created internally
(in case you do not need the validation result).value or null if the
validation failed or null is the actual (valid)
value.public Void getValueDirect(Void template, ValidationState state) throws RuntimeException
AttributeReadValueAdvanced.getValueOrException(Object) and
AbstractValidatableObject.validate(ValidationState). It allows more efficient implementations as determining and creating
the value can be expensive. Saving changes requires validation AND
on success getting the value, while already validation requires getting the value. For composite UI
objects this effect would reinforce to multiply the number of calls to
AttributeReadValueAdvanced.getValueOrException(Object). UiFeatureValueAndValidation.getValueAndValidate(ValidationState).getValueDirect in interface UiFeatureValueAndValidation<Void>template - is the object where the data is filled in. May also be null - then this
method will create a new instance.state - is the ValidationState. If null the validation will be omitted,
otherwise an implicit validation is performed.current value. May be null (esp. if invalid).RuntimeException - if state is null no validation is performed and input
errors are directly thrown causing a fast fail. Otherwise if validation is performed all
RuntimeException are catched and according validation failures are
collected and
visualized by the UI.public void addChangeHandler(UiHandlerEventValueChange<Void> handler)
UiHandlerEventValueChange to this object.addChangeHandler in interface UiFeatureValue<Void>handler - is the UiHandlerEventValueChange to add.public boolean removeChangeHandler(UiHandlerEventValueChange<Void> handler)
UiHandlerEventValueChange from this object.removeChangeHandler in interface UiFeatureValue<Void>handler - is the UiHandlerEventValueChange to remove.true if the handler has been removed successfully, false
if it was NOT registered and nothing has
changed.public void setValue(Void value)
setValue in interface AttributeWriteValueAdvanced<Void>setValue in interface AttributeWriteValue<Void>value - is the new value. May be null unless otherwise stated.public void setValueForUser(Void value)
AttributeWriteValueAdvanced.setValue(Object) but will NOT set the original
value and will set the modified to true (instead
of false).setValueForUser in interface AttributeWriteValueAdvanced<Void>value - is the value to set.public void setValue(Void value, boolean forUser)
AttributeWriteValueAdvanced.setValue(Object) and AttributeWriteValueAdvanced.setValueForUser(Object). forUser is dynamic.setValue in interface AttributeWriteValueAdvanced<Void>value - is the new value to set.forUser - true for the semantics of AttributeWriteValueAdvanced.setValueForUser(Object),
false for AttributeWriteValueAdvanced.setValue(Object).public void resetValue()
setValue(AttributeReadValueAdvanced.getOriginalValue())
resetValue in interface AttributeWriteValueAdvanced<Void>public Void getValue()
null instead. If you want to do validation and give feedback to the
user please use AttributeReadValueAdvanced.getValueOrException(Object) instead. However, there are higher-level ways to do
this such as
getValueAndValidate.getValue in interface AttributeReadValueAdvanced<Void>getValue in interface AttributeReadValue<Void>null unless otherwise stated.public Void getValueOrException(Void template) throws RuntimeException
AttributeReadValueAdvanced.getValue() but does NOT catch exceptions while parsing the value from the
user input. Additionally it allows to provide a template object that gets populated. This allows advanced
features with polymorphism as you can also provide a sub-class of <VALUE>.getValueOrException in interface AttributeReadValueAdvanced<Void>template - is the object where the data is filled in. May also be null - then this
method will create a new instance.null if empty. If the value type is
String the empty String has to be returned if no value has been entered. In case
<VALUE> is a mutable object (java bean) and template is NOT null,
this method is supposed to return template.RuntimeException - if the entered value is invalid (e.g. paring caused a
NumberFormatException).public Void getOriginalValue()
set.
After calling AttributeWriteValueAdvanced.setValue(Object) the value can be modified (by the user
in case of a widget). Then calls to AttributeReadValueAdvanced.getValue() will return the current value with its potential
modifications (as a new object). This method will ensure to get the value that was
set before by the program. AttributeWriteValueAdvanced.resetValue() rely on this fact. Therefore AttributeReadValueAdvanced.getValue() will
always return a new instance.getOriginalValue in interface AttributeReadValueAdvanced<Void>public Void getRecentValue()
getRecentValue in interface UiDataBinding<Void>AttributeWriteValueAdvanced.setValue(Object, boolean). This is the
original value or the value that has
been set for the user after the original value was set for the last
time.public void addValidatorMandatory()
ValidatorMandatory.addValidatorMandatory in interface UiFeatureValidation<Void>public boolean isMandatory()
ValidatorMandatory (or a sub-class) has
been added to this object.isMandatory in interface UiFeatureValidation<Void>true if this the value of this object is mandatory.public void addValidator(ValueValidator<? super Void> validator)
ValueValidator to this object. All ValueValidators are
invoked in the same order as they are added by this method. They are
invoked no matter if the previous ValueValidators failed or
succeeded. You should always design ValueValidators in a robust and reusable way (e.g. a range validator
should accept null as valid input so it can be used for both mandatory and optional fields).addValidator in interface HasValueValidators<Void>validator - is the ValueValidator to add.public boolean removeValidator(ValueValidator<? super Void> validator)
ValueValidator from this object. removeValidator in interface HasValueValidators<Void>validator - is the ValueValidator to remove.true if the ValueValidator has actually been removed, false otherwise (it has NOT
previously been added).public boolean validate(ValidationState state)
validate in interface AbstractValidatableObjectstate - is the ValidationState. Shall initially be created as new instance and passed on in case of
recursive validations. May also be null and will then be created internally (in case you do not need
more feedback than a boolean result).true if the validation of this object has been successful, false otherwise (if there are
validation failures).public boolean doValidate(ValidationState state, Void value)
registered validators. It is called
from AbstractUiWidget (method doValidate) that
itself is called from AbstractValidatableObject.validate(ValidationState).doValidate in interface UiDataBinding<Void>state - is the ValidationState. Must NOT be null.value - is the current value of this object that has already be determined.true if the validation was successful, false otherwise (if there are
validation failures).public <P> void bind(TypedProperty<P> property, UiWidgetWithValue<P> widget)
UiFeatureValueAndValidation.getValueDirect(Object, net.sf.mmm.util.validation.api.ValidationState) and therefore all
other getValue* methods will automatically
read the value of the
given widget and set it to the given property of the <VALUE> to return.AttributeWriteValueAdvanced.setValue(Object, boolean) and therefore all other setValue* methods will
automatically get the property-value of the given property from the <VALUE>-object and
set that property-value to the given widget.bind in interface UiDataBinding<Void>P - is the generic type of the property value.property - is the TypedProperty representing the property to bind. It has to be a property
of <VALUE>.widget - is the value based widget to bind to the given property.UiDataBinding.createAndBind(TypedProperty)public <P> UiWidgetWithValue<P> createAndBind(TypedProperty<P> property)
value based widget that is to be added as
child of the
widget owning this data-binding. This will have to
following effects:
property type via
UiWidgetFactoryDatatype and can be highly customized.NlsBundleWithLookup (see
UiConfiguration.getLabelLookup()) mapping the
title with the properties to the localized display labels.ValueValidator is automatically created for the property
based on JSR 303 and will be
added to the new
widget.UiWidgetRangeField the minimum
and maximum value is set in case JSR 303 constraints such as Min,
DecimalMin, Max, and
DecimalMax are present. In the example the property foo will be
rendered as an integer spin box for the value range from -5 to +5.null.bound to the given
property.createAndBind in interface UiDataBinding<Void>P - is the generic type of the property value.property - is the TypedProperty representing the property to bind. It has to be a property
of <VALUE> and contain its property type.bound.public <P> UiWidgetWithValue<P> createAndBind(TypedProperty<P> property, String label)
UiDataBinding.createAndBind(TypedProperty) but using the given label instead
of deriving it automatically.createAndBind in interface UiDataBinding<Void>P - is the generic type of the property value.property - is the TypedProperty representing the property to bind. It has to be a property
of <VALUE> and contain its property type.label - is the label to use for the widget. See
UiWidgetField.getLabel().bound.public PropertyAccessor<Void,?> createPropertyAccessor(String property)
createPropertyAccessor in interface UiDataBinding<Void>property - is the property name.PropertyAccessor for the given property based on the
Pojo type <VALUE>.public <P> PropertyAccessor<Void,P> createPropertyAccessor(TypedProperty<P> property)
createPropertyAccessor in interface UiDataBinding<Void>P - is the generic type of the property to access - see TypedProperty.getPropertyType().property - is the TypedProperty.PropertyAccessor for the given property based on the
Pojo type <VALUE>.public void setModified(boolean modified)
modified attribute programatically. modified should be an implementation secret (another strategy may be
to get the value and check if it is equal to the original value what is however not as robust). Instead
methods such as AttributeWriteValueAdvanced.setValueForUser(Object) should be provided for API
users.setModified in interface AttributeWriteModifiedmodified - is the new value of AttributeReadModified.isModified().AttributeReadModified.isModified()public boolean isModified()
set for the last time. Often this is also called
dirty. A composite object is also modified if one of its children are modified. modified.isModified in interface AttributeReadModifiedtrue if this object has been modified, false otherwise (if no changes
have been made to this object).AttributeReadValueAdvanced.getOriginalValue(),
AttributeWriteValueAdvanced.setValueForUser(Object)public Boolean getValidity()
getValidity in interface UiDataBinding<Void>Boolean.TRUE if validation was successful, Boolean.FALSE if validation failed,
null if NOT validated (since
UiFeatureMessages.clearMessages() or something similar has been
called).public void setValidity(Boolean valid)
UiDataBinding.getValidity(). UiDataBinding.getValidity().setValidity in interface UiDataBinding<Void>valid - is the new value for UiDataBinding.getValidity(). May be null.public String getLabel(TypedProperty<?> property)
property (including I18N, etc.).getLabel in interface UiDataBinding<Void>property - is the TypedProperty.TypedProperty.getTitle()Copyright © 2001–2016 mmm-Team. All rights reserved.