Hello all, In the context of embedding/wrapping existing web applications in a Java client, I am facing some issues especially in regard of navigation interception & file download. My first use case was to be able to navigate to PDFs exposed by a web application.
First I did not found a convenient API in JavaFX to register a kind of "download plugin". Then, I found that some people were monitoring webengine.location property. This solution is very simple to setup but it fails when you want to intercept several navigations to the same item. Finally, I ended in investigating & demoing a way of doing it by using javascript & java-javascript bridges possibilities. I pushed my demo app to github: https://github.com/McFoggy/fxnav-interceptor What I do is: - loading the webapp - from java, inject a javascript lib - from java, inject java bridges to this JS lib - from JS, monitor the DOM - on JS DOM modification, java bridges are called and install 'ClickListener' instances on appropriate JS DOM nodes (anchors in the example) - when user click links, JS events are fired, handled by Java bridges, that can then download the target of the link and consume the JS event Do you think of easier way of doing this: - in the current JavaFX version (8u20)? - in future versions? Several tickets are already opened https://javafx-jira.kenai.com/browse/RT-19046 https://javafx-jira.kenai.com/browse/RT-36498, but I did not found any target version for them, any info? Thanks for feedback & keep on going with the great stuff you already provided. Matthieu Brouillard