JSOperation API issues
Posted: Fri Apr 05, 2019 1:05 am
HI there,
I'm working on creating actions using the JSOperation functionality, and encountering some problems calling API functions. Here's some example code:
The error message I see is:
InternalError: Java class "[Lro.sync.ecss.extensions.api.node.AuthorNode;" has no public instance field or method named "getStartOffset".
There does seem to be such a function according to the API docs:
https://www.oxygenxml.com/InstData/Edit ... rtOffset--
I'm a bit puzzled by the square bracket and L character at the beginning of the class specification in the message. I've tried explicitly casting to an AuthorNode. What am I missing here? Why does the length of the AuthorNode array come back as only 1, and why can't I call getStartOffset()?
All help appreciated,
Martin
I'm working on creating actions using the JSOperation functionality, and encountering some problems calling API functions. Here's some example code:
Code: Select all
function doOperation() {
var selText = authorAccess.getEditorAccess().getSelectedText();
var documentController = authorAccess.getDocumentController();
var workspaceAccess = authorAccess.getWorkspaceAccess();
try {
if (selText.length() > 0) {
//First get the selection bounds.
var selEnd = authorAccess.getEditorAccess().getSelectionEnd();
var selStart = authorAccess.getEditorAccess().getSelectionStart();
//Get all the starting anchors in our document.
var anchors = new Array(documentController.findNodesByXPath("//*:anchor[@next]", true, true, true));
//THIS SHOWS "1" EVEN THOUGH THERE ARE LOTS OF SUCH ANCHORS IN THE DOCUMENT.
workspaceAccess.showErrorMessage(anchors.length);
//Get the ids we care about.
var relevantAnchors = [];
for (var i = 0; i < anchors.length; i++) {
//THIS SHOWS THE ERROR MESSAGE BELOW.
var nodeStart = anchors[i].getStartOffset();
if ((nodeStart >= selStart) && (nodeStart < selEnd)) {
relevantAnchors.push(anchors[i].getAttribute('next').toString().substring(1));
}
}
}
} catch (e1) {
//e1.printStackTrace();
workspaceAccess.showErrorMessage(e1);
}
}
InternalError: Java class "[Lro.sync.ecss.extensions.api.node.AuthorNode;" has no public instance field or method named "getStartOffset".
There does seem to be such a function according to the API docs:
https://www.oxygenxml.com/InstData/Edit ... rtOffset--
I'm a bit puzzled by the square bracket and L character at the beginning of the class specification in the message. I've tried explicitly casting to an AuthorNode. What am I missing here? Why does the length of the AuthorNode array come back as only 1, and why can't I call getStartOffset()?
All help appreciated,
Martin