Mar 17th, 2010, 01:13 PM
WebUtils.hasSubmitParameter is false if I disable submit button
During the onsubmit event of a form, we are disabling the submit button so the user can't click it twice (which causes all sorts of issues).
The problem is, once disabled, the function hasSubmitParameter() is always returning false in our controller code. We have multiple submit buttons, so we use this function to determine which was clicked and proceed accordingly.
Has anyone found a way around this?
Mar 18th, 2010, 04:31 AM
How about using window.setTimeout and disabling the buttons 2 seconds after the submit? On the other hand your code should be able to deal with a double submit. One simple way is to create a "form id" as hidden form field, that is read from the request and put into the session. If the incoming request has the same form id as the last request, just block it.
Mar 18th, 2010, 10:13 AM
The setTimeout was considered as a solution and tested (works), but it seems inelegant as there won't be a concise time that we can guarantee the form has been submit (and if we set the timeout too long, then it doesn't give us enough protection).
Yes, protecting against this on server side is best practice, at least from a data integrity standpoint. The tokenizer approach you mention is probably what we will do at some point. However, this requires modifications to each JSP as well as controller, which is just not viable at this point in the scope of our project.
But along those lines, how do you simply "reject" a duplicate request from the controller such that it doesn't interfere with the user's experience? I.E. how can I have the controller completely ignore the duplicate request and not attempt to return a view as if it had never happened?