HTML button element form WebKit Chrome Safari iPhone
In WebKit browsers, the
Buttonwidget in a GWT application seems to always act as a submit, regardless of event sinking (via
ClickListener) behaviour added to it.
In Firefox (and IE!) the button works fine - that is the 'onclick' behaviour added to the widget via the GWT listening architecture is executed and the page is not submitted.
A clue to the solution is in the code for the GWT Button (thank goodness for source code - see
It would seem that for WebKit browsers this default is enforced but not made explicit in the DOM so this GWT snippet does not get a chance to resolve the issue. The work around is to always be explicit about the button type (as recommended in W3Schoools).
You do this in GWT as follows:
Button b = new Button("click here"); DOM.setElementAttribute(b.getElement(), "type", "button");