I am building a Java-enabled web application for some specific requests (e.g. printing without selecting a printer each time), and there is something that makes me crazy .
I use JavaFX to instantiate a browser object and everything works fine, but of course I need to make javascript callbacks in Java, here is the code:
...
...
we.getLoadWorker().stateProperty().addListener( new ChangeListener<Worker.State>()
{
@Override
public void changed(ObservableValue<? extends State> observable, State oldValue, State newValue)
{
if ( newValue == Worker.State.SUCCEEDED )
{
bridge = new Bridge();
JSObject jsobj = (JSObject) we.executeScript( "window" );
jsobj.setMember( "app", new Bridge() );
}
if ( newValue == Worker.State.CANCELLED )
{
System.out.println( newValue );
System.out.println( "An error accourred" );
}
}
});
...
...
This works, but after a few minutes of working the bridge, which works completely, javascript can no longer make callbacks, and if I try to warn () on the "app" object, it will return me undefined. I am using JDK9
source
share