Details
Description
The recommended way to build a cancel button on a form is to use the Submit component with javascript like onclick="javascript:this.form.events.cancel();". In Internet Explorer 6, this causes the cancel listener to get called twice and occasionally the two calls crash into each other and cause an exception. This problem does not exist with Firefox 1.5. Here is a simple example that demonstrates the behavior:
<form jwcid="@Form" cancel="listener:cancel">
<submit jwcid="@Submit" value="Cancel" onclick="javascript:this.form.events.cancel();"/>
</form>
public void cancel(IRequestCycle cycle)
{
System.out.println("cancel called");
}
Output after clicking the cancel button in IE 6:
cancel called
cancel called
(and sometimes an exception and stack trace)
The workaround is to use the Button component instead with the same javascript call. "cancel called" is only printed once in that case for Firefox and Internet Explorer and there are no exceptions.