I have a fairly simple JavaFX application. It has one window, split in two. On the left is a tableview that lists rows from a database. When you select one of the rows, it displays the XML (also from the database) in a webview on the right. So far so good. I can't for the life of me get any sort of JavaScipt working. My ultimate goal is to get a search and highlight working (as in this great post. Based on my problems there, I thought I'd try and simplify matters by just plugging in a simple JavaScript function to the HTML.
I'm using FXML, if that's relevant. I have a button that for it's OnAction property, calls this method:
@FXML
private void searchBrowser() {
if (webEngine.getDocument() != null) {
highlight(searchField.getText());
}
}
@FXML
private void highlight(String text) {
webEngine.executeScript("test()");
It doesn't throw any errors, and both methods are called in order. Just nothing else happens. The test() function is in the HTML, just a simple alert. If I just save the HTML and load it in Chrome or IE, the function works fine. What am I doing wrong?