To close this thread, the solution is to rest the history token by adding
the following line:

private void displayLogin() {
...
// reset the current token
History.newItem("login", false);
}


Thanks Ian and Paul!


On Sun, Jun 21, 2009 at 2:56 AM, Paul Robinson <[email protected]> wrote:

>
> The first time you press the hyperlink to "logout", there's a new
> history item added of that name. The second time you press it, the
> current history token is still "logout", so it does nothing.
>
>
> hezjing wrote:
> > Hi
> >
> > I have the following code which suppose to do the following:
> >
> > 1) when the login button is clicked, it will clear the RootPanel and
> > show a logout hyperlink,
> >
> > 2) when the logout hyperlink is selected, it will clear the RootPanel
> > and show the login button again.
> >
> >
> > public class Dummy implements EntryPoint, ValueChangeHandler<String> {
> >
> > public void onModuleLoad() {
> > History.addValueChangeHandler(this);
> > displayLogin();
> > }
> >
> > private void displayLogin() {
> > Button ok = new Button("Login");
> > ok.addClickHandler(new ClickHandler() {
> > public void onClick(ClickEvent event) {
> > displayContent();
> > }
> > });
> > RootPanel root = RootPanel.get();
> > root.clear();
> > root.add(ok);
> > }
> >
> > private void displayContent() {
> > Hyperlink logout = new Hyperlink("Logout", "logout");
> > RootPanel root = RootPanel.get();
> > root.clear();
> > root.add(logout);
> > }
> >
> > public void onValueChange(ValueChangeEvent<String> event) {
> > if (event.getValue().equals("logout")) {
> > displayLogin();
> > }
> > }
> > }
> >
> >
> > The problem is when tested in hosted mode, the hyperlink stops
> > responding after the 1st time:
> >
> > 1) Login button is clicked, show logout hyperlink
> >
> > 2) Logout hyperlink is selected, show login button
> >
> > 3) Login button is clicked, show logout hyperlink
> >
> > 4) Logout hyperlink is selected, and NOTHING happen here!
> >
> >
> > Do you have any idea of what could be the problem?
> >
> >
> > --
> >
> > Hez
> >
> > >
>
> >
>


-- 

Hez

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to