Search code examples
gwtuibinderclientbundle

In a GWT UiBinder template with an image resource, where should I locate the actual image file?


According to the docs, you can add an image resource to be used in a uibinder template like this:

public interface Resources extends ClientBundle {

  @Source("Logo.jpg")
  ImageResource logo();

  ...
}

Using this example as is, however, the image file (Logo.jpg) must be included in the same directory/package as Resources.java. Where should I put my image file and how should I list the file path so that I don't have to keep the image file in my src tree? Specifically, I'm using maven - don't I want my images in src/main/webapp, not in src/main/java/com/mygwtapp/client?


Solution

  • You can provide a relative path for your images like this:

    @Source("../../resources/images/Logo.jpg")
    ImageResource logo();
    

    The path is relative to where your Resources interface is located. And ../ stands for parent directory.