こんにちは私は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_pageが起動されるSecondPanelという名前のボタンがあります。
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()が必要なことを知りたいですか?また、なぜそれがアプリケーションで2回目に必要とされないのですか?