Google Web Toolkit (GWT) is a web development toolkit is an
framework developed by Google. It’s build using Java as baseline language and allows J2EE developers to implement AJAX behavior in their web application without being expert in AJAX
Going little further in deep, an application is divided into tow parts namely client and server components. All the calls made from client to server are asynchronous. Please refer “Starting with GWT” for more details on GWT basic architecture.
Coming to its uses and limitations aspects, let’s go through its uses first and then the limitations.
Usage of GWT:
- GWT framework usage Java as baseline language and hence can be easily integrated into Java applications.
- Since programming constructs are very similar to Java, learning curve is very small.
- By default, all the requests made by client is asynchronous, the application with much complex client server interaction becomes much more efficient without much effort investment.
- GWT has plug-ins available for major IDE such as Eclipse, IntelliJ IDEA etc.
- GWT comes with its own testing server (Tomcat) called Hosted mode, and provides feature to quickly validate the functionality implemented right through the IDE itself.
- Since the application can be run in Hosted Mode from the IDE itself, debugging the application becomes very easy especially the UI components.
- All the internal URLs of the applications are hidden from the user/hackers and can't be accessed directly bypassing the entry point of the application.
- It supports custom calls of native JS functions if any, though not recommended ant not easy.
- Other features such as Internationalization (i18n), logging are well supported in GWT.
This is only the first side of the GWT. Let’s look at the other side of it i.e. limitations of using GWT.
Limitations of GWT:
- All the client code should be clearly bundled with client package. If any server class is referenced in the client code, results into GWT compilation issue without a very clear message. This becomes trickier as both client and server java files are part of the same source code structure.
- GWT compiler output is not very clear and results into very high level compilation errors messages resulting into more effort into finding the root cause of the compilation error.
- Every call in GWT application is asynchronous so if there are any synchronous calls required, they have to be grouped in a single call otherwise need to be tricked with group of asynchronous calls.
- While writing client side code having multiple asynchronous calls involved, it becomes very tricky to uses out put of the first call into second call.
- It becomes more error prone when multiple asynchronous calls are involved in one user request. Developer uses class level variables to pass the details from one call to the other. This way the coding is done without any compilation error. Since the calls are asynchronous, we can’t guarantee the request processing time of individual calls. This leads into inconsistent behavior in the application. If not properly handled, the application may work/may not work as expected depending on the sequence of various individual asynchronous calls processing.
- Entire UI is developed using Java (GWT) and Style Sheets. This leads into same issues as servlets (UI elements tightly coupled in Java) and eliminates the advantage of having JSPs.
- If the code is running fine in hosted mode, but not running properly in real application deployment, it becomes very difficult to troubleshoot the code as the generated code from the GWTCompiler (which is actually running in production mode) is not very readable.
- Creating a screen with complex page layout becomes very tricky as not all HTML elements are supported through GWT.
- Novice users result into excessive use of the UI components (various panes e.g. Horizontal Pane, Vertical Pane) and later get confused about their positions and usage as they can be instantiated at any place in the code but only appear in UI at place where added to the base component.
- No assistance from UI editors such as Macromedia Dreamweaver.
To summarize, GWT is a very useful framework for application having simple UI with lot of client server interactions involved (where
is a required/applicable feature). It’s not suitable for an application with few requests (one or two) per screen and especially if the screen layout involves huge number of screen components. Many of the times, I have seen wrong usage of GWT where we bear with its limitations but not able to utilize its capabilities. Hence before going for GWT in any application, its applicability should be critically evaluated. AJAX