Skip to end of metadata
Go to start of metadata

Generated Object

An internal class that currently should not be relied on.

Attributes

  • source <Object> The object that triggers the binding update
  • sourceProperty <String> A property that is read for the update and whose change triggers the update
  • sourceEvent <String> The event name trigger an update
  • sourceValue <Closure> A closure providing the value when sourceEvent triggers
  • target <Object> The object to be updated when a bound value changes
  • targetProperty <String> The property on the target update to which the queried value will be written
  • validator <Closure> If the closure returns null or Boolean.FALSE then a triggered binding will be canceled
  • converter <Closure> Takes the queried value and converts it to another object to be written to the targetProperty. The queried value is passed in "it" to the closure.

Content

bind accepts no content

Usage

bind can be used as a stand alone element or as a value for any attribute of any object.

When used as an attribute value the target and targetProperty values implicitly become the current object being constructed and the property being written to.

Until the external API is finalized, it is not recommended to use the object returned from bind

Examples

Example binding one property to another:

Example when triggering on a particular event with a value closure

Note that the source value can get any arbitrary value.

Example with validator and converter:

In this example the validator prevents the button text from having less than 1 char and the converter makes the button text all lowercase.

Note: Tested on Groovy 1.5.1

  • No labels

2 Comments

  1. It is not clear from the documentation what parameters supports sourceValue binding attribute.
    Actually it is invoked without parameters.
    Maybe it would be great if sourceValue closure was invoked with Event parameter, what do you think about it?

  2. It depends on the target source. If it is a SwingTimerTriggerBinding the param is the time elapsed. But there is no way to directly access that by the builder currently. I have added code (in 1.6) to the EventTriggerBinding to check to see if the sourceValue binding is a closure, and if so set the event object as parameter of the closure.