Frage

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:

  • http://www.myapp.com/home and http://www.myapp.com/about-us; or
  • http://www.myapp.com/HomePlace:home and http://www.myapp.com/AboutUsPlace:about-us; or
  • something else?

Thanks in advance!

War es hilfreich?

Lösung

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.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top