Hi, I am running into this weird issue where the onHistoryChanged() isn't being called when I hit the browser's back button or even if I call History.back(). I am testing this in the hosted mode (even running it in firefox yields me the same result). The strange thing is, if I call History.back() thrice - looks like it calls onHistoryChanged() on the third request - it is quite confusing and I was hoping if someone could shed some light on this issue that I am running into.
I am using GWT 1.5 and to demonstrate my case, I'll use the example in the GWT-1.5 tutorial (http://preview.tinyurl.com/6grjh2) // Excluding imports for brevity // Entry point classes define <code>onModuleLoad()</code>. public class BrowserHistoryExample implements EntryPoint { TabPanel tabPanel; public void onModuleLoad() { tabPanel = new TabPanel(); int tabIndex = 0; // A Ext-GWT ContentPanel (com.extjs.gxt.ui.client.widget.ContentPanel) ContentPanel cp = new ContentPanel(); cp.addText("Page1"); tabPanel.add(cp, "Page1"); cp = new ContentPanel(); cp.addText("Page2"); tabPanel.add(cp, "Page2"); Button backButton = new Button("Back"); backButton.addClickListener(new ClickListener () { public void onClick(Widget arg0) { System.out.println("Going back now ..."); History.back(); // Commenting this for now ... // but on un-commenting, the third call to History.back() seems to invoke onHistoryChanged() // History.back(); // History.back(); } }); cp = new ContentPanel(); cp.addText("Page3"); cp.add(backButton); tabPanel.add(cp, "Page3"); tabPanel.addTabListener(new TabListener() { public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) { return true; } public void onTabSelected(SourcesTabEvents sender, int tabIndex) { // Push an item onto the history stack System.out.println("Pushing tabIndex: " + tabIndex + " on the stack"); History.newItem("page" + tabIndex); } }); History.addHistoryListener(new HistoryListener() { public void onHistoryChanged(String historyToken) { System.out.println("Got token: " + historyToken); // Parse the history token try { if (historyToken.substring(0, 4).equals("page")) { String tabIndexToken = historyToken.substring(4, 5); int tabIndex = Integer.parseInt(tabIndexToken); // Select the specified tab panel tabPanel.selectTab(tabIndex); } else { tabPanel.selectTab(0); } } catch (IndexOutOfBoundsException e) { tabPanel.selectTab(0); } } }); tabPanel.selectTab(0); RootPanel.get().add(tabPanel); } } So the thing is, when I navigate from Page1 tab to Page2 tab to Page3 tab - and then when I hit the "back" button (defined above, which simply calls History.back()) - nothing really happens for the first 2 times I hit the button. Only when I hit it the third time (or alternatively call History.back() thrice in the buttonClick event) - is the onHistoryChanged() method invoked. Again, it would be great if someone could help me figure out whats going on? Thanks! -- 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.
