Hi Tauren,

A while ago I wrote this article, which may give you some hints on how to achieve this:
http://stuq.nl/weblog/2008-09-03/user-friendly-form-validation-with-wicket

Regards,

Daan

Op 21 apr 2009, om 17:36 heeft Tauren Mills het volgende geschreven:

Thanks Nino,

Actually, I want just one error message right next to the username field
that is specific to the username. I also want to highlight via css the
username field. A messagepanel would list errors in other fields as well,
wouldn't it?

Tauren

On Apr 21, 2009 5:06 AM, "nino martinez wael" <nino.martinez.w...@gmail.com >
wrote:

Hmm, it happens automatically, a validator can register errors.. Like this:

      form.add(new TextField<String>("email",new
PropertyModel<String>(form.getModel(),"email")).add(
EmailAddressValidator.getInstance()).add(new
IValidator() {
                      public void validate(IValidatable validatable) {
                              String string = (String)
validatable.getValue();
if (userRepository.areEmailThere(string)) {
                                      validatable.error(new
ValidationError().addMessageKey(

"error.unique").setVariable("email",

validatable.getValue()));
                              }

                      }
              }));

form.add(new CheckBox("agree", new Model<Boolean>(false))
                              .add(new IValidator<Boolean>() {
                                      public void
validate(IValidatable<Boolean> validatable) {
                                              Boolean agree =
validatable.getValue();
                                              if (!agree) {
validatable.error(new
ValidationError()

.addMessageKey("error.mustagree"));
                                              }

                                      }
                              }));


And then just in your ajax add the error message panel to the
response.. Works just fine... Or is it something more you want?

2009/4/21 Tauren Mills <tau...@tauren.com>:

On a site registration form, I have three validators on the username >
field.  One tests to make s...
---------------------------------------------------------------------
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


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

Reply via email to