user3629892
user3629892

Reputation: 3046

GWT tokenizer: How to change URL

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?

Upvotes: 0

Views: 273

Answers (2)

Thomas Broyer
Thomas Broyer

Reputation: 64541

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.

Upvotes: 1

Andrei Volgin
Andrei Volgin

Reputation: 41089

  1. Rename the Place class from LoginPlace to Login.

  2. Pass an empty token:

    new LoginPlace("")
    

Upvotes: 0

Related Questions