how to find the path to image resources

414 views
Skip to first unread message

mars

unread,
Jan 11, 2012, 2:32:26 PM1/11/12
to Google Web Toolkit
hi,

i have a maven gwt project, no exception all the images are stored
under 'src/main/webapp/img', then in the package :
'com.mycom.myapp.client' i have Resources.java which defines all
images/text/css resources for the whole project as below:

public interface Resources extends ClientBundle {
final static String IMG_ROOT_PATH = "src/main/webapp/img/";

Resources INSTANCE = GWT.create(Resources.class);

@Source(IMG_ROOT_PATH + "logo.png")
ImageResource logo();

}

however when i complied it complaint cannot find that image. how
should i specify the path here? thanks

StrongSteve

unread,
Jan 12, 2012, 5:18:14 AM1/12/12
to Google Web Toolkit
You have to navigate relatively from the directory your Resource
interfaces resides in...

Thomas Broyer

unread,
Jan 12, 2012, 6:15:30 AM1/12/12
to google-we...@googlegroups.com
@Source paths are resolved in the *classpath* (using ClassLoader.getResourceXxx), not the filesystem.

...but I don't understand what you're trying to do:
  1. src/main/webapp contains the files that can/will be served via HTTP (e.g. src/main/webapp/img/foo.png will be available at http://server/app/img/foo.png);
  2. ClientBundle *bundles* its resources itself (either as data: URIs in the CSS and/or JS, and/or as *.cache.* files next to the *.nocache.js)
Unless you have a very very specific use case, you should choose one way or the other.
Reply all
Reply to author
Forward
0 new messages