-
Book Overview & Buying
-
Table Of Contents
Google Web Toolkit 2 Application Development Cookbook
By :
All the required tools and technologies are installed. Now, we will create the Java Web project using the Google Web Toolkit Framework in NetBeans.
Make sure that GWT and GlassFish are installed, the GlassFish server is added, and the GWT4NB plugin is installed in NetBeans.
Start NetBeans.
Go to File | New Project.
Select Java Web from the Categories field, and Web Application from the Projects field, as shown in the following screenshot:
![]() |
Click on Next.
Give Sales Processing System as the Project Name, browse the Project Location, and check Set as Main Project:
![]() |
Click on Next.
Select GlassFish v3 from the Server list, and Java EE 6 Web from the Java EE Version.
Set the Context Path, or leave it as suggested. It is the path to the "root directory" of a web application (called the context root), relative to the root of the web server namespace.
![]() |
Click on Next.
Select Google Web Toolkit from the list of frameworks, browse for the GWT SDK Installation folder (such as C:\Program Files\gwt-2.0.3, or any other location where you have installed it), and name the GWT Module as com.packtpub.Main:
![]() |
Click on Finish on completion of the installation.
After following the aforementioned steps, a NetBeans project structure with some sections containing the following files has been created:
Web Pages
WEB-INF
sun-web.xml
web.xml
welcomeGWT.html
Source Packages
com.packtpub
Main.gwt.xml
com.packtpub.client
MainEntryPoint
Libraries
GWT2.0.3-gwt-user.jar
gwt-dev.jar
gwt-servlet.jar
JDK1.6
GlassFish v3
![]() |
A directory and file structure is created, as shown in the following screenshot:
![]() |
A default code is given in the MainEntryPoint.java file. That's why, we can run the project to see a basic output. To run the project, right-click on Sales Processing System under Projects and then click on Run, as shown in the following screenshot:
![]() |
The following events take place:
GlassFish is started automatically, if it is not started yet. It will prompt the user for the username and password. Provide "admin" as the username and "adminadmin" as the password (or as we had set during the installation of GlassFish).
The project is compiled by GWT Compiler.
The project is deployed to the \Sales Processing System\build\web directory.
The default browser is called with the URL http://localhost:8080/Sales_Processing_System/.
The output is a button labeled Click me!. If the button is clicked, a label, Hello, GWT!!!, is hidden and displayed alternately:
![]() |
Change the font size
Change margin width
Change background colour







