K
K
kirawa2016-02-29 13:12:56
JavaScript
kirawa, 2016-02-29 13:12:56

How to bridge between java and javascript?

Hello, I am writing a javafx application in which I receive data from the server and send it to a webView

webView.getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {
                    if (newValue == Worker.State.SUCCEEDED) {
                        JSObject jsObject = (JSObject)webView.getEngine().executeScript("window");
                        jsObject.call("initialize", jsonArray);
                    }
                });

How can I get some event from javascript in java? Well, from here
<select id="cat_select" onchange="changeEventHandlerCatWidget(event);">
                    <option value="0">Все</option>
                    <option value="1">продукты</option>
                    <option value="2">изделия</option>
                </select>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
kirawa, 2016-02-29
@kirawa

org.w3c.dom.Document document = webView.getEngine().getDocument();
                        org.w3c.dom.Element el = document.getElementById("places_select");
                        ((EventTarget) el).addEventListener("change", this, false);

got it all figured out

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question