Google Web Toolkit Guide

Your informal guide to GWT

Hello World App:

I've written a tutorial for GWT. Use it to create your first GWT app. Done? Good. Now that you have an application that greets you with a 'Hello World!', lets look into some concepts before further coding.

Core Pieces:

  • UI - GWT provides you a list of Panels and Widgets to create your UI. If they don't satisfy your need, you can create on your own
  • Communication - GWT defines a RPC mechanism. Both the Service and Consumer code will be in Java
  • Modules - Modules are the unit of configuration in a GWT app. Modules tell about the entry point, services, etc 
  • Testing - JUnit is the defacto standard for testing Java code. GWT is no exception. It provides you GWTTestCase, which will bridge GWT and JUnit
  •  Javascript - Yeah, I know. There will be always a case where we need some custom Javascript coding. GWT has 'JavaScript Native Interface'  which allows you to integrate your handwritten JavaScript code 

More on Modules:

A modules will contain all the settings of your GWT project. Its defined in an XML with .gwt.xml extension. Referencing a module is very much like a java class.For example a module defined in the directory com/example/gwt/SomeModule.gwt.xml is referred as com.example.gwt.SomeModule

Typically a user defined module will inherit from But inheritance is optional and its not limited to one super module. You can inherit from as many modules as you wish. Its defined like:

    <inherits name=''/> 
    <inherits name='com.example.gwt.SomeModule'/>

Modules can define startup classes called as entry point class in GWT. The class should extend the interface, which defines only one method - onModuleLoad, where all your startup codes goes into.

    <entry-point class='com.example.gwt.first.client.App'/>

The modules can define source path. Souce path contains the Java classes that needs to be translated into JavaScript. In other words source path contains the client-side code. Source path is optional. If not specified and if a directory called client exists in same directory where the module XML resides, the GWT considers it for translation. The command line application creator tool creates this client directory for you.

        <source path="client"/> 

Modules can also define another path called the public path. Like source path, these also contains resources  accessed by the browser, but these resources are not meant for translation by GWT. Your images, css, Htmls go here.

        <public path="public"/>

When you implement GWT's RPC, you will be creating classes by extending RemoteServiceServlet. The URI mapping of those servlets are configured thru servlet tag. It has two attributes the class and path

        <servlet class="com.example.gwt.server.MyRemoteService" path="/myRemoteService" />

All put together, your module file looks like this:

    <inherits name="" /> 
    <inherits name="com.example.gwt.SomeModule" />
    <entry-point class="com.example.gwt.first.client.App" />
        <source path="client" /> 
        <public path="public" />
        <servlet class="com.example.gwt.server.MyRemoteService" path="/myRemoteService" />

 More content:

Coming soooooon. Stay tuned...

Coming soon. Stay tuned ...