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 <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]> 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 <[EMAIL PROTECTED]>
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 <[EMAIL PROTECTED]> 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
[EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to