DWRUtil.onReturn

Getting notified when return is pressed

When inputs are part of a form then the return key causes the form to be submitted. When you are using Ajax, this is generally not what you want. Usually it would be far better if some JavaScript was triggered.

Unfortunately different browsers handle events in quite a different manner. So DWRUtil.onReturn patches over the differences. If you want to have a submit button that does the same as pressing return in a form field, then you need to code your application like this:

<input type="text"
    onkeypress="DWRUtil.onReturn(event, submitFunction)"/>
<input type="button" onclick="submitFunction()"/>

You can use either the onkeypress event or the onkeydown event; they do roughly the same thing.

Generally speaking DWR is not a generic JavaScript library so it does not attempt to provide fill this need. However this is one of these really useful functions to have around if you are doing Ajax work.

onSubmit

This function makes up for the fact that the onSubmit() event only works with <FORM ...> elements.