A few days ago I started experimenting with the Google Web Toolkit module for the Netbeans IDE a rather nice module that lets you develop GWT code directly in your (at least mine!) very favorite IDE. The biggest benefit is free code completion and tagets for building and debugging your application.
A few remarks thought, when trying to integrate the awesome OFCGWT chart library in my application I had to face two problems.
First of all the GWT4NB tutorial on Netbeans.org says you should use the 1.4 java compiler because the GWT does not support Java EE 1.5. Well I’m pretty sure the GWT does not offer support for EJBs and the like (because it has nothing to do with the backend, it’s a UI toolkit!) but it does support Java SE 6 constructs. Thus, if you do select Java EE 1.4 when first creating your project be sure to then change the source/binary version to 1.6 in the project properties.
As an example I could not compile the OFCGWT example without it.
The next thing to be aware of is that the GWT4NB module does not fully comply with the URL assigned to your application by the GWT, when a typical application URL would look like (in GWT):
http://localhost:8080/UWTest/org.test.Main
Netbeans with the GWT4NB plugin exposes it as:
That basically means the entry point .html file is not located in org.test.Main in the GWT4NB version but rather directly at the root context of your app.
A consequence of this is that GWT modules assuming that the compiled javascript will be loaded by a page at org.test.Main will look for files in the wrong place. Namely, in the case of OFCGWT, the .js references .swf files which it expects to be located in the same folder as where it has been loaded from.
Anyway, I found two workarounds for that matter:
1:
We need to override the post-compile target in our build.xml which is guaranteed
never to be re-generated by the IDE:
<target name="-post-compile">
<property name="gwt.compiler.output.style" value="OBFUSCATED"/>
<property name="gwt.compiler.logLevel" value="WARN"/>
<java classpath="${javac.classpath}:${src.dir}"
failonerror="true"
classname="com.google.gwt.dev.GWTCompiler" fork="true"
maxmemory="512m">
<arg value="-out"/>
<arg path="${build.web.dir}/"/>
<arg value="-style"/>
<arg value="${gwt.compiler.output.style}"/>
<arg value="-logLevel"/>
<arg value="${gwt.compiler.logLevel}"/>
<arg value="${gwt.module}"/>
</java>
<property name="gwt.output.dir" value="${gwt.module}"/>
<move todir="${build.web.dir}/${gwt.output.dir}">
<fileset dir="${build.web.dir}/${gwt.module}"/>
<fileset dir="${build.web.dir}">
<include name="**/*.html"/>
<include name="**/*.css"/>
</fileset>
</move>
</target>
This will actually move all the .css and .html files of your web folder to the correct output dir. You then need to be sure that the correct .js file is loaded in your welcomeGWT.html file. That is: you need to remove the org.test.Main/ part.
When deploying Apache might not really be happy anymore since there is no html file at the root of your application anymore however, you just need to call it explicitely like:
http://localhost:8080/UWTest/org.test.Main/welcomeGWT.html and that
should do the trick! BUT –>
2:
BUT, that said, there is a much simpler way of getting rid of that problem: In gwt.properties change the line gwt.output.dir to gwt.output.dir=/
This will deploy the GWT files (all of them, including the .html and the ofcgwt .swf files) at the root http://localhost:8080/UWTest/ which then means that the .js, .swf and .html files are all located in the same folder and thus all on the same path.
This will actually move all the .css and .html files of your web folder to the correct output dir. You then need to be sure that the correct .js file is loaded in your welcomeGWT.html file. That is: you need to remove the org.test.Main/ part.