14

In my Google web toolkit application, my gwt.xml file includes the following line in the module:

<module rename-to='foo'>
...
  <script src="foo.js"></script>
...

My question is: where in my GWT project do I actually place foo.js so that it gets packed into the war when I compile my project?

0

1 Answer 1

18
+200

Put it in a public folder. A public folder is a folder placed next to a client folder in the same package where your gwt.xml file is located. See also http://code.google.com/webtoolkit/doc/1.6/DevGuideOrganizingProjects.html#DevGuideModules

Sign up to request clarification or add additional context in comments.

24 Comments

I have made a folder named public within the src directory. So, given my project name is foo, com.google.sample.foo.client, com.google.sample.foo.server, public are all under the src folder. I have kept the jquery.js file and another js file foo.js inside the public folder. I have added the lines <script src="jquery.js" type='text/javascript'"></script> and <script src="blur.js" type='text/javascript'"></script> to the gwt.xml file.
Then I have added these lines in the head section of the HTML file in the war folder: <script src="jquery.js" type='text/javascript'"></script> and <script src="blur.js" type='text/javascript'"></script>. The blur.js contains a single click handler for an element already defined in the HTML file. However, when I click on that element in the browser page, nothing happens. What else do I need to do?
@Cupidvogel: Did you put the scripts in com.google.sample.foo.public or the public directory under the src directory? Because it should be next to the client directory? Also when adding it as script to the HTML page you would need to add the module name to the path, because the files in public are placed in the modulename subfolder. i.e.: <script src=foo/jquery.js>. Or insert them via the script tag in your module gwt.xml file: developers.google.com/web-toolkit/doc/1.6/… (without the module name in the src path).
I made a new folder named public, at the same level as war, src, test. I have kept both files there. I didn't understand your module part, please explain a bit more. What do I now need to do in the XML and HTML files to make these scripts working?
The public folder must be placed in the directory where your <module>.gwt.xml is, otherwise GWT can't find it. It must be at the same level as the client directory. If you have this correct, you will find in the war a directory with your modulename. This directory has all GWT generated files. Anything in a public directory will also be in that directory. To access them from your HTML page, set the src path to this folder, hence the module reference. If you put the script tags in your gwt.xml file,GWT will take care of the path and you can specify the src tag in the gwt.xml as you have now.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.