|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.beans.binding.BindingContext
public class BindingContext
BindingContext manages a set of bindings.
BindingContext provides methods to bind and unbind the set of
Bindings it contains. The following example illustrates
adding a Binding to a BindingContext and
binding it:
BindingContext context = new BindingContext();
context.addBinding(source, "${sourcePath}", target, "targetPath");
context.bind();
BindingContext provides methods for tracking the state of the
Bindings it contains. The getHasUncommittedValues
method may be used to determine if any of the bound Bindings
contained in a BindingContext have an uncommited value. Similarly,
the hasInvalidValues method may be used to determine if any of
Bindings are currently invalid. Both of these properties are bound;
a PropertyChangeListener may be attached to the
BindingContext to track when either property changes.
BindingContext also supports a BindingListener.
BindingListeners are notified when conversion or validation of
a Binding fails. BindingListener provides a convenient
way to provide feedback to the user when an invalid value is input.
Binding,
BindingListener| Constructor Summary | |
|---|---|
BindingContext()
Creates a new BindingContext. |
|
| Method Summary | |
|---|---|
void |
addBinding(Binding binding)
Adds a Binding to this BindingContext. |
Binding |
addBinding(java.lang.Object source,
java.lang.String sourcePath,
java.lang.Object target,
java.lang.String targetPath,
java.lang.Object... args)
Creates and adds Binding to this BindingContext. |
void |
addBindingListener(BindingListener listener)
Adds a BindingListener to this BindingContext. |
void |
addFunction(java.lang.String prefix,
java.lang.String localName,
java.lang.reflect.Method m)
Adds the specified method to the list functions available to the expression. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this BindingContext. |
void |
addPropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this BindingContext. |
void |
addResolver(ELResolver resolver)
Adds an ELResover to the list of resolvers used in resolving
values. |
void |
bind()
Binds the set of unbound Bindings that have been
added to this BindingContext. |
void |
clearHasEditedTargetValues()
Sets the hasEditedTargetValues property to false. |
void |
commitUncommittedValues()
Commits any uncommited values in the Bindings managed by
this BindingContext. |
java.lang.Iterable<java.beans.FeatureDescriptor> |
getFeatureDescriptors(java.lang.Object obj)
Returns an iterator over the known FeatureDescriptors for the
specified object. |
boolean |
getHasEditedTargetValues()
Returns whether any of the Bindings contained in this
BindingDescription have had the target value edited. |
boolean |
getHasInvalidValues()
Returns true if any of the Bindings managed by
this BindingContext have a target value state of
INVALID. |
boolean |
getHasUncommittedValues()
Returns true if any the Bindings managed by this
BindingContext have a source or target value state of
UNCOMMITTED. |
BindingValidator |
getValidator(Binding binding)
Returns the BindingValidator for the specified
Binding. |
void |
removeBinding(Binding binding)
Returns a Binding. |
void |
removeBindingListener(BindingListener listener)
Removes a BindingListener from this BindingContext. |
void |
removeFunction(java.lang.String prefix,
java.lang.String localName,
java.lang.reflect.Method m)
Adds the specified method to the list functions available to the expression. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from this
BindingContext. |
void |
removePropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from this
BindingContext. |
void |
removeResolver(ELResolver resolver)
Removes an ELResover from the list of resolvers used in resolving
values. |
java.lang.String |
toString()
Returns a string representing the state of this binding context. |
void |
unbind()
Unbinds the set of Bindings that have been added
to this BindingContext and bound. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public BindingContext()
BindingContext.
| Method Detail |
|---|
public void clearHasEditedTargetValues()
hasEditedTargetValues property to false. This
is typically invoked after a save operation has done.
getHasEditedTargetValues()public boolean getHasEditedTargetValues()
Bindings contained in this
BindingDescription have had the target value edited. This
property is internally set to true when the target property of
a Binding chanages. The value of this is set to false
by invoking clarHasEditedTargetValues.
clearHasEditedTargetValues()public void addBinding(Binding binding)
Binding to this BindingContext. The specified Binding must
not be bound. Bindings are bound by invoking
the bind method.
binding - the Binding to add, must be
non-null
java.lang.IllegalArgumentException - if binding is null
java.lang.IllegalStateException - if binding is bound, or
has already been addedbind()
public Binding addBinding(java.lang.Object source,
java.lang.String sourcePath,
java.lang.Object target,
java.lang.String targetPath,
java.lang.Object... args)
Binding to this BindingContext.
source - the source of the bindingsourcePath - path to the property of the sourcetarget - the target of the bindingtargetPath - path to the paroperty of the targetargs - alternating set of key/value pairs; each even numbered
entry is of type Parameter, and the following
value is of a type specified by the Parameter
Binding
java.lang.NullPointerException - if one of the even entries is null
java.lang.ClassCastException - if one of the even entries is not a
Parameter, or one of the odd entries is not of a type
identified by the preceeding Parameter entry
java.lang.IllegalArgumentException - if args is oddpublic void removeBinding(Binding binding)
Binding.
binding - the Binding to remove
java.lang.NullPointerException - if binding is null
java.lang.IllegalStateException - if binding is bound
java.lang.IllegalStateException - if binding has already been
addedpublic void bind()
Bindings that have been
added to this BindingContext.
java.lang.IllegalStateException - if a binding added via
addBinding has been bound
PropertyResolverException - if PropertyResolver throws an
exception; refer to PropertyResolver for the conditions
under which an exception is thrownunbind()public void unbind()
Bindings that have been added
to this BindingContext and bound.
PropertyResolverException - if PropertyResolver throws an
exception; refer to PropertyResolver for the conditions
under which an exception is thrownpublic void addBindingListener(BindingListener listener)
BindingListener to this BindingContext.
listener - the BindingListener to addpublic void removeBindingListener(BindingListener listener)
BindingListener from this BindingContext.
listener - the BindingListener to removepublic BindingValidator getValidator(Binding binding)
BindingValidator for the specified
Binding.
binding - the Binding to obtain the
BindingValidator for
BindingValidator
java.lang.NullPointerException - if binding is nullpublic void commitUncommittedValues()
Bindings managed by
this BindingContext. This is a convenience method that may
be used to make sure all edited values are committed. This
invokes setSourceValueFromTargetValue() on any Bindings
managed by this BindingContext that have target value state of
UNCOMMITTED.
PropertyResolverException - if PropertyResolver throws an
exception; refer to PropertyResolver for the conditions
under which an exception is thrownpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener to this BindingContext.
listener - the PropertyChangeListener to addpublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
PropertyChangeListener from this
BindingContext.
listener - the PropertyChangeListener to remove
public void addPropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
PropertyChangeListener to this BindingContext.
property - the name of the property the
PropertyChangeListener is interested inlistener - the PropertyChangeListener to add
public void removePropertyChangeListener(java.lang.String property,
java.beans.PropertyChangeListener listener)
PropertyChangeListener from this
BindingContext.
property - the name of the property the
PropertyChangeListener is interested inlistener - the PropertyChangeListener to removepublic boolean getHasUncommittedValues()
true if any the Bindings managed by this
BindingContext have a source or target value state of
UNCOMMITTED.
true if a value is uncommitedpublic boolean getHasInvalidValues()
true if any of the Bindings managed by
this BindingContext have a target value state of
INVALID.
true if a target value state is invalidpublic final void addResolver(ELResolver resolver)
ELResover to the list of resolvers used in resolving
values. Adding a resolver does not effect existing Bindings.
resolver - the resolver to add
java.lang.IllegalArgumentException - if resolver is nullpublic final void removeResolver(ELResolver resolver)
ELResover from the list of resolvers used in resolving
values. Removing a resolver does not effect existing Bindings.
resolver - the resolver to remove
java.lang.IllegalArgumentException - if resolver is null
public final void addFunction(java.lang.String prefix,
java.lang.String localName,
java.lang.reflect.Method m)
Bindings.
prefix - the prefix of the function, or "" if no prefix;
for example, "fn" in ${fn:method()}, or
"" in ${method()}.localName - the short name of the function. For example,
"method" in ${fn:method()}.m - the method
java.lang.IllegalArgumentException - if any of the arguments are
null
public final void removeFunction(java.lang.String prefix,
java.lang.String localName,
java.lang.reflect.Method m)
Bindings.
prefix - the prefix of the function, or "" if no prefix;
for example, "fn" in ${fn:method()}, or
"" in ${method()}.localName - the short name of the function. For example,
"method" in ${fn:method()}.m - the method
java.lang.IllegalArgumentException - if any of the arguments are
nullpublic final java.lang.Iterable<java.beans.FeatureDescriptor> getFeatureDescriptors(java.lang.Object obj)
FeatureDescriptors for the
specified object. This method is primarily intended for builders.
Preferred properties are identified by FeatureDescriptors that
return a value of Boolean.TRUE from getValue(PropertyDelegateProvider.PREFERRED_BINDING_PROPERTY).
obj - the object to query for FeatureDescriptors
Iterable over the known FeatureDescriptors for
the specified object; this never returns null
java.lang.IllegalArgumentException - if obj is nullpublic java.lang.String toString()
null.
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||