Java J2EE Portal
Enterprise Java Station
J2EE curve
Java News / Articles
Java News / Articles
AJAXEnabled
Are you Ajax Enabled? Everybody else is...
Integrating and Interoperating between J2EE and .NET Solutions
J2EE vs JavaEE - Simplify programming
Processing...
Buy Java, Deals On Software Technology Store
Click here for great deals on computers, laptops, software and books
Creating a new Google Web Toolkit (GWT) application PDF Print
Written by Content Team   
Apr 02, 2007 at 02:04 AM

Google Web Toolkit (GWT) is one of the most popular AJAX frameworks today. It's an open source framework that makes writing AJAX applications easy for developers. You write your front end in Java and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.

In the book Google Web Toolkit GWT Java AJAX Programming from Packt, author Prabhakar Chaganti provides a step-by-step guide to GWT. Below is Chapter 2 from the book. Visit PacktPub.com for more information on this book.

Creating a New GWT Application

In this chapter, we will use the GWT tools to generate a skeleton project structure and files, with and without Eclipse support. We will then create our first AJAX application (a random quote application) by modifying the generated application to add functionality and finally run the application in both hosted and web mode.

The tasks that we will address are:

* Generating a new application
* Generating a new application with Eclipse support
* Creating a random quote AJAX application
* Running the application in hosted mode
* Running the application in web mode

Generating a New Application

We will generate a new GWT application by using one of the GWT scripts. These helper scripts provided by GWT create the skeleton of a GWT project with the basic folder structure and initial project files, so that we can get started in creating our new application as quickly as possible.

Time for Action-Using the ApplicationCreator

The GWT distribution contains a command-line script named applicationCreator that can be used to create a skeleton GWT project with all the necessary scaffolding. To create a new application, follow the steps given below:

1.Create a new directory named GWTBook. We will refer to this directory location as GWT_EXAMPLES_DIR. This folder will contain all the projects that will be created while performing the various tasks in this book.

2.Now create a subdirectory and name it HelloGWT. This directory will
contain the code and the files for the new project that we are going to create in this chapter.

3.Run the GWT_HOMEapplicationCreator by providing the following parameters in the command prompt:

applicationCreator.cmd -out GWTBookHelloGWT
com.packtpub.gwtbook.HelloGWT.client.HelloGWT

The -out parameter specifies that all the artifacts be generated in the
directory named HelloGWT. The fully qualified class name provided as the last parameter is used as the name of the class that is generated by the
applicationCreator script and marked as the EntryPoint class for this
application (we will cover the EntryPoint class in the next section).

The above step will create the folder structure and generate several files in the
GWT_EXAMPLES_DIRHelloGWT directory as shown in the following screenshot:

What Just Happened?

The applicationCreator script invokes the ApplicationCreator class in gwt-dev-xxx.jar, which in turn creates the folder structure and generates the application files. This makes it very easy to get started on a new project as the whole structure for the project is automatically created for you. All you need to do is start filling in the application with your code to provide the desired functionality. A uniform way of creating projects also ensures adherence to a standard directory structure, which makes it easier for you when you are working on different GWT projects.

Here are all the files and folders that were automatically created under the GWT_EXAMPLES_DIRHelloGWT directory when we ran the applicationCreator command:

src

HelloGWT-compile.cmd

HelloGWT-shell.cmd

PAGE 1 OF 6


Add This Feed Button

Enter your Email

IndicThreads.com Conference On Java Technology, Pune, India
Java Expert Interviews
TitusBrown
Test Driven Development doesn't fit my brain
Open-Source keeps me 'coding fit'
RichUngerNetBeans
NetBeans was the early bird but has Eclipse caught the worm?
Processing...
Go to top of page  Home |
SiteMap

Copyright 2004 to 2008 Rightrix Solutions. All rights reserved. All product names are trademarks of their respective companies. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. Rightrix Solutions and IndicThreads.com are independent of Sun Microsystems, Inc.

Views expressed at IndicThreads.com reflect the views of the authors alone, and do not necessarily reflect those of IndicThreads.com. IndicThreads.com and it's authors are not responsible for reader comments and opinions.

Enterprise Java J2EE JEE Portal >> IndicThreads.com