Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8117590

JavaScript2Java Bridge should allow bound arrays to conserve their functionality

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7u6
    • fx2.1
    • javafx
    • None
    • web

      JavaScript2Java Bridge should allow bound arrays to conserve their functionality.
      Currently it's possible to bind an array to JavaScript presentation, however, it's impossible to get its elements by index, or length.
      In my opinion, arrays should be functional if we allow developers to bind them.
      Please try the following simple application to reproduce the problem:

      import javafx.application.Application;
      import javafx.scene.Scene;
      import javafx.scene.web.WebEngine;
      import javafx.scene.web.WebView;
      import javafx.stage.Stage;

      /**
       *
       * @author javafx
       */
      public class BridgeArrayTest extends Application {

          /**
           * @param args the command line arguments
           */
          public static void main(String[] args) {
              launch(args);
          }
          
          @Override
          public void start(Stage primaryStage) {
              WebView view = new WebView();
              WebEngine e = view.getEngine();
              int []array = new int[3];
              array[0] = 42;
              e.addJavaScriptBinding("test", array);
              Object o1 = e.executeScript("test[0];");
              Object o2 = e.executeScript("test.length;");
              System.out.println(o1); // Expecting "42"
              System.out.println(o2); // Expecting "3"
              primaryStage.setScene(new Scene(view));
              primaryStage.show();
          }
      }

            pbothner Per Bothner (Inactive)
            ilatyshe Irina Grineva (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: