Home  Client Side Scripting  EXT GWT

“EXT GWT frequently Asked Questions in various EXT Google Web Toolkit job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting”

32 EXT GWT Questions And Answers

1⟩ Explain GWT Enterprise Usage?

GWT uses or supports Java, Apache Tomcat (or similar web container), Eclipse IDE, Internet Explorer, and Internationalization and Localization. Java-based GWT RIAs can be tested using JUnit testing framework and code coverage tools. Because GWT allows compile time verification of images, CSS, and business logic, many common development defects are automatically discovered without need of the manual testing commonly required by RIAs.

Google has noted that some of its products are GWT based:

► Orkut

► Blogger

► AdWords

► Flights

► Wallet

► Offers

► Groups


2⟩ What is EXT GWT (Google Web Toolkit)?

Google Web Toolkit or GWT Web Toolkit, is an open source set of tools that allows web developers to create and maintain complex JavaScript front-end applications in Java. Other than a few native libraries, everything is Java source that can be built on any supported platform with the included GWT Ant build files.


3⟩ Explain GWT components?

The major GWT components include:

GWT Java-to-JavaScript Compiler

Translates the Java programming language to the JavaScript programming language.

GWT Development Mode

Allows the developers to run and execute GWT applications in development mode (the app runs as Java in the JVM without compiling to JavaScript). Prior to 2.0, GWT hosted mode provided a special-purpose "hosted browser" to debug your GWT code. In 2.0, the web page being debugged is viewed within a regular browser. Development mode is supported through the use of a native-code plugin called the Google Web Toolkit Developer Plugin for many popular browsers.

JRE emulation library

JavaScript implementations of the commonly used classes in the Java standard class library (such as most of the java.lang package classes and a subset of the java.util package classes).

GWT Web UI class library

A set of custom interfaces and classes for creating widgets.


4⟩ Basic GWT questions

How does GWT app work? (compiling to JavaScript, cross-browser support, bootstrapping script, etc.)

When would you NOT use GWT? (rather general and open-ended question, but it demonstrates if developer is really into this technology) Follow-up question: What GWT alternatives would you consider?

What 3d party libraries have used with GWT? Which libraries would you recommend? Why?

Describe server-side development with GWT.

Did you use DI framework with GWT?

What does make MVP better fit for GWT than general MVC?

Serialization and Un-serialization. What is required of a user defined class for it to be serializable?

Event handling. Describe how an event bus is used and implemented.

Describe how one module can inherit or use members from another GWT module.


5⟩ What are the GWT Panels?

RootPanel is the top level panel.

For layout the page, we could use following layout panels, finally we need to add all those layout panels in RootPanel.





Use below panels inside the Layout panels for holding the widgets.


VerticalPanel ( Prefer using FlowPanel )


6⟩ What is Google Web Toolkit (GWT)?

The Google Web Toolkit (GWT) is a toolkit to develop Ajax web application with Java. The programmer writes Java code and this code is translated into HTML and Javascript via the GWT compiler.

The compiler creates browser specific HTML and JavaScript to support all the major browsers correctly. GWT supports a standard set of UI widgets, has build in support for the browser back button and a JUnit based test framework.

GWT provides two modes:

Development Mode: allows to debug the Java code of your application directly via the standard Java debugger.

Web mode: the application is translated into HTML and Javascript code and can be deployed to a webserver.


7⟩ How to create custom widgets in GWT?

Create a class that should extends Composite class of GWT.

Inside the constructor you can write you logic to create a widget and call the initWidget method().

Then you can use this class in anywhere in the application and add this widget in any panels.

private static class OptionalTextBox extends Composite implements

