nus-cs2103-AY1819S1 / forum

A repo to hold the issue tracker for module discussions
1 stars 1 forks source link

Loading image path to HTML file in BrowserPanel.java #136

Open javenseow opened 5 years ago

javenseow commented 5 years ago

Hi i'm loading a HTML file into the browser panel to display some information and one of the information that i am loading is an image which i have copied from the original path and into a separate folder that is in the resource folder. I used MainApp.class.getResource(/path_to_picture/).toString() as the file path in BrowserPanel.java and it worked but it doesn't work when it's in a JAR file. I would like to ask what path am i supposed to put in the HTML file to access the image in the folder in the JAR file?

ooihuiying commented 5 years ago

My team is facing a somewhat similar issue too. As our browser panel is written in HTML, it doesn't show up when we run it from the jar file. Would appreciate if someone could help us out. Thank you :)

ghost commented 5 years ago

Getting what you wish to exactly be displayed on the BrowserPanel seems a little hard :/ (speaking from experience)

lywjoel commented 5 years ago

Hi @javenseow, perhaps you can try using MainApp.class.getResource(/path_to_picture/).toExternalForm() Chanced upon it when I was searching for a solution for my team's problem (same team as @ooihuiying)

lywjoel commented 5 years ago

Our team decided to opt for not replacing the WebView in BrowserPanel with another JavaFX element like a Stackpane, but to append JSON elements as a query to the end of the URL (URL + "?name=Example&phone=12345678"), as was done for the dummy search page, and for the BrowserPanel to load a separate styled HTML file. The display works when we run the product via MainApp.java, and the parsing is done properly within the HTML file. However, packaging it in a JAR file seemed to break its functionality as the HTML would not display within the WebView at all. At first, I thought that the program was not retrieving the HTML file from the resources folder properly, but upon removing the query string from the URL, the HTML file managed to load without any information displayed. I suspect that the problem lies with the JAR file trying to locate the HTML file with the query string as part of the filename. However, without the query string, we have no way of displaying the Person's information on the HTML page. We only discovered this issue after packaging our JAR two days ago before our tutorial, and have been unable to come up with a workaround. The only possible solution seems to be replacing the WebView with other JavaFX elements, but we are unlikely to be able to get a placeholder done in time for the PE dry run tomorrow. Requesting for advice!! 😢

damithc commented 5 years ago

We only discovered this issue after packaging our JAR two days ago before our tutorial, and have been unable to come up with a workaround. The only possible solution seems to be replacing the WebView with other JavaFX elements, but we are unlikely to be able to get a placeholder done in time for the PE dry run tomorrow. Requesting for advice!! 😢

Is the product entirely unusable due to this? If that is the case, you will not be able to receive bug reports for your product from the PE dry run. If there are other features that work, testers can test those features.

ghost commented 5 years ago

The changes made by commands is reflected mainly through the WebView apart from help messages describing the outcome of the command. Hence, users will not be able to check whether the changes are reflected inside the storage or not.

Due to the constraint of time, is it acceptable for us to test the product from IntellijIDEA instead for PE dry run? The HTML works as intended when it runs from the IDE. (same team as @lywjoel and @ooihuiying )

damithc commented 5 years ago

Due to the constraint of time, is it acceptable for us to test the product from IntellijIDEA instead for PE dry run? The HTML works as intended when it runs from the IDE. (same team as @lywjoel and @ooihuiying )

It's not you who will be testing. I don't think the students allocated to test your app can be forced to set up your project on their computer but they can be given the option. Please specify your team ID here so that I can notify the relevant testers about the problem.

lywjoel commented 5 years ago

Thanks Prof @damithc, our team is W13-4.

lywjoel commented 5 years ago

Hi Prof, we have managed to release a v1.3.1 with a simple GUI in time. I think it should suffice for the PE dry run! Thanks!

damithc commented 5 years ago

Hi Prof, we have managed to release a v1.3.1 with a simple GUI in time. I think it should suffice for the PE dry run!

Good to hear that :-)