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();
}
}
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();
}
}
- relates to
-
JDK-8126601 JS2Java Bridge arrays and other parts of JS2Java Bridge do not work on Linux
- Closed