I'm working with JavaFX, and am investigating data binding. I've found that I can define a one-way binding in my FXML, like this:
<TextField fx:id="usernameTextField" text="${controller.userName}" GridPane.columnIndex="1" />
This means, that the text of the usernameTextField is 'observing' the controller.userName property.
But this creates a one-way binding. If the controller.userName property changes, I see the updated text in the text field, that part works. But I can no longer insert text into the text field, because I've made the one-way binding.
All I can find about this are posts which are now more than four years old, but I can't figure out, if JavaFX has been updated to support more elaborate bindings.
The way to do that is:
<TextField fx:id="usernameTextField" text="#{controller.userName}"/>
But this feature is not enabled yet (last checked on OpenJFX 13) and using it will cause FXMLLoader to throw an UnsupportedOperationException("This feature is not currently enabled.").
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With