This tutorial will guide you on how to prepare a development
environment to start your work with GWT Framework. This tutorial will
also teach you how to setup JDK, Tomcat and Eclipse on your machine
before you setup GWT Framework:
Before we start with creating actual HelloWorld application
using GWT, let us see what are the actual parts of a GWT application. A
GWT application consists of following four important parts out of which
last part is optional but first three parts are mandatory:
As power of GWT lies in Write in Java, Run in JavaScript, we'll be using Java IDE Eclipse to demonstrate our examples. Let's start with a simple HelloWorld application:
This tutorial will explain you how to create an application war
file and how to deploy that in Apache Tomcat Websever root. If you
understood this simple example then you will also be able to deploy a
complex GWT application following the same steps.
GWT widgets rely on cascading style sheets (CSS) for visual styling. By default, the class name for each component is gwt-<classname>. For example, the Button widget has a default style of gwt-Button and similar way TextBox widgest has a default style of gwt-TextBox. In order to give all buttons and text boxes a larger font, you could put the following rule in your application's CSS file:
Every user interface considers the following three main aspects:
UI elements : Thes are the core visual elements the user
eventually sees and interacts with. GWT provides a huge list of widely
used and common elements varying from basic to complex which we will
cover in this tutorial.
Form widgets allows users to input data and provides them interaction
capability with the application. Every Form widget inherits properties
from Widget class which in turn inherits properties from UIObject and
Wigdet classes.
Complex widgets allows users to advanced interaction capability with
the application. Every Complex widget inherits properties from Widget
class which in turn inherits properties from UIObject.
Layout Panels can contain other widgets. These panels controls the
way widgets to be shown on User Interface. Every Panel widget inherits
properties from Panel class which in turn inherits properties from
Widget class and which in turn inherits properties from UIObject class.
GWT provides a event handler model similar to Java AWT or SWING User Interface frameworks.
A listener interface defines one or more methods that the widget
calls to announce an event. GWT provides a list of interfaces
corresponding to various possible events.
GWT provides three ways to create custom user interface elements. There are three general strategies to follow:
Create a widget by extending Composite Class: This is the
most common and easiest way to create custom widgets. Here you can use
existing widgets to create composite view with custom properties.
A GWT based application is generally consists of a client side module
and server side module. Client side code runs in browser and server
side code runs in web server. Client side code has to make an HTTP
request accross the network to access server side data.
GWT provides execellent support for automated testing of client side
code using JUnit testing framework. In this article we'll demonstrate
GWT and JUNIT integration.
GWT provides three ways to internationalize a GWT application, We'll
demonstrate use of Static String Internationalization being most
commonly used among projects.
GWT applications are normally single page application running
JavaScripts and do not contains lot of pages thus browser do not keep
track of user interaction with Application.
To use browser's history functionality, application should generate a
unique URL fragment for each navigable page.
GWT supports browser history management using a History class for which you can reference GWT - History Class chapter.
GWT uses a term token which is simply a string that the
application can parse to return to a particular state. Application will
save this token in browser's history as URL fragment.
The logging framework emulates java.util.logging, so it uses the same
syntax and has the same behavior as server side logging code
GWT logging is configured using .gwt.xml files.