attributes of different objects share binding
Consider the code below. Changing any of the first 2 numField values on-screen, changes the other one as well, even though it should be a different object.
application concurrencybug
import mobl::ui::generic
type MyType {
attribute : Num
}screen root() {
header("Bug report") var first = MyType(attribute=15) var second = MyType(attribute=20) var firstDerived <- first.attribute var secondDerived <- second.attribute numField(first.attribute, label="property of 1st object") numField(second.attribute, label="property of 2nd object") numField(firstDerived, label="derived/copied property of 1st object") numField(secondDerived, label="derived/copied property of 2nd object") button("log derived values", onclick={ logValues(); }) function logValues() { log( "1st-derived: " + firstDerived + "\n2nd-derived: " + secondDerived ); }
}
Submitted by Meinte Boersma on 23 March 2012 at 14:45
Attachments
Issue Log
The following expansion (see attachment) of the same mobl file suggests that the problem is related to having multiple instances of the same type, since the problem doesn’t occur across different types, whether the properties are equally named or not.
In fact, the suggestion is that there is some name-based mechanism at work w.r.t. the databinding which works off the combination of type name and property name and thus coalesces all same-named attributes of the same type onto on.
(The derived stuff is to see whether the obvious workaround doesn’t suffer from the same problem - it doesn’t, but would force us to explicitly update the values of the objects (first, second) when leaving a screen and such.)
after some digging I found indeed that the problem is that Types are becoming bound to this(probably screen).
This give only the oppertunity to bound a property once, the quick fix is to use entitys which don’t have this problem.
Log in to post comments