3 Replies Latest reply: Jun 10, 2013 12:24 PM by Jlaskey-Oracle RSS

    Call JavaScript method in FXML from java controller

    Ertong
      I have fxml like
         ....
         <fx:root type="javafx.scene.Group" xmlns:fx="http://javafx.com/fxml">
          <fx:script>
              function applyState(oldState, newState)
              {
                  ...
              }
          </fx:script>    
          ....
      and controller to it.

      The idea is to move some view logic to fxml file.
      So, when I need to change some view state, I want to call applyState from java code.
      The question is how to do it.

      -----
      What I have found:

      We can get
      fxmlLoader.getNamespace().get("applyState")
      and receive sun.org.mozilla.javascript.internal.InterpretedFunction.

      NetBeans see this class. But while building the project i have an error
      error: package sun.org.mozilla.javascript.internal does not exist

      But this class really exists in rt.jar in JRE.
      After that I have stopped digging into this.
      I suspect that using internal API is not a good idea to call this InterpretedFunction.

      Can somebody suggest how can I make such an invocation?

      Edited by: 940811 on Nov 19, 2012 11:21 PM