Thanks for the advise. I did try some variations of the your
suggestions. But I still get the App reload if the History.newitem()
is called anywhere (with or without the boolean flag). One point I did
not make clear: I am using the Anchor class to navigate (for example):
//this triggers reload any I click on it. It does navigate momentarily
to the login page and then reloads.
private static Anchor ancLogin = new Anchor("Login","#Login#");
//this triggers reload once upon the anchor's click event and then
behaves as expected. Thus I need to click on the login anchor twice to
get to the login page.
private static Anchor ancLogin = new Anchor("Login","?
page=Login#Login#");
This behavior is found on the gwt hosted mode (port 8080) and also on
IE. I did not try with FireFox yet.
Below is the class responsible for building the anchors:
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Anchor;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.RootPanel;
public class TopLinks implements ClickHandler {
private static CerradoConstants constants = null;
//top links
private static Anchor ancHome = new Anchor("Home","#index#");
private static Anchor ancAbout = new Anchor("About
Us","#aboutUs#");
//private static Anchor ancBoom = new Anchor("The Brazilian
Boom","?page=boom#boom#");
private static Anchor ancBoom = new Anchor("The Brazilian
Boom","#boom#");
private static Anchor ancHowStarted = new Anchor("How It All
Started","#howStarted#");
//user stuff
private static Anchor ancAccount = new Anchor("Create
Account","#Account#");
//this is the key to make history work
private static Anchor ancLogin = new Anchor("Login","?
page=Login#Login#");
private static Anchor ancLogout = new Anchor
("Logout","#Logout#");
private Controller controller = null;
public TopLinks(Controller controller, CerradoConstants
constants){
this.constants = constants;
this.controller = controller;
ancHome.addClickHandler(this);
ancAbout.addClickHandler(this);
ancBoom.addClickHandler(this);
ancHowStarted.addClickHandler(this);
ancAccount.addClickHandler(this);
ancLogin.addClickHandler(this);
ancLogout.addClickHandler(this);
ancHome.setStyleName("gwt-Top-Anchor");
ancAbout.setStyleName("gwt-Top-
Anchor");
ancBoom.setStyleName("gwt-Top-Anchor");
ancHowStarted.setStyleName("gwt-Top-Anchor");
ancAccount.setStyleName("gwt-Top-Anchor");
ancLogout.setStyleName("gwt-Top-Anchor");
ancLogin.setStyleName("gwt-Top-Anchor");
}
public void show(){
RootPanel.get("links").clear();
RootPanel.get("links").add(ancHome);
RootPanel.get("links").add(ancAbout);
RootPanel.get("links").add(ancBoom);
RootPanel.get("links").add(ancHowStarted);
setLoginAnchor(false);
}
private void setLoginAnchor(boolean startUp){
if (controller.getData().getUser() == null){
RootPanel.get("links").add(ancAccount);
RootPanel.get("links").add(ancLogin);
}else{
Window.alert(controller.getData().getUser
().getLastName());
RootPanel.get("links").add(ancLogout);
}
}
public void onClick(ClickEvent event) {
String action =Window.Location.getParameter("page");
String link = event.getSource().toString();
String url = link.substring(link.indexOf("#")+1);
url = url.substring(0, url.lastIndexOf("#"));
Window.alert("topLink: action= "+action);
Cerrado.getInstance().setPage(url, constants);
}
}
--------------------------------------------------------------------------------
On Dec 28, 10:43 am, Trevis <[email protected]> wrote:
> I'm glad you asked this question! I've just assumed that you had to
> fire the change event when adding to the history stack with addItem.
>
> I guess you probably saw it but your answer is simply use the two
> argument version and pass in "false" for the issueEvent argument.
>
> On Dec 23, 11:32 pm,compuroad<[email protected]> wrote:
>
>
>
> > I thought History.newItem() would only build the history stack.
> > However in my App it fires the EntryPoint onModuleLoad, restarting the
> > application.
>
> > What am I missing?
--
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.