At this time, JavaFX variables bound to a pure-Java object (POJO) will not automatically update as they should. This article describes one or more ways to get two-way binding working.

Problem Statement

Original Thread

I want to get a JFX button to change state given a property
change in Java code. I can pass the new state into the script
but the binding does not work.


Possible Solution

Create a JavaFX object, identical to the POJO. Add a variable named 'backer' for the original POJO. Each variable must have an 'on replace' that updates the value in the backer variable. The 'on replace' for the backer variable will give all the values, the values of the original POJO.


Example of the POJO:

package org.mydomain;
public class OriginalPojo {
    private String name;
    private Integer age;
    // getters/setters for all parameters

Example of the JavaFx object:

package org.javafx.mydomain;
public class JavaFxPojo {
    public-init var backer : org.mydomain.OriginalPojo on replace {
      name : backer.getName();
      age : backer.getAge();

  public var name : String on replace {
  public var age : Integer on replace {

Solution based on this thread.


Community content is available under CC-BY-SA unless otherwise noted.