0

Firstly as for the desktop (not Android) application.

I want to replace the source of an image which is placed inside loaded HTML document to local one (from my hard drive). I show loaded page using JavaFX components: webEngine->webView->Scene->Stage. What I did?

I loaded a page using webEngine.load("http://any_page"). After that I obtained an image object (on Java side) and casted it to HTMLImageElementImpl. This is the representation of object which exists on loaded page. I set the src attribute like below:

htmlImageElementImpl.setSrc("file:/local_path_to_my_image");

...and expected the new image will appear on loaded page. Unfortunately it does not work. Previous image (which originally was on loaded page) has dissapeared and new has not appear (there is a white area). I determined that this image is there (when I click right button on it, it is possible to choose an "open image in new window" option and see it). It appears. I think that it need to refresh the component to show it.

What is interesting when I replace src of this tag to image exisiting in the Internet like below:

htmlImageElementImpl.setSrc("http://_file_existing_in_the_internet//image.jpg");

...every works fine and replaced image appears on the fly.

I has spend two days and I have not managed with this problem. So I decided to ask you.

Best regards

Kess

Kessler
  • 31
  • 6
  • I have forgot to add one important information. When I load page from static html (webEngine.loadContent()) everyone works fine. Only during loading from remote server there is a problem with replacing image to file from local computer. Probably downloaded content is oriented for a resporces which comes from server and not for local one. Any ideas? – Kessler Jul 14 '16 at 16:41
  • hey have u tried using converting the URI? http://stackoverflow.com/questions/26447451/javafx-in-webview-img-tag-is-not-loading-local-images – gumuruh Feb 19 '17 at 15:18

1 Answers1

0

I forgot to answer. The trouble was related with security issues. Capability to access to file system (from java script tier) is constrainted by aforementioned cause.

Solution: I established Java embedded local HTTP server and shared this images there. We have to accept the fact that specified port on local machine have to be opened, but this is acceptable solution.

Kessler
  • 31
  • 6