두 개의 다른 토큰 #m :과 #t를 동시에 표시 할 수 없습니다. 동시에 두 장소에있을 수 없습니다.
따라서 탭과 트리가 동시에 표시되는 경우 두 가지 상태를 같은 위치에 한 번에 저장해야합니다.
이것은 다소 다양합니다.
public class ExamplePlace extends Place {
public String treePosition = "/";
public int tabIndex = 0;
public ExamplePlace() {
super();
}
public ExamplePlace(String treePosition, int tabIndex) {
this.treePosition = treePosition;
this.tabIndex = tabIndex;
}
@Prefix("overview")
public static class Tokenizer implements PlaceTokenizer<ExamplePlace> {
/**
* parse token to get state
*
*/
@Override
public ExamplePlace getPlace(String token) {
String treePosition = "";
int tabIndex = 0;
String[] states = token.split(";");
for (String state : states) {
String[] mapping = state.split("=");
if (mapping.length == 2) {
if ("t".equals(mapping[0])) {
treePosition = mapping[1];
}
if ("m".equals(mapping[0])) {
try {
tabIndex = Integer.valueOf(mapping[1]);
} catch (Throwable e) {
}
}
}
}
return new ExamplePlace(treePosition, tabIndex);
}
/**
* store state in token
*
*/
@Override
public String getToken(ExamplePlace place) {
StringBuffer sb = new StringBuffer();
if (place.getTreePosition()!=null) {
sb.append("t").append("=").append(place.getTreePosition());
sb.append(";");
}
sb.append("m=").append(place.getTabIndex());
return sb.toString();
}
}
public String getTreePosition() {
return treePosition;
}
public void setTreePosition(String treePosition) {
this.treePosition = treePosition;
}
public int getTabIndex() {
return tabIndex;
}
public void setTabIndex(int tabIndex) {
this.tabIndex = tabIndex;
}
}
이렇게하면 URL이 표시됩니다.
있는 index.html # 개요 : t =/서브 트리/서브 트리/잎, 전방 토큰에, 확실하지 슬래시와 m은 = 2
당신은 문제가 실행될 수 있습니다. 필요한 경우 다른 문자로 변경하십시오.
활동은 들어오는 장소를 받고보기에 상태를 주입합니다.
흠, 이것이 유일한 해결책이 될 것을 두려워합니다! GWT- "Activities/Places"를 발견하기 전에 필자는 우연히 비슷한 접근법을 구현합니다 (그러나 여러 "장소"와 함께). 뭐든간에. 이제 나는 문서에서 뭔가를 놓치지 않았다는 것을 안다! 감사. –
중요한 것은 한 번에 여러 장소에있을 수 없으며 개인적인 활동에 의해 관리되는 여러 표시 영역에서만 사용할 수 있다는 것입니다. 그 장소는 활성화 된 활동을 결정합니다. – koma