-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
8
-
generic
-
generic
In FXML, we used to create a new bindings for a scripts in tag attributes, as we needed a new "event" variable. This is the code that does this:
Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
Bindings localBindings = scriptEngine.createBindings();
localBindings.put(EVENT_KEY, event);
scriptEngine.setBindings(localBindings, ScriptContext.ENGINE_SCOPE);
// Execute the script
try {
scriptEngine.eval(script);
} catch (ScriptException exception){
throw new RuntimeException(exception);
}
However, this does no longer works. If there's a function already defined in the engine, it won't be found in Nashorn.
Not sure why it worked in JDK7 actually, as localBindings appear empty both in JDK7 and JDK8 when printed out.
The difference is that JDK7 engineBindings contain also the function name, but JDK8 does not! So even if I try to copy the full context using "localBindings.putAll(engineBindings)", this does not work, as engineBindings does NOT appear to contain the function. But when I execute this with the original engineBingins, the function is found, even though it's not in the map.
For a full use-case, see https://javafx-jira.kenai.com/browse/RT-30986
Bindings engineBindings = scriptEngine.getBindings(ScriptContext.ENGINE_SCOPE);
Bindings localBindings = scriptEngine.createBindings();
localBindings.put(EVENT_KEY, event);
scriptEngine.setBindings(localBindings, ScriptContext.ENGINE_SCOPE);
// Execute the script
try {
scriptEngine.eval(script);
} catch (ScriptException exception){
throw new RuntimeException(exception);
}
However, this does no longer works. If there's a function already defined in the engine, it won't be found in Nashorn.
Not sure why it worked in JDK7 actually, as localBindings appear empty both in JDK7 and JDK8 when printed out.
The difference is that JDK7 engineBindings contain also the function name, but JDK8 does not! So even if I try to copy the full context using "localBindings.putAll(engineBindings)", this does not work, as engineBindings does NOT appear to contain the function. But when I execute this with the original engineBingins, the function is found, even though it's not in the map.
For a full use-case, see https://javafx-jira.kenai.com/browse/RT-30986