JavaFX 2.2 WebView

孤街醉人 提交于 2019-12-24 12:51:10

问题


I am using Javafx and FXML . I have created my form . in one of my pages I have a Tree in the left pane (Split Pane) , and the right pain is a Webview inside the right Anchor pane.

when I select a node on the tree (treeItem) the webview will change accordingly to the respective site that was selected in the tree view.

This works (like a charm)when I run it as an application.

HOWEVER , when viewing this in the browser (i.e. chrome , firefox and safari(mac)) i dont see the web view , it stays blank. i.e. the UI will load and the tree will be there , but the right jand pain never shows the embedded views.

When I run as a webstart I see the right views. The web pages that are embedded into the web views have a login, when i try login the web page flicker , like ther refresh and the login form is blanked, I have to enter the credential again.

not sure what is wrong or how to debug the browser / webstart side.


回答1:


when viewing this in the browser (i.e. chrome , firefox and safari(mac)) i dont see the web view , it stays blank. i.e. the UI will load and the tree will be there , but the right jand pain never shows the embedded views.

If you not done so already, you will need to sign your application to allow it to run outside of the browser embedded Java application sandbox so that the webview's network layer has permission to access the external locations.

Also monitor the webview loadworker's exception property to see if an exception or FAILED state was encountered:

Worker worker = webview.getEngine().getLoadWorker();
worker.stateProperty().addListener(new ChangeListener<Worker.State>() {
  @Override public void changed(ObservableValue<? extends Worker.State> observableValue, Worker.State oldState, Worker.State newState) {
    System.out.println("Browser state change: " + newState);
  }
});
worker.exceptionProperty().addListener(new ChangeListener<Throwable>() {
  @Override public void changed(ObservableValue<? extends Throwable> observableValue, Throwable oldThrowable, Throwable newThrowable) {
    System.out.println("Browser encountered a load exception: " + newThrowable);
  }
});

not sure what is wrong or how to debug the browser / webstart side.

There is an excellent Oracle article on debugging steps for webstart / browser embedded applications. The article provides numerous pointers such as how to set debug and trace levels, etc.



来源:https://stackoverflow.com/questions/14479218/javafx-2-2-webview

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!