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. 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
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.
- Select Help>Install from Catalog, type Google Eclipse Plugins in the Find field, and click Go.
- Click Install button beside the plugin for your Eclipse version. (For MyEclipse 2015, install Google Plugin for Eclipse.
- Accept the license agreement and complete the wizard.
2. Create a Web ProjectCreate 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.
Before generating the GWT application, the project requires some basic GWT setup using some of the tools provided by the Google Eclipse Plugin.
- Right-click CustomersGwtApp, and select Google>Web Toolkit Settings.
- In the Google>Web Toolkit properties, select the Use Google Web Toolkit checkbox.
- 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.
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.
- Right-click CustomersGwtApp, and select Google>GWT Compile.
- Accept the default settings, and click Compile.
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.
- Right-click CustomersGwtApp, and select Run As>MyEclipse Server Application. Select the MyEclipse Tomcat server.
MyEclipse 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.
- 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/.
The GWT application can be used to perform create, read, update, and delete functions on customers. The following image shows some of the views.
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.