I want to have my own Hibernate annotaion validator...... named NotEmpty a
problem is that when after form submition the only initialize() method is
called. isValid() method does not executes......
below is the code and Thanks in advance for help......
------------- Annotation descriptor -------------------
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.hibernate.validator.ValidatorClass;
@ValidatorClass(value=NotEmptyValidator.class)
@Target(value={ElementType.METHOD,ElementType.FIELD})
@Retention(value=RetentionPolicy.RUNTIME)
@Documented
public @interface NotEmpty {
String message() default "Field cannot be empty";
}
------------- Annotation validator -------------------
import org.hibernate.validator.PropertyConstraint;
import org.hibernate.validator.Validator;
import java.io.Serializable;
public class NotEmptyValidator implements Validator, PropertyConstraint,
Serializable {
public boolean isValid(Object value) {
System.out.println(" is Valid method called...");
..............
..............
return false;
}
public void initialize(NotEmpty parameters) {
System.out.println(" Initialize method called...");
}
public void apply(org.hibernate.mapping.Property property){
System.out.println(" Apply method called...");
}
}
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995089#3995089
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995089
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user