I guess there are cases where you want to use an AbstractFormValidator
and run validation on a form before it is submitted and want to address
those fields before they are submitted.  It would be nice if the
modelobject were updated.

Let's say you have 100 textfields attached to a form, you want to
validate some of the fields, all at once (say using FormValidator
attached to the form),

Is there a way to force a modelobject update on each individual field
and then do my form validation.  (I guess the only way is through ajax
events on each field).

E.g.

Form.add(new TextField);
Form.add(new TextField);
Form.add(new TextField);
Form.add(new TextField);
Form.add(new TextField);

Form.add(new AbstractFormValidator() {
   onValidate() {
      if (textField1.getInput() == "creditCard") {
      }
   }
});
...

With the code above, I have to do all of my form validation without my
desired type.

-----Original Message-----
From: Wilhelmsen Tor Iver [mailto:toriv...@arrive.no] 
Sent: Friday, July 29, 2011 3:20 AM
To: users@wicket.apache.org
Subject: RE: getInput and getDefaultModelObject and validation

> If I am using some form validator, I notice that getDefaultModelObject

> does not have the value from the getInput.  I am assume this 
> intentional.  Is there a way to force wicket to update the
modelObject?

Yes, form component models are not updated until they pass validation,
that is very intentional. :)

(E.g. if you have a Date text field and someone types "beer", what would
you expect to be written to the model?)

> How and when does the modelobject get updated.
 
When all validation succeeds and it progresses into a submit.

> But if I weren't using ajax, is there a way to force wicket to update 
> the modelObject.

That will happen automatically after validation passes. Validation
should ideally only check inputs and give any errors.

- Tor Iver

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




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

Reply via email to