Say I’m hosting a project at http://example.com/foo. I put all of the GWT files (which are generated in the /war/ directory after compiling) in http://example.com/foo/GwtModule directory.
Then on my host page, which is http://example.com/foo/bar, I put the following in the HTML:
<script type="text/javascript" src="http://example.com/foo/GwtModule/GwtModule.noCache.js"></script>.
My questions are:
-
Will GWT know to fetch its resources (e.g css files) from foo/GwtModule folder rather than trying to get them from foo/bar folder?
-
If I wanted to send a HTTP request to foo/signup, would
GWT.getModuleBaseUrl() + "signup"work or will I have to parse the base url, remove “/bar” from it and replace it with “/signup”? -
If I run the code locally as well as on a web server, will GWT automatically determine if the base url is
http://localhost/foo/baror http://example.com/foo/bar , or do I need to hard-code the base urls somewhere?
Yes.
GWT always resolves the module base from the script URL (or a special
<meta name='gwt:property'>)GWT.getModuleBaseURL()will be/foo/GwtModule/.You can either use
GWT.getModuleBaseURL() + "/../signup"or"GWT.getHostPageBaseURL() + "/signup", in your case they’ll both resolve to the same/foo/signupURL.See answer to first question.
That means you’ll have to use
<script src="GwtModule/GwtModule.nocache.js">or<script src="/foo/GwtModule/GwtModule.nocache.js">in your host page.