You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Igor Vaynberg <ig...@gmail.com> on 2009/03/25 17:26:29 UTC

Re: Double submit issue - disabling HTML submit button causes form posting to be cancelled

search this list for SecureForm, might give you some ideas for the
form-token pattern.

-igor

On Wed, Mar 25, 2009 at 3:22 AM, Jeremy2009 <js...@gmail.com> wrote:
>
> Hello,
>
> I am implementing a 'double-submit' prevention strategy by pre-pending the
> relevant wicket component's 'onclick' handler with "this.disabled=true".
> This works fine for components that are translated as normal HTML buttons ie
> <input type='button'> and that form submission only involves javascript in
> the onclick handler (eg using AjaxButton):
>
> Eg,
>
> <input type="button" onclick="this.disabled =
> true;wicketShow('ajaxIndicatore2');......bind(this));;; return false;"
> value="Change password" name="submitButton" id="submitButtoned"/>
>
> (NB I have removed the bulk of the ajax javascript code in the onclick
> handler for clarity).
>
> When uploading a file and using the wicket UploadProgressBar class, there's
> javascript placed in the HTML form's onsubmit handler. This handler is ONLY
> fired if you use a HTML submit button <input type='submit'>.  Using a
> standard HTML button and using it's onclick handler to submit the form does
> NOT call the form's onsubmit handler before the form is posted to the
> server.  This is expected browser behaviour as far as i can tell.
>
> Eg,
>
> <input type='button' onclick='this.form.submit()'/>
>
> ...submits the form, but the form's onsubmit handler does not fire.
>
> My problem comes when the following happens:
>
> <input type='submit' onclick='this.disabled=true'/>
>
> ...this disables the submit button and calls the form's onsubmit handler (as
> evidenced by placing javascript alert('here') messages in the generated HTML
> onsubmit handler) BUT it cancels the posting of the form and instead the
> page reloads, as far as i can tell.  According to various web sites, it's
> expected behavour that disabling a submit button cancels the form being
> posting.
>
> So, if i want the form's onsubmit handler to fire and allow the
> UploadProgressBar to work, how am I to prevent a user from double-clicking
> the submit button when uploading a file?  Hopefully, I am missing something
> obvious...
>
> Kinds regards
> Jeremy
>
> --
> View this message in context: http://www.nabble.com/Double-submit-issue---disabling-HTML-submit-button-causes-form-posting-to-be-cancelled-tp22698742p22698742.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org