I’m creating a web application with GWT. I have a method bookMode() that builds a UI with some textboxes, listboxes, etc. and shows it in a dialog box. I call the method like this:
//listen for mouse events on the add button
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
String check = Cookies.getCookie("role");
if(check == "TopBeheerder") {
boolean currentMode = mode0.getValue();
add addObject = new add();
if(currentMode == true) {
addObject.bookMode();
}
if(currentMode == false) {
addObject.userMode();
}
}
else {
BibPhp.notification("You don't have enough permissions.");
}
}
});
When I use the GWT.log() function I notice that this method is called twice. But I searched all my code with the eclipse search function and the method isn’t called twice. I have no idea why GWT behaves likes this. The method userMode() is also called twice.
When the Java code gets converted to HTML and Javascript; the equality comparison between java and javascript are not the same. Hence if you have two widgets (buttons) with the same id in HTML and add click handlers to each one by one, chances are high that the same widget gets the click handler added twice. Try setting different ids to the button widgets, that has helped me to resolve any issues related multiple click handler invocations.