Learning Google Web Toolkit

Google Web Toolkit is an interesting project. It’s basically an AJAX toolkit but presents itself as a Java toolkit. The idea is that you still write Java code as you would with Java AWT, SWING, and the GWT converts it to JavaScript code for you.

But why don’t write JavaScript code directly? Well, you may know Java better than JavaScript. More importantly, Java is a typed language and easier to develop a large system than JavaScript.

Bothered by SLOW Web UI to manage vSphere? Want to manage ALL your VMware vCenters, AWS, Azure, Openstack, container behind a SINGLE pane of glass? Want to search, analyze, report, visualize VMs, hosts, networks, datastores, events as easily as Google the Web? Find out more about vSearch 3.0: the search engine for all your private and public clouds.

Using GWT for Java developers is mostlya piece of cake. You need to download and install JDK, GWT SDK, Eclipse, Google plug-in, and the recently Instantiation designer. The designer is from acquisition of Instantiation and really optional, but it’s a great tool that can make your life easier especially for prototyping. The nice thing about the designer is that the code generated is pretty human readable, thus easy to modify.

Of course, GWT code is different from a typical Java code. One noticeable difference is the GWT code has entry point instead of the main() in a typical Java application. You also need to know how to embed the Java code (to be compiled to JavaScript) into host HTML page and how to change component styles using CSS. The GWT also support XML based GUI development called UIBinder, similar to the XAML in WPF.

If you are using Eclipse with Google plugin, debugging GWT web application is very similar to other applications.

An advanced feature in GWT is the RPC (Remote Procedure Call) that facilitates the client (JavaScript) and Server (Servlet) communication. You don’t need to worry about the details like serialization and de-serialization, but to define an interface X that extends the “com.google.gwt.user.client.rpc.RemoteService”.

On the server side, you write implementation class Y that implements X and extends from “com.google.gwt.user.server.rpc.RemoteServiceServlet”. It’s pretty straight-forward.

On the client side, it’s a bit different. You need to create a corresponding asynchronous communication interface AsyncX with a bit of twisting on the interface. If you have a method as: (from Lars’ tutorial, the same for the next)

List<MyUser> getUserList();

The asynchronous version looks like:

void getUserList(AsyncCallback<List<MyUser>> callback);

Then you implement the AsyncCallback<List<MyUser>> interface in a class and register it with service so that the callback can be invoked when response comes back. It is not that straight forward. You’d better off to run through a sample for a better sense how it works.

While learning the GWT, I found the tutorial by Lars Vogel very helpful. It walks you through a right sized sample step-by-step within 2 hours. You can find many different tutorials from his web site. I highly recommend Lars’ tutorials.

This entry was posted in Software Development and tagged , , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>


    My company has created products like vSearch ("Super vCenter"), vijavaNG APIs, EAM APIs, ICE tool. We also help clients with virtualization and cloud computing on customized development, training. Should you, or someone you know, need these products and services, please feel free to contact me: steve __AT__ doublecloud.org.

    Me: Steve Jin, VMware vExpert who authored the VMware VI and vSphere SDK by Prentice Hall, and created the de factor open source vSphere Java API while working at VMware engineering. Companies like Cisco, EMC, NetApp, HP, Dell, VMware, are among the users of the API and other tools I developed for their products, internal IT orchestration, and test automation.