Community contributed extensions

Play-GWT2 Module

This module is based on the GWT Plugin by Rustem Suniev.

It provides some classes and command to simplify the integration of a GWT2 Module in a play application.

h2. Installation

1. This module does not includes GWT SDK. You will need to download it. ( version 2.0.x )

2. Create a new Play! application or use an existing one.

2. Set GWT_PATH environment variable.

3. Install GWT2 module. > play install gwt2

4. Edit the conf/application.conf file to enable the GWT2 module :

# Additional modules
# ~~~~~
# A module is another play! application. Add a line for each module you want
# to add to your application. Modules path are either absolutes or relative to
# the application root.
#
module.gwt2=${play.path}/modules/gwt2
h2. Initialize you Application bc. play gwt2:init myApp

this will create some folder
- /app/gwt (directory for gwt modules)
- /gwt-public (directory for GWT compiled resources)

p. copy gwt-user.jar to /lib

Create a GWT Module create your module like this:

play gwt2:create myApp

this will ask you a gwt module name

What is the gwt module name ?

enter for eg: firstmodule

this action create some files
/app/gwt/firstmodule
/app/gwt/firstmodule/Firstmodule.gwt.xml (module)
/app/gwt/firstmodule/public
/app/gwt/firstmodule/public/index.html (default page for entry point)
/app/gwt/firstmodule/client
/app/gwt/firstmodule/client/Firstmodule.java (entry point)
/app/gwt/firstmodule/client/GreetingService.java
/app/gwt/firstmodule/client/GreetingServiceAsync.java
/app/gwt/firstmodule/shared
/app/gwt/firstmodule/shared/FieldVerifier.java
/app/gwt/firstmodule/server
/app/gwt/firstmodule/server/GreetingServiceImpl.java

GreetingService Interface must use annotation @RemoteServiceRelativePath(“greet”)

GreetingServiceImpl.java must implements GWTService and us @GWTServicePath(“/firstmodule/greet”) annotation

Testing you GWT Module with dev mode

First start you Play application.

play run myApp

Then start the dev mode,

play gwt2:devmode myApp

GWT will compile your modules at first time.

Now you access your gwt module this url /app/firstmodule/index.html

Compiling a module

To compile a module (eg: before deployment)

play gwt2:compile myApp

this will ask you a gwt module name

What is the gwt module name ? 

Enter a name, then GWT will compile your module.

Remove a GWT Module

As for creating a new GWT Module but use gwt2:remove

play gwt2:remove myApp

this will ask you a gwt module name

What is the gwt module name ?

all directory of your module will be deleted:
- /app/gwt/firstmodule/**
- /gwt-public/firstmodule/**

Debugging the GWT UI

1. The easiest way it to eclipsify, netbeansify, ... you application and then use you prefered IDE to use JPDA. By default GWT listen on port 3408.

Creating a service using GWT-RPC

this part is the same as the Play-GWT by Rustem Suniev.

If you follow the GWT manual, it will explain you how to expose a service with GWT-RPC using a RemoteServiceServlet.

Exposing a GWT service with Play is almost the same, but since you can’t define servlets in a Play application, you have to use the provided support class, play.modules.gwt.GWTService

For example, to implement this service:


package gwt.mymod.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
@RemoteServiceRelativePath("hello")
public interface HelloService extends RemoteService {
    String sayHello(String name);
}

simply create a class that extends the play.modules.gwt.GWTService, and define the service URL path with the play.modules.gwt.GWTServicePath annotation. Like this:


package services;
import play.modules.gwt2.GWTService;
import play.modules.gwt2.GWTServicePath;
import gwt.mymod.client.HelloService;
@GWTServicePath("/main/hello")
public class HelloServiceImpl extends GWTService implements HelloService {
    public String sayHello(String name) {
        return "Hello " + name;
    }
}

This is the only difference from the GWT documentation.