我使用了一个名为PlaceHistoryMapperWithoutColon的PlaceHistoryMapper装饰器。
用法:
final PlaceHistoryMapper historyMapper0 = GWT
.create(PlaceHistoryMapperImpl.class);
final PlaceHistoryMapper historyMapper = new PlaceHistoryMapperWithoutColon(historyMapper0);
装饰源:
public class PlaceHistoryMapperWithoutColon implements PlaceHistoryMapper {
private static final String COLON = ":";
private PlaceHistoryMapper placeHistoryMapper;
public PlaceHistoryMapperWithoutColon(PlaceHistoryMapper placeHistoryMapper) {
this.placeHistoryMapper = placeHistoryMapper;
}
@Override
public Place getPlace(String token) {
if (token != null && !token.endsWith(COLON)) {
token = token.concat(COLON);
}
return placeHistoryMapper.getPlace(token);
}
@Override
public String getToken(Place place) {
String token = placeHistoryMapper.getToken(place);
if (token != null && token.endsWith(COLON)) {
token = token.substring(0, token.length() - 1);
}
return token;
}
}
装饰源例如:
@WithTokenizers({ FirstPlace.Tokenizer.class, SecondPlace.Tokenizer.class })
public interface PlaceHistoryMapperImpl extends PlaceHistoryMapper {
}
地点源例如:
public final class FirstPlace extends Place {
@Prefix("first")
public static class Tokenizer implements PlaceTokenizer<FirstPlace> {
@Override
public NetworkInfosPlace getPlace(String token) {
return new FirstPlace();
}
@Override
public String getToken(FirstPlace place) {
return "";
}
}
}
这是来自doc:'你的应用中的许多地方可能不会保存任何状态到URL,所以他们可以扩展一个BasicPlace,它声明一个返回null标记的PlaceTokenizer'你是否尝试创建PlaceTokenizer,你的添加人形式的空令牌? – Strelok
感谢您的回复。如果我从getToken(PlaceName地方)返回null,那么我最终会得到如下的URL:“#addPersonForm:null”。我错过了什么(可能:)? – Justin