GWT MVP with Activities and Places


public interface HelloView extents IsWidget {
    public interface Presenter {
         String getName();


Holds on to instances of views and other reusable resources.

public interface ClientFactory {
    EventBus getEventBus();
    HelloView getHelloView();


Similar to Presenter. Implements the Presenter interface defined in the view above.

public class HelloActivity extends AbstractActivity implements HelloView.Presenter {
    private String name;
    private ClientFactory clientFactory;

    //this is equivalent to the go method in the Presenter
    public void start(AcceptsOneWidget container, EventBus eventBus) {
         HelloView view = clientFactory.getHelloView();


Most Activities have an associated Place.

public class HelloPlace extends Place {
    private String name;
    public HelloPlace(String token) { = token }
    public String getName() { return; }

    public static class Tokenizer implements PlaceTokenizer<HelloPlace> {
         public String getToken(HelloPlace place) { ... }

         public HelloPlace getPlace(String token) { ... }


Link between PlaceTokenizers and GWT’s history mechanism.

@WithTokenizers({ HelloPlace.Tokenizer.class, ... })
public interface MyPlaceHistoryMapper extends PlaceHistoryMapper {}


How we map each Place to an Activity. Used to automatically route app to an Activity.

public class MyActivityMapper implements ActivityMapper {
    public Activity get Activity(Place place) {
         if (place instanceof HelloPlace) {
              return new HelloActivity();
         } else if (place instanceof ...) { }