簡體   English   中英

GWT-歷史優先令牌出現問題

[英]GWT - Trouble with History first token

我有這個問題:當我調用Content類(由於#param而決定查看哪個頁面的類)時,我會執行以下操作:

History.addValueChangeHandler(this);
if(!History.getToken().isEmpty()){
    changePage(History.getToken());
} else {
    History.newItem("homepage");
}

因此,現在,如果我查看瀏覽器的導航欄,則會看到http://localhost:8084/GWT/?gwt.codesvr=127.0.0.1:9997#homepage 沒錯。 不幸的是,如果我在瀏覽器上按Back ,則會看到它加載了以前的地址,例如http://localhost:8084/GWT/?gwt.codesvr=127.0.0.1:9997

一開始我有一個“假”頁面。

1-我該如何解決? 然后使用默認令牌啟動應用程序,或將其從歷史記錄中刪除。 或者,當令牌為空時,只需調用onValueChange方法,然后在確定工作流后再使用某種switch / if-else方法。

2-作為相關問題,當我調用History.addValueChangeHandler(this); 在構造函數類中,netbeans說“在構造函數中泄漏”。 這是什么意思?

干杯

也許您忘了添加History.fireCurrentHistoryState(); onModuleLoad()方法的結尾?

您需要設置歷史記錄令牌,並使用當前令牌觸發歷史記錄更改事件。 這是您如何做到的:

/ If the application starts with no history token, redirect to a new
// 'homepage' state.
String initToken = History.getToken();
if (initToken.length() == 0) {
  History.newItem("homepage");
}

// Add widgets etc


// Add history listener
History.addHistoryListener(yourHistoryHandler);

// Fire the initial history state.
History.fireCurrentHistoryState();

恕我直言,以“ proto:// hostname#homepage”形式出現的首頁網址很丑陋:)

1.只是一個建議:

String token = History.getToken();
String page = token.isEmpty() ? "homepage" : token;
changePage(page);

2.您的EntryPoint是否實現ValueChangeHandler<String>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM