Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path for images folder in GWT project

Tags:

image

gwt

I have the following line of code to set the URL of an image I want to display

img.setUrl("images/img1.jpg");

Where should I place my images folder in order for it to get picked up correctly. Currently I have it in my WEB-INF folder but this does not appear to work. I get the error on my console "WARNING: No file found for: /images/img1.jpg" I created my project using Eclipse and I have not changed any folder structure.

like image 512
MayoMan Avatar asked Feb 25 '13 16:02

MayoMan


People also ask

How do I find the path to an image file?

Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document. Properties: Click this option to immediately view the full file path (location).

What is HTML Path?

An HTML file path is used to describe the location of a file in a website folder. File paths are like an address of file for a web browser. We can link any external resource to add in our HTML file with the help of file paths such as images, file, CSS file, JS file, video, etc.


2 Answers

You should make a folder named images under your war/project_folder and place the images there.

And while setting the Url you shoud do

image.setUrl(GWT.getModuleBaseURL()+"images/im1.jpg");

You can use either GWT.getModuleBaseURL() or GWT.getHostPageBaseURL().

like image 118
Adarsha Avatar answered Oct 24 '22 12:10

Adarsha


Create a public folder (named "public") alongside with folders "client" and "server". The content of the public folder will be copied into the war.

>src
  >com
    >test
    >client
--->public
        >images
    >server
    >shared

Voilà!

like image 36
Patrick Hamel Avatar answered Oct 24 '22 13:10

Patrick Hamel