GWT Basics - AthanasiosPavlou/sandbox-modules Wiki

This report describes the contents of the sample GWT web application created by the GWT command line tool or the Eclipse plugin. The description goes beyond a simple listing of the project’s contents, attempting to provide enough detail for a more complete understanding of the project structure, its contents and their interaction. The report is in essence a restructuring of information already available online (please see references)

The only requirement to follow this report is to create a GWT project using Eclipse (if you have the GWT plugin installed) or the GWT command line tool by executing: webAppCreator -out MyWebApp com.mycompany.mywebapp.MyWebApp

After the successful creation of the sample project MyWebApp a number of folders, packages and files will be generated. These are described below:

File MyWebApp.launch: If you are using Eclipse, you can launch the app in development mode, by running the .launch configuration file created by webAppCreator using the Run or Debug menus.

You will spend most of your development time running your application in development mode, which means that you are interacting with your GWT application without it having been translated into JavaScript. Anytime you edit, run, and debug applications from a Java integrated development environment (IDE), you are working in development mode. When an application is running in development mode, the Java Virtual Machine (JVM) is actually executing the application code as compiled Java bytecode, using GWT plumbing to connect to a browser window. This means that the debugging facilities of your IDE are available to debug both your client-side GWT code and any server-side Java code as well. By remaining in this traditional "code-test-debug" cycle, development mode is by far the most productive way to develop your application quickly.

As of GWT 2.0, development mode uses a regular browser instead of an embedded browser. You can use any supported browser, including ones on other machines, as long as it has the GWT Developer Plugin installed. If you use a browser that does not have the plugin installed, you will get a message with an offer to download the plugin. Browsers are typically opened automatically via the -startupUrl command line option (though GWT will try to find plausible startup URLs if you do not supply any).

File build.xml: To launch a development mode session, from the command line run ant devmode, assuming you have an Ant build.xml file generated by webAppCreator. Let's look behind the scenes when you launch your GWT application in development mode. To run development mode, you start a Java VM using the main class If you look inside a generated ant build.xml, you'll find something like this:

<target name="devmode" depends="javac" description="Run development mode"> <java failonerror="true" fork="true" classname=""> <classpath> <pathelement location="src"/> <path refid="project.class.path"/> </classpath> <jvmarg value="-Xmx256M"/> <arg value="-startupUrl"/> <arg value="Hello.html"/> <arg value=""/> </java> </target>

This is similar to running the following command on the command line:

java -Xmx256M -cp "src;war/WEB-INF/classes;\gwt-2.0.0\gwt-user.jar;\gwt-2.0.0\gwt-dev.jar" -startupUrl Hello.html

The -startupUrl parameter tells Development Mode which URL(s) to make available for launching. If the value excludes the domain, the domain is assumed to be localhost. The port is assumed to be the port running the embedded server. In the example above, this address is http://localhost:8888/Hello.html (with an additional parameter giving the location of the development mode code server).

Folder war: By default, development mode runs an internal Jetty instance to serve your web application. This embedded Jetty instance serves directly out of your project's war directory. You can disable this internal server by passing the -noserver option to development mode and instead run your own external server.

Package com.mycompany.mywebapp

Packages com.mycompany.mywebapp.client and com.mycompany.mywebapp.server

These contain the service descriptors as well as the app’s main entry class ( The default example is using GWT-RPC for client-server communication. The GWT-RPC mechanism lets you send Java objects between the client and server with little work on both the client and server sides.

There are three parts to the GWT-RPC mechanism. The first is the service that runs on the server as a servlet, the second is the web browser that acts as a client and calls the service, and last are the data objects that pass between the client and server.

In brief the steps are the following:





e-book GWT in Action

[1] [2] [3] [4] [5] <- the gwt libary supports HTML features one of the is storage that could be useful.