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" <[email protected]>
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 <[email protected]>:

> On a site registration form, I have three validators on the username >
field.  One tests to make s...
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to