I've been looking at GWT as a way of building client-side components
for a customer service style web application. Because we are required
to support 'no javascript' situations - i.e. basic browser, javascript
turned off, and providing accessible web pages, we are designing
static pages which are then 'decorated' with GWT; the idea being that
the system works with any browser/screen reader etc but provides the
best experience when using a JavaScript enabled browser. I've combined
GWT and the GWT Widget library (
http://gwt-widget.sourceforge.net) to
wrap existing form objects.
I've been fairly successful with this but for one problem. If I create
a GWT Button instance inside a form, clicking on the button causes a
form post to occur. The abbreviated scenario is as follows:
HTML:
<form method="post" action="some-url">
<p>Post Code: <input type="text" id="searchPostCode"></p>
<p>House No: <input type="text" id="searchHouseNo"></p>
<div id="jsSearchButton" align="right"></div>
... address fields ...
... other fields ...
<button type="submit">Next ></button>
</form>
GWT Code:
RootPanel.get("jsSearchButton").add(new Button("Find Address"));
This is neat in that the search button is not present if JavaScript is
not supported, thereby gracefully degrading.
Can anyone offer an insight into how to stop the form submission being
caused by the GWT button? The actual form has a number of fields after
the address and will probably have other GWT buttons as well.
Many thanks for a great framework.