Scaffolding GWT 2.1 and Spring

This tutorial walks you through producing a ready-to-run Google Web Toolkit (GWT) 2.1 and Spring application that implements the CRUD application pattern for a domain model. Spring scaffolding with GWT requires a MyEclipse Spring or Bling subscription. In this tutorial, you will learn how to:

  • Install Google Eclipse Plugins
  • Configure a project for GWT
  • Scaffold from a database table into an existing project
  • Compile GWT
  • Deploy the application

Duration Time: 20-30 Minutes

Start Tutorial Now

Don't have MyEclipse? Download Now


1. Install Google Eclipse Plugins

If you're going to do GWT development in MyEclipse (or Eclipse),  you need the Google Eclipse Plugins (GEP). GEP includes the GWT SDK and some tools for GWT development. Among other things, GEP compiles the GWT application generated by MyEclipse. GEP is available in the Marketplace catalog and is easily added to your installation.

  1. Select Help>Install from Catalog, type Google Eclipse Plugins in the Find field, and click Go.

    GEP in the catalog
  2. Click Install button beside the plugin for your Eclipse version. (For MyEclipse 2015, install Google Plugin for Eclipse 4.4.)
  3. Accept the license agreement and complete the wizard.


2. Create a Web Project

Create a MyEclipse Web project called CustomersGwtApp, and on the Web Module page, select the Generate web.xml deployment descriptor checkbox.

Note: If you get a popup regarding the project compiler  compliance level not matching the workspace default, specify that you want to use a custom setting for the project by clicking Yes.

 

New web project


3. Configure the Web project for GWT

Before generating the GWT application, the project requires  some basic GWT setup using some of the tools provided by the Google  Eclipse Plugin.

  1. Right-click CustomersGwtApp, and select Google>Web Toolkit Settings.

    Configuring for GWT
  2. In the Google>Web Toolkit properties, select the Use Google Web Toolkit checkbox.

    Indicating use of Web Toolkit
  3. Select Google>Web Application in the navigation, and select the checkboxes indicated in the image below to specify that the current project has a WAR directory.

    Specifying the WAR directory


4. Scaffold from Database Tables

Scaffolding with GWT requires the same steps as scaffolding with Spring MVC. Follow the steps in Scaffolding a Spring MVC Application with the following exceptions:

Select the Generate checkbox for GWT on the Select Web Client Type wizard page.

Selecting the GWT web client

Select the GWT 2.1 recipe, which encompasses the latest GWT technology and best practices from the Google GWT team.


GWT options


5. GWT Compile

The GWT code generated by MyEclipse needs to be  compiled into JavaScript using the GWT SDK.

  1. Right-click CustomersGwtApp, and select Google>GWT Compile.

    GWT compiler
  2. Accept the default settings, and click Compile.

    GWT compiler

The compile takes approximately one minute to complete. You can monitor the progress using the Console view. When the compile is complete, a "Compilation succeeded " message appears in the console.


6. Deploy the App

  1. Right-click CustomersGwtApp, and select Run As>MyEclipse Server Application. Select the MyEclipse Tomcat server.

    Deploying the applicationMyEclipse Tomcat starts. The first page is a dashboard for accessing all scaffolded web clients. Because this tutorial only scaffolded a single parent object for GWT, the only option under Google Web Toolkit is View GWT Scaffolding.
  2. Click the View GWT Scaffolding button to see the generated application in operation. If you want to run the GWT application in a separate browser, use the following URL: http://localhost:8080/CustomersGwtApp/.

    Dashboard

The GWT application can be used to perform create, read, update, and delete functions on customers. The  following image shows some of the views.

Customer app list
Customer app edit details


7. What's Generated?

To ease your way into code generation, this tutorial involved scaffolding from only a single database table. Therefore, only the software components for managing a single entity were generated, and there were no entity relationships. When you start generating for multiple entities, potentially with entity relationships, there are many more software components generated than were generated with this tutorial. Even though there's a lot more code, it is grouped and organized as shown in the following  image.

Generated scaffolding