If you look at the code to BOLE (in MENU\1-File\2-Open.js) you'll see where I've tried to call a B4J class from "outside" in Nashorn. All methods in the class file have a leading capital letter. However, when calling from Nashorn, I've had to add a leading underscore and lowercase the name of the method. (Open becomes _open, Read becomes _read etc.) Also, I've had to include as the first parameter of the call, the name of the class itself.
The class is instantiated as
Questions:
var f = FileControl._open(FileControl, "./", "All Files", "*.*");
if ("" !== f) {
MainText.text = FileControl._read(FileControl, f);
gsPath =f;
}
if ("" !== f) {
MainText.text = FileControl._read(FileControl, f);
gsPath =f;
}
The class is instantiated as
Private oFC As fileControl
oFC.Initialize(MainForm)
and exposed to Nashorn asoFC.Initialize(MainForm)
oNas.enginePut("FileControl",oFC)
(the source can be seen from the github repository)
Questions:
- Is this how it's supposed to be?
- Is there a way of declaring the class's methods and properties such that Nashorn doesn't have to have the class name as a first parameter?
- Would it have been better to have make a library (jar + xml)? or
- do I need to go into pure java for this kind of thing?
- Could I have done the FileChooser purely from the Nashorn side? And if yes, how?