You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alec Swan <al...@gmail.com> on 2011/04/14 18:25:13 UTC

How to check if form submission succeeded using JavaScript?

Hello,

I have a button on a page which submits a Wicket form by calling
form.submit() using straight JavaScript. If the form submitted without
errors, then the JavaScript code should set a cookie. I am looking for
some ideas on how to detect if the form was submitted successfully or
not in JavaScript?

Thanks,

Alec

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


Re: How to check if form submission succeeded using JavaScript?

Posted by Alec Swan <al...@gmail.com>.
Thanks for the prompt response. However, in my case is has to be set
on the client/JavaScript side because our application allows page
designers to change the content of the page and its behavior at
runtime and decide which cookie to set if any.

Thanks,

Alec

On Thu, Apr 14, 2011 at 10:37 AM, Pedro Santos <pe...@gmail.com> wrote:
> Hi, you can set a cookie in the Button#onSubmit implementation,
>
> new Button(""){
>    public void onSubmit() {
>        //at this point all validations are tested
>        ((WebResponse)RequestCycle.get().getResponse()).addCookie(new
> Cookie(name, value));
>    }
> }
>
> On Thu, Apr 14, 2011 at 1:25 PM, Alec Swan <al...@gmail.com> wrote:
>
>> Hello,
>>
>> I have a button on a page which submits a Wicket form by calling
>> form.submit() using straight JavaScript. If the form submitted without
>> errors, then the JavaScript code should set a cookie. I am looking for
>> some ideas on how to detect if the form was submitted successfully or
>> not in JavaScript?
>>
>> Thanks,
>>
>> Alec
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> --
> Pedro Henrique Oliveira dos Santos
>

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


Re: How to check if form submission succeeded using JavaScript?

Posted by Pedro Santos <pe...@gmail.com>.
Hi, you can set a cookie in the Button#onSubmit implementation,

new Button(""){
    public void onSubmit() {
        //at this point all validations are tested
        ((WebResponse)RequestCycle.get().getResponse()).addCookie(new
Cookie(name, value));
    }
}

On Thu, Apr 14, 2011 at 1:25 PM, Alec Swan <al...@gmail.com> wrote:

> Hello,
>
> I have a button on a page which submits a Wicket form by calling
> form.submit() using straight JavaScript. If the form submitted without
> errors, then the JavaScript code should set a cookie. I am looking for
> some ideas on how to detect if the form was submitted successfully or
> not in JavaScript?
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Pedro Henrique Oliveira dos Santos

Re: How to check if form submission succeeded using JavaScript?

Posted by Alec Swan <al...@gmail.com>.
Thanks. I will follow yours and Pedro's recommendations and submit
form using AjaxButton.

On Thu, Apr 14, 2011 at 12:54 PM, Martin Grigorov <mg...@apache.org> wrote:
> if you use (JavaScript) form.submit() then this will reload the whole page.
> I.e. there is no way to do anything with JavaScript after submitting the
> form.
>
> On Thu, Apr 14, 2011 at 6:25 PM, Alec Swan <al...@gmail.com> wrote:
>>
>> Hello,
>>
>> I have a button on a page which submits a Wicket form by calling
>> form.submit() using straight JavaScript. If the form submitted without
>> errors, then the JavaScript code should set a cookie. I am looking for
>> some ideas on how to detect if the form was submitted successfully or
>> not in JavaScript?
>>
>> Thanks,
>>
>> Alec
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>

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


Re: How to check if form submission succeeded using JavaScript?

Posted by Martin Grigorov <mg...@apache.org>.
if you use (JavaScript) form.submit() then this will reload the whole page.
I.e. there is no way to do anything with JavaScript after submitting the
form.

On Thu, Apr 14, 2011 at 6:25 PM, Alec Swan <al...@gmail.com> wrote:

> Hello,
>
> I have a button on a page which submits a Wicket form by calling
> form.submit() using straight JavaScript. If the form submitted without
> errors, then the JavaScript code should set a cookie. I am looking for
> some ideas on how to detect if the form was submitted successfully or
> not in JavaScript?
>
> Thanks,
>
> Alec
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com <http://jweekend.com/>