[JavaFX] Bind bug? Or am I just stupid?
I really love that binding stuff in JavaFX. I am looking forward until some smart guy implements something similar in Scala…
But I also have some problems with it. Sometimes “on replace” triggers are called with the same values for <old> and <new>. Here is a small sample script that shows it:
[cc lang="c" escaped="true" tab_size="2" lines="20"]
import java.lang.RuntimeException;
/**
* @author johannes
*/
println( “Starting binding test…” );
var i = 0.5 on replace old {
println( “i changed to <{i}>” );
if ( i == old ) {
throw new RuntimeException( “This will never happen!” );
}
};
var b = bind calc( i ) on replace old {
println( “b has changed from <{old}> to <{b}>” );
if ( b == old ) {
println( “!!!!!!!!!!!!!!!!!!!!!!!” );
println( “Why is on replace called? Both objects are the same: {isSameObject( b, old )}” );
println( “!!!!!!!!!!!!!!!!!!!!!!!” );
}
};
println( “i: {i}” );
i = 0.5;
println( “i: {i}” );
i = 0.9;
println( “i: {i}” );
i = 1.0;
println( “i: {i}” );
function calc( i ) {
return i < 1;
}
[/cc]
Of course I have posted a question in the JavaFX forum. But no answers yet….
UPDATE:
Has finally been fixed in 1.3! Now it works as expected.
April 14th, 2010 at 10:03
[...] This post was mentioned on Twitter by Johannes Schneider, Johannes Schneider. Johannes Schneider said: New blog posting, [JavaFX] Bind bug? Or am I just stupid? – http://tinyurl.com/y3pot8l [...]
April 14th, 2010 at 10:45
The “on replace” trigger will fire as long as you have performed an assignment operation. It will fire regardless whether the assignment was the same value or not.
April 17th, 2010 at 00:43
@Richard: I am really looking forward to the 1.3 release….
April 23rd, 2010 at 12:53
[...] now – with release 1.3 – it seems to work much better. At least some of the simplest cases now work as [...]