atom feed19 messages in net.java.dev.openjfx-compiler.devRe: Binding with inverse
FromSent OnAttachments
Brian GoetzMar 13, 2009 11:50 am 
Michael AzziMar 13, 2009 12:43 pm 
Brian GoetzMar 13, 2009 1:20 pm 
Michael AzziMar 13, 2009 1:42 pm 
Weiqi GaoMar 14, 2009 6:24 am 
Kim TopleyMar 14, 2009 7:40 am 
Robert FieldMar 15, 2009 12:53 pm 
Brian GoetzMar 16, 2009 11:18 am 
Brian GoetzMar 16, 2009 11:19 am 
Kim TopleyMar 16, 2009 12:21 pm 
Weiqi GaoMar 16, 2009 7:37 pm 
Brian GoetzMar 18, 2009 11:32 am 
Michael AzziMar 18, 2009 11:56 am 
Weiqi GaoMar 18, 2009 7:09 pm 
Brian GoetzMar 20, 2009 9:11 pm 
Brian GoetzMar 20, 2009 9:12 pm 
Brian GoetzMar 20, 2009 9:18 pm 
Weiqi GaoMay 3, 2009 7:31 pm 
Brian GoetzMay 3, 2009 7:52 pm 
Subject:Re: Binding with inverse
From:Robert Field (Robe@Sun.COM)
Date:Mar 15, 2009 12:53:44 pm
List:net.java.dev.openjfx-compiler.dev

OK, this is a twisty bit of the semantics of bind with inverse. Unidirectional bind (regular bind) binds to an expression, in your example the expression "t.content", if either "t" or "content" change then content1 will change. Bidirectional bind (bind with inverse) binds to a variable, in your example the variable "t.content", but since "t" is null, "content" is the default value. That won't change if "t" changes.

Contrast:

var t = Text { content: "Hello, World" }; var content1 = bind t.content on replace { println("content1: {content1}") }; var content2 = bind t.content with inverse on replace { println("content2: {content2}") };

t.content = "How goes, World";

which yields:

content1: Hello, World content2: Hello, World content2: How goes, World content1: How goes, World

Bidirectional bind cannot bind to anything multi-variate since it would not know which to update on inverse.

And, yes, the null is now fixed to be the default value (empty string).

-Robert

Kim Topley wrote:

This code gives what seemed to me to be a surprising result:

-------------------------------------------------------------- import javafx.scene.text.Text;

var t:Text; var content1 = bind t.content on replace { println("content1: {content1}") }; var content2 = bind t.content with inverse on replace { println("content2: {content2}") };

t = Text { content: "Hello, World" };

--------------------------------------------------------------

Here's what it prints with the JavaFX 1.1 compiler/runtime:

-------------------------------------------------------- content1: content2: null content1: Hello, World

-------------------------------------------------------- The first issue is that content2 is null at some point, but I'm pretty sure that's already covered and probably fixed already. What surprised me is that content1 and content2 wind up being different, even though they are both bound to the same value. The difference is that content2 is bound with inverse while content1 is not. The cause is clear from the generated Java file. Do you want an issue raised for this?