GWT makes it easier to build a rich Ajax browser client interface than to build a traditional Java GUI interface. However, even a good technology like GWT cannot build a complete WEB application on its own. You must also have a data store on the server and a type of framework to convert the data into a Java object that GWT can pass to its customers from the server. In this series of articles, you will use Apache Derby, the 100% pure Java database, to embed it in the same Java Virtual machine (JVM) as the rest of the server-side code.
The first article in this series focuses on GWT. Here you will learn how to set up GWT and create a simple client interface to respond to user actions. Later articles will show you how to set up the Derby database and connect your GWT front-end to a derby-based backend. Ultimately, you will learn how to deploy your system outside of your development environment.
What is Google Web Toolkit?
With GWT, you can use the Java programming language to develop AJAX applications. Ajax applications are characterized by rich, interactive environments that are often associated with traditional UI applications. Figure 1 shows a sample GWT interface that mimics the desktop e-mail application. This demo can be seen on GWT's Web site.
Figure 1. GWT e-Mail Demo
The most unique feature of GWT is that you can create Ajax applications while still writing code in the Java language. You can use your favorite Java integrated development environment (IDE), and the better thing is that you can also debug your clients in the Java IDE. You can use Java objects to communicate between the client and the server, which is much lighter in the client than when using Java applets.
Basically, GWT is a compiler. It translates the Java code you write into JavaScript code, which is then inserted into the HTML page and used by the client running the application. This feature allows you to avoid the minutiae of supporting JavaScript code on multiple browsers, allowing you to focus on the interface and interaction of your program.
Of course, if the compiler is the only feature that GWT offers, it won't be too exciting. Luckily, it has brought us more than that. With GWT, the compiler is simply a mechanism for delivering the entire client/server application architecture. The features include:
A standard set of UI widgets (widgets) that look good, have high flexibility, and are tuned to work in all major browsers, including Safari and Opera.
An event mechanism that captures and responds to events entirely on the client.
A framework for managing asynchronous calls between Web applications and servers.
A mechanism for creating stateful browser history so that your Ajax applications do not become cluttered by the possibility of backward (back) button behavior.
A test framework that uses JUnit to write unit tests for client applications.
This series explores the majority of the above features. But first please download and install GWT.