javagwtgwt-places

How do GWT PlaceHistoryMapper tokens translate to actual URLs?


If I implement my own PlaceHistoryMapper:

public class MyAppPlaceHistoryMapper implements PlaceHistoryMapper {
    @Override
    public Place getPlace(String token) {
        if(token.equals("home"))
            return new HomePlace();
        else
            return new AboutUsPlace();
    }

    @Override
    public String getToken(Place place) {
        if(place instanceof HomePlace)
            return "home";
        else
            return "about-us";
    }}
}

And if my web app is rooted at http://www.myapp.com, then what are the actual (bookmarkable) URLs associated with HomePlace and AboutUsPlace? Are they:

Thanks in advance!


Solution

  • It's http://www.myapp.com/#home and http://www.myapp.com/#about-us.

    If you prefer, you can also have http://www.myapp.com/#HomePlace:home and http://www.myapp.com/#AboutUsPlace:about-us. To achieve that, you would use PlaceTokenizers and @WithTokenizers instead of implementing PlaceHistoryMapper yourself.

    Both approaches are good, it's your choice.