Annotation Type Bind
Pairs a @Bindable field with the component it should mirror.
name is the value the target component returns from
Component#getName(). attr picks the attribute to write: text, UIID,
selected state, visible / hidden, the icon name, or the component name
itself.
One-way bindings push from the model to the component on
Binders.bind. Two-way bindings additionally listen for user input on
text fields, text areas, and check boxes so changes flow back into the
model.
Accessor resolution
The annotation processor decides how to read and write the field in this order:
- Explicit accessor names --
@Bind(getter="getX", setter="setX"). Use this when the JavaBeans naming convention doesn't match (a fluent setter, a renamed boolean, ...). - JavaBeans accessors when both
getterandsetterare blank:getFoo()/isFoo()for the getter,setFoo(T)for the setter. Detected from the project's compiled bytecode -- no runtime reflection. - Direct public-field access as a last resort. The processor fails the build with a clear error when the field is private and no usable accessor exists.
For two-way bindings the build-time processor instruments the resolved
setter to call Binders.notifyChanged(this) at every return point.
Application code can mutate the model through the setter from anywhere
and the bound component refreshes automatically; see
Annotation-Component-Binding.asciidoc for the loop-guard details.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements
-
Element Details
-
name
String nameComponent#getName()of the target component. -
attr
-
twoWay
boolean twoWayWhen false the binding is one-way (model -> component only). DefaulttrueforTEXTagainst editable components and forSELECTED; for all other attributes the binding is implicitly one-way regardless of this flag.- Default:
true
-
getter
String getterExplicit getter method name. Default: empty -- the processor uses JavaBeansget<Field>/is<Field>discovery, then falls back to direct public-field access.- Default:
""
-
setter
String setterExplicit setter method name. Default: empty -- the processor uses JavaBeansset<Field>discovery, then falls back to direct public-field assignment. The resolved setter (whether explicit or detected) is instrumented for two-way bindings.- Default:
""
-