ClickHandler {

private TextBox textBox = new TextBox();

private CheckBox checkBox = new CheckBox();






8⟩ Explain GWT Features?

Dynamic and reusable UI components: programmers can use pre-designed classes to implement otherwise time-consuming dynamic behaviors, such as drag-and-drop or sophisticated visual tree structures.

Simple RPC mechanism

Browser history management

Support for full-featured Java debugging

GWT handles some cross-browser issues for the developer.

Unit testing integration

Support for Internationalization and localization

HTML Canvas support (subject to API changes)

The developers can mix handwritten JavaScript in the Java source code using the JavaScript Native Interface (JSNI).

Support for using Google APIs in GWT applications (initially, support for Google Gears)


The developers can design and develop their application in a pure object-oriented fashion, since they're using Java (instead of JavaScript). Common JavaScript errors, such as typos and type mismatches, are caught at compile time.

The JavaScript that the GWT compiler generates can be tailored to be either unobfuscated and easier to understand or obfuscated and smaller to download.

A number of libraries are available for GWT, by Google and third parties. These extend GWT's features.


9⟩ Explain Code of entry point with onModuleLoad where split out is working?

To split your code, simply insert calls to the method GWT.runAsync at the places where you want the program to be able to pause for downloading more code. These locations are called split points. For this you should use runAsync.

public class Hello implements EntryPoint {

public void onModuleLoad() {

Button b = new Button("Click me", new ClickHandler() {

public void onClick(ClickEvent event) {

GWT.runAsync(new RunAsyncCallback() {

public void onFailure(Throwable caught) {

Window.alert("Code download failed");


public void onSuccess() {

Window.alert("Hello, AJAX");









10⟩ How to set CSS style in GWT Java code?

The look and feel of a GWT application can be customized via CSS files. Each widget in GWT can be given a HTML "div" container and can therefore be individually styled by CSS. You use the Java method setStyle(String s) for this.


11⟩ Explain what is GWT ClientBundle?

In GWT we can use ClientBundle to load all the images and CSS files in one single file and use it anywhere in the application. It provides flexible way to get the resources.

1. It creates a single image from the collection of images at compile time to reduce the image size.

2. Enable more aggressive caching headers for program resources. It will go to server for every-time to get the images.

3.Eliminate mismatches between physical file names and constants in Java code by performing consistency checks during the compile.


12⟩ Tell me how to make GWT Custom Event Handler?

This is an event that is triggered when the user becomes happy.

Define a new event class. You can add arbitrary metadata in the event class. For simplicity, we will not include any here though.

public class HappyEvent extends GwtEvent {



Define a new handler and marker interface for the event class.

interface HappyHandler extends EventHandler {

public void onHappiness(HappyEvent event);


interface HasHappyEvents {

public HandlerRegistration addHappyHandler(HappyHandler handler);


Add a unique event type

class HappyEvent extends AbstractEvent{

public static AbstractEvent.Key KEY = new AbstractEvent.Key(){...}

public GwtEvent.Key getKey(){

return KEY;




Wire up the handler's fire method

class HappyEvent extends GwtEvent {

static Key KEY = new Key(){

protected void fire(HappyHandler handler, HappyEvent event) {






13⟩ How to run GWT application?

Two ways of running the application:

1) Create a war file and deploy in any app server or

2) Run ant hosted in the command prompt. And click on the ‘Launch Default Browser’.


14⟩ Explain what are Modules, Entry Points and HTML Pages in GWT?

GWT applications are described as modules. A module "modulename" is described by a configuration file "modulename.gwt.xml". Each module can define one or more Entry point classes.

An entry point is the starting point for a GWT application, similar to the main method in a standard Java program. A Java class which is an entry point must implement the interface "com.google.gwt.core.client.EntryPoint" which defines the method onModuleLoad().

The module is connected to a HTML page, which is called "host page". The code for a GWT web application executes within this HTML document.

The HTML page can define "div" containers to which the GWT application can assign UI components or the GWT UI components are simply assigned to the body tag of the HTML page.


15⟩ Tell me why to use GWT / what are the advantages to use GWT?

You're using Java - it means that your webdevs' proficiency in javascript won't come in handy as much (it will be helpful if you dabble in JSNI)

It's easy (especially for a beginner in GWT, especially when that person comes from a HTML/JS background - without too much object-oriented experience) to go all "wow, these 'object' things are so cool, let me make all my <div>s into separate objects, that will make the code all nice and neat". Of course, I'm over-exaggerating it, but you get the point - it's easy to imagine that an unexperienced programmer could put a full-blown Widget with lots of Handlers in every cell of a FlexTable... And then (s)he'll waste a lot of time wondering why the application feels sluggish ;) tl;dr: it's easy for beginners in GWT to make their applications "bloaty" by writing code in java.

The Compiler - now, most people talked with about GWT doesn't realize just how amazing this part of GWT is - for starters try this presentation from last year's Google IO. The compiler has the view of the whole application.

One nifty thing about GWT is that you get performance gains and new features for free with almost every new release of the framework. Since it's Java compiled to JavaScript.

Debugging - it is worth mentioning that you can (and should :)) debug your GWT apps just like any other Java application, using your IDE's debugger. And, in general, the Java debuggers I've seen are more advanced then their JavaScript counterparts.

UiBinder - while it's still not "perfect", UiBinder let's you design your Widgets in an easy and intuitive way using XML (as opposed to the pre-2.0 way that forced you to do this in Java). Mixing HTML and GWT's Widgets has never been so easy and fun.

Working with CSS - GWT has always, of course, embraced CSS, but with the introduction of GWT 2.0 (and UiBinder) they took it to another level. Let's look at a CSS file from a "normal" web application - hundreds, if not thousands of lines, hard to navigate, some styles are redundant but it's hard to notice that, some aren't used at all, add to this mix the need to please IE6/7 and you get yourself a nightmare. With GWT, you can instruct it to perform the similar tasks it did for the JS code for CSS - so it will prune all the unused CSS styles, merge where appropriate, minimize and obfuscate the class names, and many more (including conditionals, constants, etc in your CSS files). You are encouraged to keep your styles in their respective UiBinder's XML files - makes organizing and finding them so much easier. Last but not least, you get an error when you misspell a CSS style name - less hassle then trying to do the same via Firebug or a similar tool.

OOPHM - Out of Process Hosted Mode, with this, they fixed one of the biggest disadvantages of GWT - now, you get to use Hosted Mode in the browser of your choice (if that choice is Firefox, Safari, IE or Chrome, but at least you can use any version you want). The design of OOPHM also allows you to do cool stuff like run Windows in a VM, and connect from the IE there to the Hosted Mode running on the host OS (Linux/MacOS) - no need for hacks, copying files after every compile, etc.

The out-of-box collection of Widgets is kept small and simple. Now, if you're coming from some full-blown GUI framework (be it web or desktop), you might be surprised at how relatively small the number of Widgets GWT has. But according to the GWT's devs, it's kept like this on purpose - the basic Widgets are all the tools/"blocks" you need to build your own, customized to your needs Widgets.


19⟩ Explain how to create a GWT application?

•Create a folder for the application (e.g. withoutbook)

•Run webAppCreator in the newly created folder

–webAppCreator takes a module name (here 'withoutbook' is the module name with a package prefix)