Welp, this all started because my table was showing all my TableCells without any text. I still have that problem, but I have eliminated the superclass method call issue.
I made a Java class to place all required methods directly in the superclass, and used this from my JavaScript. The class source is as follows:
public class JsTextTableCell<S,T> extends javafx.scene.control.TableCell<S, T> {
public void setText(Object text){
System.out.println("In java, calling setText(" + text.toString() + ")");
super.setText(text.toString());
}
}
Then I changed my javascript to:
fx.EditableTextTableCell = function () {
var cell;
if(!fx.EditableTextTableCell.Class) {
fx.EditableTextTableCell.Class = Java.extend(fx.JsTextTableCell, {
updateItem: function (item, isEmpty) {
if(!isEmpty){
cell.super$setText(item);
}
}
});
}
cell = new fx.EditableTextTableCell.Class();
return cell;
};
This code runs just fine. In fact, both the Java.super
and cell.super$setText
methods work. My table still refuses to show my text, but that is another issue entirely. So it appears Nashorn indeed only travels one level up in searching for super class methods, and does not find methods inherited from further up in the inheritance chain.
EDIT
Seems I was getting a sloppy in my frustration. In my solution above, I'm creating my new extended class only once, and am there after setting the text on the cell it closed over on the first invocation of the fx.EditableTableCell constructor. This ends up leaving all the cells in my table blank. The reason this happened is that you may not use this.text = item
within the updateItem function definition. You must have an external reference to the object, for whatever reason, and this caused me to leak the cell
variable and end up with a closure issue.
To recap : Java.super
and obj.super$methodName
are both fine ways to access a method defined directly on the superclass of a JavaAdapter in Nashorn, and nobody has ever really mastered closures.