I'm digging up this thread because A) it doesnt have a resolution and B) I'm a shameless point theif.
edit: speaking to the original question, your post is exactly right, to do a (one way) binding, the syntax is ${fx_id_value}
, exactly as written in the OP's example.
It seems to me that in FXML 2.1 there was some notion of bidirectional bindings added, as per javafx.fxml.FXMLLoader#BI_DIRECTIONAL_BINDING_PREFIX
/**
* Prefix for bidirectional-binding expression resolution
* @since JavaFX 2.1
*/
public static final String BI_DIRECTIONAL_BINDING_PREFIX = "#{";
unfortunately, following that back a little bit, we effectively only have one usage on line 318 of javafx.fxml.FXMLLoader.Element#processPropertyAttribute
:
else if (isBidirectionalBindingExpression(value)) {
throw constructLoadException(new UnsupportedOperationException("This feature is not currently enabled."));
}
Doing a search on the javafx bug tracker reveals that this exposed javadoc, referencing #{
as a symbol, is a bug, and should be removed. This seems to me to be something that is in the works. However, considering the myriad of bugs JavaFX currently has, I wouldn't be surprised if we don't see it until java 9.
Stepping back, your frustration with the documentation mirrors my own (as does your experience: I'm also coming at JavaFX from WPF, granted I've spent much less time with both than I suspect you have). The best solution for using javafx binding expressions has come from reading the source code to the com.sun.javafx.fxml.expression.Expression (warning! usual rules about com.sun packages apply: they are internal and they have wierd licensing issues, read that source at your own risk!). The Expression.java class is a hand-written parser/compiler for javafx binding expressions withen FXML, using reflection as its runtime. Why they didn't use ANTLR or JavaCC I don't know. It would be much easier to read if we could just reference a grammar and a listener.
From reading that, I've learned that you can have expressions withen the ${
and }
delimeters. The most common for me has been something like:
<HBox>
<CheckBox fx:id="abcCheckBox"/>
<TextField disable="${ ! abcCheckBox.selected}"/>
</HBox>
similar to XAML. It does also support addition, negation, and other common things, as long as everything references fx:id'd components and properties on them (and 'controller' is an fx:id given to you for free referencing the controller this XML is being loaded onto).
All things considered, I like javafx, but it will be a while before they have the deep binding & integration features that something like C#, WPF, XAML, and caliburn-micro offer.