For the past eight(8) years Schalk Neethling has been working as a freelance developer under the pseudo of Volume4 and is now the president of Overt Strategy Consulting. During this period he has completed over 300 projects ranging from full web application development to complete branding. As president and lead developer of Overt Strategy Consulting, Schalk Neethling and his team has released a 100% Java standards based content management system called AlliedBridge and business document exchange and review system, called Doc-Central. Schalk Neethling is also actively involved on a daily basis in the open source, web standards and accessibility areas and is a current active member of the Web Standards Group. Schalk is also the co-founder and president of the non-profit The South Web Standards and Accessibility Group, which aims to actively educate and raise awareness of web standards and accessibility to both the developer society as well as business large and small. Schalk also has a long relationship with DZone and is currently zone leader for both the web builder, css.dzone.com, as well as the .NET zone, dotnet.dzone.com, and you can find a lot of his writing there as well as on his blog located at schalkneethling.alliedbridge.com. Schalk is constantly expanding on his knowledge of various aspects of technology and loves to stay in touch with the latest happenings. For Schalk web development and the internet is not just a job, it is a love, a passion and a life style. Schalk has posted 173 posts at DZone. View Full User Profile

The Great GWT Roundup

09.26.2008
| 21726 views |
  • submit to reddit

Over the past two months or so we here at the web builder zone, thanks to Manning Publishing, have been publishing a comprehensive series on GWT. We recently published the last in the series and I thought that it would be a good idea to create a sort of index of all of these articles.

So if you missed the series, missed an article or want to explore the series again this is your chance. Below is a summary of each article posted with a direct link to the complete article.

Working With The GWT Shell

The GWT shell is one of the most important components GWT provides, and one you’ll use every day when developing GWT applications.The shell is composed of three main parts: a logging console, an embedded Tomcat server, and the hosted mode browser. The GWT shell console provides an enhanced logging interface and centralized GUI as a GWT dashboard. The hosted mode browser is capable of invoking your Java classes directly on browser events, rather than requiring a compilation to JavaScript; thus you can use a standard Java debugger to work with your Ajax code, instead of relying solely on compiled JavaScript for testing and interaction. The development server, Tomcat Lite, facilitates local development and testing of server-based resources.

GWT Basic Project Structure And Components

The core of every GWT project is the project layout and the basic components required—host pages, entry points, and modules. To begin a GWT project, you need to create the default layout and generate the initial files. The easiest way to do this is to use the provided ApplicationCreator tool.

Design patterns and GWT

We have a calculator EntryPoint implementation that places a CalculatorWidget on the RootPanel, so we now need to provide this widget. This will be our own widget, composed of basic GWT components. CalculatorWidget will contain the view for our calculator application, a simple data and logic layer as the model, and an intermediary controller between these layers. This, of course, means we'll be using MVC and GWT together - keep in mind that all of these components will end up distributed to the client.

GWT: Running a completed project

Let's put GWTShell and GWTCompiler to use with a calculator example, CalculatorWidget. First, we'll use GWTShell to get the lay of the land and launch the hosted mode browser. This is how you typically run and debug a project while in hosted mode during development. Then we'll move on to compiling things with GWTCompiler, which is what is normally used as part of a build process to turn your Java into JavaScript and create a deployable artifact for web mode.

Making GWT Remote Procedure Calls

GWT enables client applications to communicate with server resources through its own RPC and object-serialization mechanism. This communication process involves each side of the conversation implementing a very straightforward GWT service interface and sending/receiving special GWT serialized data. The server side exposes resources, and the client side invokes those resources asynchronously.

GWT: The Development Server - Tomcat Lite

The GWT shell uses a stripped down and somewhat customized version of the Apache Tomcat servlet container as its development mode server. While this is a Tomcat instance, GWT sets things up differently to automate certain elements and facilitate quick and easy development mode use and testing.

GWT's deployment of applications to the local Tomcat can be somewhat confusing. Saying that GWT uses Tomcat is much like saying that your favorite driver drives a Camaro in NASCAR races. It might look like a Camaro, people might even call it a Camaro, but driving it's not like driving the Camaro your local GM dealer will sell you. GWT's Tomcat has a custom deployment descriptor, web.xml, which includes the configuration for the special GWTShellServlet. This servlet is used in hosted mode only to automatically dispatch servlet entries from your module file into the appropriate classes.

GWT: Using An External Development Server

GWTShell includes the -noserver command-line option, which instructs the toolkit not to start or use the embedded Tomcat instance. If you use -noserver, you're essentially telling GWT that you'll handle the server-side resources on your own, like a baseball player in the outfield calling a fly ball - "I got this one."

GWT: Building A Model

The model layer of a GWT application has to be a little bit smarter than the model in many traditional web applications. It needs to be responsible for notifying the view layer of changes, as well as for receiving updates to its own structure. In desktop Java development, this is accomplished through the use of PropertyChangeEvents and PropertyChangeListeners that bind the data from the model to the view components. The view layer "listens" for changes to the model and updates itself accordingly, using the Observer pattern. This can be done in GWT development as well. Figure 1 shows a basic User class that we will work with.

Published at DZone with permission of its author, Schalk Neethling.

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)