Google Web Toolkit (GWT) : Your first step !

Google Web Toolkit (GWT) is a development toolkit for building and optimizing complex browser-based applications. It is an open-source, Java-based framework for creating Ajax web applications. It is created and used by Google. With GWT, you can develop and debug AJAX applications in the Java language using the Java development tools of your choice. When you deploy your application to production, the GWT compiler translates your Java application to browser-compliant JavaScript and HTML.

What the code is ?

• Client-side code
– compiled to HTML and JavaScript
– uses CSS for formatting

• Server-side code can be implemented
– including Java 5 and 6
– commonly Java-based GWT RPC servlets are used

For now Let us implement a basic application say “My Total Bill App ” for your understanding using GWT Remote Procedure Call (GWT-RPC) . The whole thing what we have to do is to implement following:

  • Implementing the synchronous & asynchronous interfaces
  • Building user interface using GWT
  • Writing a service implementation

The basic GWT project structure looks like as:
 GWT Project Structure

1. Building user interface with GWT in MyTotalBill.java(Client Side)

After implementing this with corresponding HTML page you will find the user interface as follows:

My Total Bill

2.Implementing interfaces:-
Each RPC service must define a pair of interfaces: the synchronous interface, which is implemented on the server, and the asynchronous interface, which is called by the client-side code.

BillService.java(Client side)

BillServiceAsync.java(Client side)

3. Writing the Service implementation BillServiceImpl.java(Server Side) :-

4. Adding the onclick handler on submit button in MyTotalBill.java.

5.Configuring the web.xml file to define servlet mapping:

6. Now we are ready to run our application, the result will look like as:
MyBillApp

You can find My Total Bill app on GitHub.

Leave a Reply

%d bloggers like this: