VALUE
- is the generic type of the value
.public interface UiDataBinding<VALUE> extends UiFeatureValueAndValidation<VALUE>, AttributeWriteModified
values
with
widgets
. UiWidgetCustomComposite
and derived classes where it allows
comfortable property-bindings
. public class MyBeanFrom extendsWithUiWidgetCustomGridPanel
{ public MyBeanForm( UiContext
context) { super(context, MyBean.class);UiWidgetWithValue
<Integer> fooField = getDataBinding().createAndBind
(MyBean.PROPERTY_FOO); getDelegate().addChildren(fooField);UiWidgetWithValue
<BarType> barField = getDataBinding().createAndBind
(MyBean.PROPERTY_BAR); getDelegate().addChildren(barField); ... } }
MyBean
like this:
public class MyBean implementsThis will automatically do all the nasty work for you as described inPojo
{ public static finalTypedProperty
<Integer> PROPERTY_FOO = newTypedProperty
<>("foo"); public static finalTypedProperty
<BarType> PROPERTY_BAR = newTypedProperty
<>("bar"); @Min
(-5) @Max
(5) private int foo; @Mandatory
private BarType bar; public int getFoo() { return this.foo; } public void setFoo(int foo) { this.foo = foo; } public BarType getBar() { return this.bar; } public void setBar(BarType bar) { this.bar = bar; } ... }
createAndBind(TypedProperty)
. Otherwise you would have to do something like this in your widget:
public class MyBeanFrom extendsUiWidgetCustomGridPanel
{ private final UiWidgetIntegerField
fooField; private final MyBarCustomWidget barField; public MyBeanForm(UiContext
context) { super(context, MyBean.class); // create field for property "foo" by hand... this.fooField = getContext().getWidgetFactory().create(UiWidgetIntegerField
.class); Integer min = Integer.valueOf(-5); this.fooField.setMinimumValue(min); Integer max = Integer.valueOf(5); this.fooField.setMaximumValue(max); NlsBundleMyLabelsRoot labels =NlsAccess.getBundleFactory()
.createBundle(NlsBundleMyLabelsRoot.class); this.fooField.setLabel(labels.foo()); this.fooField.addValidator(newValidatorRange
<Integer>(min, max)); this.fooField.addValidator(ValidatorMandatory.getInstance()
); getDelegate().addChildren(this.fooField); // create field for property "bar" by hand... this.barField = new MyBarCustomWidget(context); this.barField.setLabel(labels.bar()); this.barField.addValidator(ValidatorMandatory.getInstance()
); getDelegate().addChildren(this.barField); ... }
Modifier and Type | Method and Description |
---|---|
<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
createAndBind(TypedProperty) but using the given label instead
of deriving it automatically. |
PropertyAccessor<VALUE,?> |
createPropertyAccessor(String property) |
<P> PropertyAccessor<VALUE,P> |
createPropertyAccessor(TypedProperty<P> property) |
boolean |
doValidate(ValidationState state,
VALUE value)
This method performs the actual validation using the
registered validators. |
String |
getLabel(TypedProperty<?> property)
Determines the label to use for the given
property (including I18N, etc.). |
VALUE |
getRecentValue() |
Boolean |
getValidity() |
void |
setValidity(Boolean validity)
This method sets the value of
getValidity() . |
getValueAndValidate, getValueDirect
addChangeHandler, removeChangeHandler
resetValue, setValue, setValue, setValueForUser
getOriginalValue, getValue, getValueOrException
addValidatorMandatory, isMandatory
addValidator, removeValidator
validate
setModified
isModified
<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.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.createAndBind(TypedProperty)
<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
.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
.<P> UiWidgetWithValue<P> createAndBind(TypedProperty<P> property, String label)
createAndBind(TypedProperty)
but using the given label
instead
of deriving it automatically.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
.Boolean getValidity()
Boolean.TRUE
if validation was successful, Boolean.FALSE
if validation failed,
null
if NOT validated (since
UiFeatureMessages.clearMessages()
or something similar has been
called).void setValidity(Boolean validity)
getValidity()
. getValidity()
.validity
- is the new value for getValidity()
. May be null
.boolean doValidate(ValidationState state, VALUE value)
registered
validators. It is called
from AbstractUiWidget
(method doValidate
) that
itself is called from AbstractValidatableObject.validate(ValidationState)
.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).VALUE getRecentValue()
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.<P> PropertyAccessor<VALUE,P> createPropertyAccessor(TypedProperty<P> property)
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>.PropertyAccessor<VALUE,?> createPropertyAccessor(String property)
property
- is the property name
.PropertyAccessor
for the given property
based on the
Pojo
type <VALUE>.String getLabel(TypedProperty<?> property)
property
(including I18N, etc.).property
- is the TypedProperty
.TypedProperty.getTitle()
Copyright © 2001–2016 mmm-Team. All rights reserved.