You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by mc...@softcoin.com on 2007/09/27 04:01:00 UTC

Re: AJAX form submit and validation

Apologies for reviving a dead thread, but I'm having the issues  
discussed below and don't entirely understand the proposed  
solutions.  In my case I have a form with multiple TextFields each of  
which is required.  Using the common suggestion of:

AjaxFormValidatingBehavior.addToAllFormComponents(form,"onblur");

The user is prompted with multiple required field errors when they  
tab out of the first required field.  This obviously isn't ideal as  
the user hasn't even had a chance to enter data in the other fields.   
This even happens using the form validation example straight out of  
the "Pro Wicket" book.

I've got an AjaxFallbackButton mostly working to validate everything  
only when the form is submitted, but if the user gets an error and  
then submits the form again without fixing the error the form is  
submitted without validation.  I'm sure there is a bug in my code  
somewhere, but even if there is do I really need to write a half page  
of code to implement an AjaxFallbackButton for what would seem to be  
the most common use case (wanting to validate the entire form at once  
prior to submission)?

I just feel like I'm missing the obvious one liner that will do this  
for me.  Can someone please point me to an example of validating  
multiple form fields using Ajax and wicket upon form submission?

Thanks,
-Mike

On Aug 27, 2007, at 1:48 AM, Ian Godman wrote:

> Apologies to Eelco, missed your email ! Very annoying, would  have  
> saved me a lot of time!
>
> Many thanks.
>
>
> Ian
>
> ----- Original Message ----
> From: Carlos Pita <ca...@gmail.com>
> To: users@wicket.apache.org
> Sent: Monday, 27 August, 2007 6:50:00 AM
> Subject: Re: AJAX form submit and validation
>
> On 8/26/07, Ian Godman <ia...@yahoo.co.uk> wrote:
>>
>> I worked it out. Very simple solution!
>>
>> On the AjaxSubmitLink override the onError method and add the  
>> feedback
>> panel to the AjaxRequestTarget !
>>
>>
>> Ian
>
>
>
> Yes, that or setDefaultFormProcessing(false) as Eelco suggested  
> before.
> That's not doing validation by hand, just postponing the moment of
> validation to fit your needs. Then, when validation should be done,  
> call
> process() on the form and that will carry on validation and model  
> updating
> as usual. It's as simple as that.
>
>
> ----- Original Message ----
>> From: Gerolf Seitz <ge...@gmail.com>
>> To: users@wicket.apache.org
>> Sent: Sunday, 26 August, 2007 6:05:00 PM
>> Subject: Re: AJAX form submit and validation
>>
>> have you tried AjaxFormComponentUpdatingBehavior?
>>
>>   gerolf
>>
>> On 8/26/07, Ian Godman <ia...@yahoo.co.uk> wrote:
>>>
>>> Thanks but this does not solve my problem.
>>>
>>> I am submitting the form via ajax using an AjaxSubmitLink. If the  
>>> form
>> has
>>> errors on it then I do not get the submit, if the form has no errors
>> then
>>> the submit code runs ok. The errors are not displayed.
>>>
>>> If I add a AjaxFormValidatingBehavior for the onblur event then I  
>>> can
>> see
>>> the errors but they check for required fields etc as soon as the  
>>> first
>> field
>>> is left therefore displaying errors too soon.
>>>
>>> With the AjaxFormValidatingBehavior set to onsubmit event I get  
>>> no error
>>> reporting and no submit.
>>>
>>> I need to validate the entire form only when submit button is  
>>> pressed
>>> pressed. One possibility is to do the validation "by hand" in the  
>>> submit
>>> processing code.
>>>
>>>
>>> Ian
>>>
>>>
>>> ----- Original Message ----
>>> From: Gerolf Seitz <ge...@gmail.com>
>>> To: users@wicket.apache.org
>>> Sent: Sunday, 26 August, 2007 2:10:01 PM
>>> Subject: Re: AJAX form submit and validation
>>>
>>> concerning "one field depends on another":
>>> have you already taken a look at
>>>
>>>
>> http://cwiki.apache.org/confluence/display/WICKET/Validating 
>> +related+fields
>>> ?
>>> the code is still 1.2, but it should get you started.
>>>
>>> hth,
>>>   gerolf
>>>
>>> On 8/26/07, Ian Godman <ia...@yahoo.co.uk> wrote:
>>>>
>>>> Hi
>>>>
>>>> I have a form that is submitted by ajax.
>>>>
>>>> I have validation on fields of the form.
>>>>
>>>> Using AjaxFormValidatingBehavior the form will be validated and  
>>>> error
>>>> messages displayed when the onblur event is used.
>>>>
>>>> However this is not what I need as the validation of one field  
>>>> depends
>>> on
>>>> another. I have tried to set the AjaxFormValidatingBehavior to
>> onsubmit
>>> but
>>>> it appears that if the form is invalid then its not submitted so no
>>> errors
>>>> are displayed.
>>>>
>>>> Is there any way I can validate my form using ajax only when it is
>>>> submited ?
>>>>
>>>>
>>>> Ian
>>>>
>>>>
>>>>
>>>>
>>>>       ___________________________________________________________
>>>> Yahoo! Answers - Got a question? Someone out there knows the  
>>>> answer.
>> Try
>>>> it
>>>> now.
>>>> http://uk.answers.yahoo.com/
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>>       ___________________________________________________________
>>> Want ideas for reducing your carbon footprint? Visit Yahoo! For Good
>>> http://uk.promotions.yahoo.com/forgood/environment.html
>>
>>
>>
>>
>>
>>
>>
>>
>> ___________________________________________________________
>> 24 FIFA World Cup tickets to be won with Yahoo! Mail
>> http://uk.mail.yahoo.com
>
>
>
>
>
>
>
>       ___________________________________________________________
> Want ideas for reducing your carbon footprint? Visit Yahoo! For  
> Good  http://uk.promotions.yahoo.com/forgood/environment.html



