Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: Release 1.5, Release 1.5.1, Release 1.6
-
Fix Version/s: Release 1.5.1, Release 1.6
-
Component/s: Validation
-
Labels:None
Description
Annotating a public field with @Validate does not work:
@Validate(required=true)
public String name;
Changing this to a private field with getters and setters works. Public fields already work well with the Stripes tag library, they should also work with validations.
Looking at DefaultValidationMetadataProvider#loadForClass, it seems that java.beans.Introspector.getBeanInfo only returns PropertyDescriptors for JavaBeans properties, i.e. that have a field, accessor, and mutator. It doesn't "see" just a public field, so the method never has a chance to find the @Validate annotation on a public field.