【发布时间】:2011-10-19 00:11:11
【问题描述】:
您好,我正在开发一个 GWT 示例历史管理应用程序。 这是我的 onModuleLoad 代码。
public void onModuleLoad() {
ContentPanel panel = ContentPanel.getInstance();
if(History.getToken()!=null && History.getToken().length()==0)
{
History.newItem("first_page");
}
History.addValueChangeHandler(new HistoryHandler());
RootPanel.get().add(panel);
History.fireCurrentHistoryState();
}
在这我解雇了 History.fireCurrentHistoryState();触发当前的历史状态。 现在在我的 firstPanel 类中,有一个名为 Second Panel 的按钮,在该按钮上触发了历史令牌 second_page。
public FirstPanel() {
VerticalPanel panel = new VerticalPanel();
Button button2 = new Button("Second Panel");
button2.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
History.newItem("second_page");
}
});
panel.add(button2);
initWidget(panel);
}
但是这里不需要触发 History.fireCurrentHistoryState() ;再次。 简单的 histtory.newItem 工作正常。
现在我想知道 History.fireCurrentHistoryState() 仅在模块加载时需要什么? 还有为什么在应用程序中第二次不需要它。?
【问题讨论】:
标签: gwt gwt-history