0

I am using Activities and Places.

I have a LoginPlace.

The url displayed when I navigate to that place has this at the end:

#LoginPlace:login

How can I change this to just #login or something else?

My tokenizer looks like this:

public class LoginTokenizer implements PlaceTokenizer<LoginPlace> {

    private LoginPlace loginPlace;

    public LoginTokenizer() {
    }

    @Override
    public LoginPlace getPlace(String token) {
        return new LoginPlace(token);
    }

    @Override
    public String getToken(LoginPlace place) {
        loginPlace = place;
        return loginPlace.getLoginToken();
    }
}

And navigation to the LoginPlace is done through the PlaceController:

clientFactory.getPlaceController().goTo(new LoginPlace("login"));

Where can I manipulate the format of the URL?

user3629892
  • 2,960
  • 9
  • 33
  • 64

2 Answers2

1

The mapping is done by the PlaceHistoryMapper.

You can have an implementation generated by GWT based in PlaceTokenizers, but then it's based on a prefix/suffix. The @Prefix allows you configure the prefix (which otherwise defaults to the place class' name).

Or you can implement the interface yourself and have complete control over the process.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
0
  1. Rename the Place class from LoginPlace to Login.

  2. Pass an empty token:

    new LoginPlace("")
    
Andrei Volgin
  • 40,755
  • 6
  • 49
  • 58
  • Hey! It's weird that I would have to change the name of my class. Are you sure this is the only way? – user3629892 Feb 25 '16 at 15:17
  • As Thomas noted you can use a @Prefix annotation, but changing the class name is the simplest way to do it. I prefer this option because it is easier to maintain and understand, especially in large apps with many different places. – Andrei Volgin Feb 25 '16 at 23:23