Issue with WebView component

Sirish Vadala sirishreddy at gmail.com
Fri Feb 10 18:23:27 UTC 2017


Hello experts, I am have an issue with WebView component. Sometimes if the
application stays idle for a few minutes, the display is just a blank
screen and WebView is not rendered on the stage. Other times it works
perfectly fine. Also once a particular webView component fails to render
onto the screen, all other webViews through out the application fail to
load.

The component behaves very inconsistently and I couldn't identify a
definitive pattern to replicate the issue.

I appreciate if any of you experts can point me out in the right direction
to fix this inconsistent behavior.

------------------------------------------------------------------------------------------
|------------------|
| My WebView code: |
|------------------|

String htmlBillText = billTextController.transformBillXmlXsl();

WebView webView = new WebView();
WebEngine engine = webView.getEngine();
engine.setOnError((WebErrorEvent event) -> {
// NEVER GOES INTO THIS AT ALL
System.out.println("event.getMessage()::"+event.getMessage());
System.out.println("event.getException()::"+event.getException().getMessage());
System.out.println("event.toString()::"+event.toString());
engine.reload();
});

engine.getLoadWorker().stateProperty().addListener(new
ChangeListener<Worker.State>() {
@Override
public void changed(ObservableValue ov, Worker.State oldState, Worker.State
newState) {
System.out.println("oldState::" + oldState);
System.out.println("newState::" + newState);
if (engine.getLoadWorker().getException() != null) {
System.out.println("engine.getLoadWorker().getException()::" +
engine.getLoadWorker().getException().getLocalizedMessage());
}
if (engine.getLoadWorker().getException() != null && newState ==
Worker.State.FAILED) {
System.out.println(engine.getLoadWorker().getException().getMessage());
}
if (newState == Worker.State.SUCCEEDED) {
System.out.println("engine.getDocument()::"+engine.getDocument());
if (engine.getDocument() != null) {
String html = (String)
engine.executeScript("document.documentElement.innerHTML");
if (StringUtils.isEmpty(html)) {
System.out.println("FX WebView Engine Failed To Load Content... Execute
Reload...");
engine.reload();
}
}
System.out.println("engine.getTitle()::" + engine.getTitle());
System.out.println("engine.getLocation()::" + engine.getLocation());
System.out.println("engine.getUserAgent()::" + engine.getUserAgent());
System.out.println("engine.getUserDataDirectory()::" +
engine.getUserDataDirectory());
System.out.println("engine.isJavaScriptEnabled()::" +
engine.isJavaScriptEnabled());
}
}
});
engine.loadContent(htmlBillText);
------------------------------------------------------------------------------------------
|------------------------------------------------|
| MY DISPLAY CONSOLE WHEN WEBVIEW FAILS TO LOAD: |
|------------------------------------------------|
oldState::READY
newState::SCHEDULED
oldState::SCHEDULED
newState::RUNNING
oldState::RUNNING
newState::SUCCEEDED
engine.getDocument()::[object HTMLDocument]
engine.getTitle()::SB6:v98#DOCUMENT
engine.getLocation()::
engine.getUserAgent()::Mozilla/5.0 (Windows NT 6.1; Win64; x64)
AppleWebKit/538.19 (KHTML, like Gecko) JavaFX/8.0 Safari/538.19
engine.getUserDataDirectory()::null
engine.isJavaScriptEnabled()::true
------------------------------------------------------------------------------------------

Thanks. -SV-


More information about the openjfx-dev mailing list