For cross field validation it would be nice if the Form object allowed
you to mark multiple fields with a single validation failure.
Currently, the only way I can see to do this is to either create two
validation errors, one for each field (so that they are decorated
properly).  However, if you are also using the <t:errors /> component,
then you end up with that validation failure showing up twice in the
errors list...

Something like the following (for a create new user form):

@InjectComponent
private Form form;

@InjectComponent
private PasswordField passwordField1, passwordField2;

@Property
private String password1, password2;

void onValidateForm() {
   if( password1 != null && !password1.equals( password2 ) ) {
      form.recordError( "Passwords do not match", passwordField1,
passwordField2 );
   }
}

Another alternative would be to simply mark the field as having an
error with a method like the following:

form.recordError( passwordField1 );

This would decorate the field, but since there's no text it wouldn't
be added to the errors list.  This wouldn't work well with the
javascript clientValidation though (which I disable, I think it's
ugly).

Have I overlooked something? Is there some other way to accomplish
this?  With the current implementation it seems like my only real
option is to use:

form.recordError( "Passwords do not match" );

and not decorate the fields at all...

Thanks,
Pete Poulos

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

Reply via email to