2 Getting Started - Reference Documentation
Authors: Peter Ledbrook, David Dawson, Rob Purcell, Predrag Knežević
Version: 1.0.3
2 Getting Started
How to use it
When starting with GWT, the first thing you need to do is create a module. This packages a bunch of client-side code into a single unit.Creating a module
grails create-gwt-module <module>
grails create-gwt-module org.example.MyApp
- src/gwt/org/example/MyApp.gwt.xml , and
- src/gwt/org/example/client/MyApp.java .
Creating a host page
Once you have a module, you need to create an HTML page that will host the user interface elements defined by it. Again, this is as simple as running another Grails command:grails create-gwt-page <page> <module>
// This will create the view file: grails-app/views/main/index.gsp grails create-gwt-page main/index.gsp org.example.MyApp // This will create the file: web-app/dir/main.html grails create-gwt-page dir/main.html MyModule// This will create the file: web-app/index.gsp grails create-gwt-page index.gsp org.example.AnotherModule
Trying it out
GWT has something called hosted mode that allows you to test and debug your web interface from a custom browser. This is also available from the plugin. Just run this command:grails run-gwt-client
grails run-gwt-client -debug
Starting the GWT hosted mode client. …
[java] Listening for transport dt_socket at address: 5006
(Run->Debug Configurations...-> Select Remote Java Application in left tree view-> click New icon top-left) Under Connect tab-> Project:Browse->select your project Connection Type: Standard (Socket Attach) Connection Properties: Host: localhost (or remote host) Port: 5006 (default, but whatever GWT Dev Mode is listening for) Name: <whatever you want> I usually name it "<project> <command>" Click Apply (or Debug if you're ready)