GWT

From Stax

Jump to: navigation, search

With Google Web Toolkit (GWT), you write your AJAX front-end in the Java programming language which GWT then cross-compiles into optimized JavaScript that automatically works across all major browsers.

Stax includes a GWT application template so you can get started with your first GWT application in just a few seconds. Just choose the GWT application template from the Stax Application Wizard, or use the following command from the Stax SDK: stax create -t gwt <appname> After you've created your application and examined the source to see the basic concepts, check out some of these GWT resources to learn more.

Contents

GWT Links


GWT Project Overview

Note: Before you will be able to build your GWT project, you must first download the latest version of the Google Web Toolkit and then set the GWT_HOME environment variable.

Project layout

After creating your GWT application using the GWT application template, you will see a directory structure similar to the following:

src Java source files
src/.../client GWT client source files (compiled into JS+HTML by GWT compile commands)
src/.../public GWT web resources used by GWT compiler
src/.../server server-side source files
test Java source files for tests
war The WAR file directory structure
war/WEB-INF/web.xml J2EE web deployment descriptor
war/WEB-INF/stax-web.xml Stax web deployment descriptor
build Generated project files (including the project war file)

Project lifecycle commands

Compile

Compilation of GWT apps is implemented via the compile targets in the build.xml ANT script. These targets will compile the GWT client source files into HTML+JS using the GWT compiler, and will compile the server-side java components using the standard Java compiler.

The GWT application template supports builds using the standard stax compile command:

stax compile

alternatively, builds can also be performed directly via ANT

ant build

Run the server

To run the application in the Stax local server, you can use the standard stax run command:

stax run

Alternatively, you can also directly invoke the ANT run target

ant run

Running the GWT browser (aka hosted mode)

The hosted-mode GWT browser is a crucial part of the GWT development workflow as it allows developers to quickly test changes made to the Java client source files without requiring a full GWT compile cycle (which takes 10 secs minimally). Instead, the GWT hosted browser environment will let you click the refresh button in the browser, which will automatically reload client in the browser using the latest Java client source (ignoring the compiled binaries). To launch the GWT hosted-mode browser, you can use the stax gwt:hosted command

stax gwt:hosted

Alternatively, you can use GWT ant hosted command to invoke the hosted target

ant hosted

Note that you will need to run the local server (see 'Run the server' above) before you will be able to serve the client source files.

Deploy

To deploy your GWT application, use the standard stax deploy command

stax deploy
Personal tools
Navigation