Search code examples
gwtsmartgwt

Smartgwt & gwt Show Image From External Folder


It is possible to show an image by directly typing

Img image = new Image();
image.setSrc("photo.jpg"); 

if photo.jpg is under "images" folder under Web-Content.

I have task to show an image which is in a folder on desktop, is that possible in any way? I did lots of research but not come to a solution. Thanks.

Smartgwt 2.4 Ubuntu 10.10 Gwt 2.2


Solution

  • If your structure is something like:

    myproject
     |-->src
     |||||-->com.myproject
     |||||||||-->client, server, shared
     |-->war
     |||||-->images
    

    ...you would use images from the war/images folder in files within the client package by referencing them as images/image.png. So your code ought to look like:

    image.setSrc("images/photo.jpg");
    

    The path of the image is relative to the war directory.