GWT-Ext is a great set of widgets for the Google Web Toolkit (GWT). At the time of writing the release candidates for GWT 1.6 are out. GWT 1.6 has a different project structure and embedded Java Servlet (Jetty) server. These changes bring the advantage that the project structure can be deployed directly to a Java Servlet server (such as Jetty of TomCat) without having to manually create the WAR directory. A slight disadvantage is that the setup documentation for GWT-EXT is no longer quite right.
Below I describe the steps necessary to create a GWT 1.6 project with eclipse and configure it for GWT-Ext.
Below I describe the steps necessary to create a GWT 1.6 project with eclipse and configure it for GWT-Ext.
- Install the Google Plugin for Eclipse (http://code.google.com/eclipse/docs/getting_started.html).
- Use the plugin to create simple GWT application:
- Select File -> New -> Web Application Project from the Eclipse menu.
- In the New Web Application Project wizard, enter a name for your project (e.g. MegaDeth) and a java package name, e.g.,
com.megadeth
. - Take the tick out of the Use Google App Engine tick box.
- Click Finish.
- Select File -> New -> Web Application Project from the Eclipse menu.
- To run the application:
- Right click it in package explorer and select Run As -> Run Configurations
- Put a tick in the Automatically Select Unused Port tickbox.
- Click Run to see the default GWT 1.6 application
- Right click it in package explorer and select Run As -> Run Configurations
- Download
gwtext-2.0.5.zip
, unpack it and copy thegwtext.jar
towar\WEB-INF\lib
in the project directory. - Create a
js
directory in thewar
directory of the project. - Download
ext-2.0.2.zip
, unpack it and copy the contents to thejs
directory. - Right click on the project in package explorer and select Refresh so that eclipse can see the new jar and
js
directory. - Add
gwtext.jar
to the project:- Right click on the project in package explore
- Select Properties -> Java Build Path -> Libraries.
- Click Add JARs, navigate to
gwtext.jar
in the project and double click it. - Click OK to close the properties dialog.
- Right click on the project in package explore
- In the project's gwt.xml file (e.g. com.megadeth\MegaDeth.gwt.xml) at the hightlight lines below:
<inherits name='com.google.gwt.user.User'/>
<inherits name='com.gwtext.GwtExt' />
...
<entry-point class='com.megadeth.client.MegaDeth'/>
<stylesheet src="../js/ext-2.0.2/resources/css/ext-all.css" />
<script src="../js/ext-2.0.2/adapter/ext/ext-base.js" />
<script src="../js/ext-2.0.2/ext-all.js" />- Change the project's entry point (e.g.
com.megadeth.client.MegaDeth.java
) to the following:
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
import com.gwtext.client.widgets.Panel;
public class MegaDeth implements EntryPoint
{
public void onModuleLoad()
{
Panel mainPanel = new Panel();
mainPanel.setTitle("Hello World!");
mainPanel.setHeight(300);
mainPanel.setWidth(500);
RootPanel.get().add(mainPanel);
}
}- Remove the following from the project html file (e.g. war/MegaDeth.html):
<h1>Web Application Starter Project</h1>
<table align="center">
<tr>
<td colspan="2" style="font-weight:bold;">Please enter your name:</td>
</tr>
<tr>
<td id="nameFieldContainer"></td>
<td id="sendButtonContainer"></td>
</tr>
</table>- Run the application as before to see a GWT-Ext panel.
- Change the project's entry point (e.g.
Thank you for this! I'm new at all this stuff, and this was perfect!
ReplyDeletePaul! Thank a lot!
ReplyDeleteThis is really kind of comment blogging worth playing!
You've brightened my day!
No worries. Glad to help. You guys should also read this: http://www.sambastream.com/blogs/agiannone/26-01-09/rich-internet-applications-and-web-20-gwt-ext-gxt-and-smartgwt.
ReplyDeletehmmm, I must have done something wrong. If I untick the google web app when it is created, the wizard does not create a gwt.xml file (com.megadeth\MegaDeth.gwt.xml) for step 9.
ReplyDeleteThank a lot Thats perfect
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteHi Paul,
ReplyDeleteGlad to see you found my blog interesting. Just to let you know that I have created a new post around GWT/GXT and performance:
http://www.sambastream.com/blogs/agiannone/29-05-09/high-performance-gxt-gwt-applications-coding-java-javascriptLet me know what you think.
Ale
I seem to have problems when I add extra items to my EntryPoint. Even adding the line "import com.gwtext.client.widgets.ToolTip;" to the import section causes an "'Ext' is undefined" error. Any ideas what would be causing this? To be clear, the project works fine with the exact example you give, but when I try to add extra widgets, nothing seems to work.
ReplyDeleteAnother point is that when I use this for something like a Button, the button shows up just fine, but I still get that Error msg.
ReplyDeleteHere are some pics that I took and put on Picasa. I am a total newbie to GWT so any help is appreciated:
http://picasaweb.google.com/jonapugh/Code#
Thanks a lot, Paul, for the instructions. You made my life easy !!
ReplyDeleteYour example doesn't work for me at all.
ReplyDeleteI keep getting an "EXT is undefined" error.
I'm using GWT-EXT 2.0.6. Should that make a difference?
Hi, I'm sorry to hear that. I'm not using GWT-EXT anymore as it's no longer being developed. We've switched to GXT.
ReplyDeletethanks paul. that was very helpful.
ReplyDeleteGuyz like u keep the industry moving . otherwise guyz like us r jus to use resources to look for spoon feeding.
gurudeb vi...!
ReplyDeletesomosto kichu thik thak ache....!
Thanks a lot!!
ReplyDeleteI would be very grateful if you please show the
steps to connect to MySQL Database in GWT in eclipse
You're most welcome. However, I don't think GWT-Ext is active and its website suggests that maybe you should look at Smart GWT.
ReplyDeleteAs for accessing MySQL from GWT, in short you don't. You need to setup some RPC calls to the server and access the database from there in the usual way.