Hello,
I'm using Tapestry 5.4 beta 27 on java 1.7.0_76 with Windows 8.1.
I'm not sure this is the right place where describe a potential bug.
I put my very simplified class.

I have an entity with two Date fields:
@Entity

@Table(name = "testparent", schema = "phoenix")

public class TestParent implements Serializable{

@Property
@ValidateDb (name="V1")
@Column(name = "F7dateReq")
public Date f7datereq;

@Property
@ValidateDb (name="V2")
@Column(name = "F14datetimeReq")
public Date f14datetimeReq;
}

and a custom ValidateDb ConstraintValidator that ensure that date values
are mandatory:


@Constraint(validatedBy = ValidateDbValidator.class)
@Target({ METHOD, FIELD, ANNOTATION_TYPE})
@Retention(RUNTIME)
@Documented
public @interface ValidateDb {
    String message() default "{com.acme.constraint.Range.message}";

    Class<?>[] groups() default {};

    Class<? extends Payload>[] payload() default {};

    String name() default "";
}


public class ValidateDbValidator implements ConstraintValidator<ValidateDb,
Object> {
 @Override
    public void initialize(ValidateDb constraintAnnotation) {
    }

    public boolean isValid(Object value, ConstraintValidatorContext
context) {

     String errorMessage=null;
     if (value==null)
      errorMessage="{validateDb.constraint.notNull}";

     context.disableDefaultConstraintViolation();
     if (errorMessage==null || "".equals(errorMessage.trim()))
     {

  context.buildConstraintViolationWithTemplate("").addConstraintViolation();
      return true;
     }
     else
     {

  
context.buildConstraintViolationWithTemplate(errorMessage).addConstraintViolation();
      return false;
     }
    }
}


I'm using the standard bean edit form and when I press the "Save" button,
the alert message appears in this way
[image: Immagine in linea 1]
In other words I get just one message referring the wrong input component
while I should get two distinct error messages, one for each field.

If I use two String fields instead of date fields, the messages are right
[image: Immagine in linea 2]

Reply via email to