It appears that there are two situations where assignment to a bound groovy property through @Bindable
does not call the listeners:
(1) In the case where the property is assigned within the class itself, such as this.prop = newval
, or, simply, prop = newval
(2) In the case where the property's value does not change obj.prop = oldval
Is there a way around this? Ideally it would support the simple (.)prop=
syntax.
Code example:
import java.beans.*
import groovy.beans.*
int changes = 0
def obj = Binding.newInstance()
obj.propertyChange = { changes++ }
obj.prop = "1st change" // change recorded
obj.twoChanges() // no changes recorded
obj.prop = obj.prop // no change recorded
assert changes == 4 // fails: changes is 1
class Binding {
@Bindable String prop
def twoChanges() {
prop = "2nd change"
this.prop = "3rd change"
}
}