Search code examples
gwthistorygwt-history

GWT - Trouble with History first token


I have this problem : when i call the Content class (the one who decide which page to view, due to the #param) I do somethings like this :

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

So, now, if i look at browser's navigation bar, i see http://localhost:8084/GWT/?gwt.codesvr=127.0.0.1:9997#homepage. And that's right. Unfortunatly, If i press Back on my browser, i see that it load the previous address, such as http://localhost:8084/GWT/?gwt.codesvr=127.0.0.1:9997

I have a sort of "fake" page at the beginning.

1 - How can I fix it? And start the application with a default token, or remove it in the history. Or just call the onValueChange method when there is empty token, and after decide the workflow with a sort of switch/if-else.

2 - As related question, when i call History.addValueChangeHandler(this); in the costructor class, netbeans say "Leaking this in constructor". What it means?

Cheers


Solution

  • IMHO, home url in form of "proto://hostname#homepage" is ugly :)

    1. Just a suggestion:

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

    2. Does Your EntryPoint implement ValueChangeHandler<String>?