--
Mike Comb
Director of Engineering
SoftCoin, Inc
mcomb@softcoin.com



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


Re: AJAX form submit and validation

Posted by mc...@softcoin.com.
I think that would be a wonderful addition to the examples.  I spent  
several hours yesterday trying to find an example that covered this.   
In the meantime, any additional pointers to best practices for this  
would be appreciated so that I can get this part of my project working.

-Mike

On Sep 26, 2007, at 9:37 PM, Eelco Hillenius wrote:

> On 9/26/07, mcomb@softcoin.com <mc...@softcoin.com> wrote:
>> Apologies for reviving a dead thread, but I'm having the issues
>> discussed below and don't entirely understand the proposed
>> solutions.  In my case I have a form with multiple TextFields each of
>> which is required.  Using the common suggestion of:
>>
>> AjaxFormValidatingBehavior.addToAllFormComponents(form,"onblur");
>>
>> The user is prompted with multiple required field errors when they
>> tab out of the first required field.  This obviously isn't ideal as
>> the user hasn't even had a chance to enter data in the other fields.
>> This even happens using the form validation example straight out of
>> the "Pro Wicket" book.
>>
>> I've got an AjaxFallbackButton mostly working to validate everything
>> only when the form is submitted, but if the user gets an error and
>> then submits the form again without fixing the error the form is
>> submitted without validation.  I'm sure there is a bug in my code
>> somewhere, but even if there is do I really need to write a half page
>> of code to implement an AjaxFallbackButton for what would seem to be
>> the most common use case (wanting to validate the entire form at once
>> prior to submission)?
>>
>> I just feel like I'm missing the obvious one liner that will do this
>> for me.  Can someone please point me to an example of validating
>> multiple form fields using Ajax and wicket upon form submission?
>
> Maybe what we should do is create an example for Wicket examples that
> shows what most would agree is best practice here. It's definitively
> not the idea that you have to write half a page of code to achieve
> this, and it seems this issue regularly comes up.
>
> Eelco
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



--
Mike Comb
Director of Engineering
SoftCoin, Inc
mcomb@softcoin.com



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


Re: AJAX form submit and validation

Posted by Eelco Hillenius <ee...@gmail.com>.
On 9/26/07, mcomb@softcoin.com <mc...@softcoin.com> wrote:
> Apologies for reviving a dead thread, but I'm having the issues
> discussed below and don't entirely understand the proposed
> solutions.  In my case I have a form with multiple TextFields each of
> which is required.  Using the common suggestion of:
>
> AjaxFormValidatingBehavior.addToAllFormComponents(form,"onblur");
>
> The user is prompted with multiple required field errors when they
> tab out of the first required field.  This obviously isn't ideal as
> the user hasn't even had a chance to enter data in the other fields.
> This even happens using the form validation example straight out of
> the "Pro Wicket" book.
>
> I've got an AjaxFallbackButton mostly working to validate everything
> only when the form is submitted, but if the user gets an error and
> then submits the form again without fixing the error the form is
> submitted without validation.  I'm sure there is a bug in my code
> somewhere, but even if there is do I really need to write a half page
> of code to implement an AjaxFallbackButton for what would seem to be
> the most common use case (wanting to validate the entire form at once
> prior to submission)?
>
> I just feel like I'm missing the obvious one liner that will do this
> for me.  Can someone please point me to an example of validating
> multiple form fields using Ajax and wicket upon form submission?

Maybe what we should do is create an example for Wicket examples that
shows what most would agree is best practice here. It's definitively
not the idea that you have to write half a page of code to achieve
this, and it seems this issue regularly comes up.

Eelco

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