Stripes

@Validate does not work on a public field

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major 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.

Activity

Hide
Frederic Daoud added a comment - 27/Sep/08 1:37 PM

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.

Show
Frederic Daoud added a comment - 27/Sep/08 1:37 PM 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.
Hide
Frederic Daoud added a comment - 27/Sep/08 2:03 PM

Fixed in build 958 (branches/1.5.x) and 959 (trunk) with accompanying unit test.

Show
Frederic Daoud added a comment - 27/Sep/08 2:03 PM Fixed in build 958 (branches/1.5.x) and 959 (trunk) with accompanying unit test.

People

Vote (0)
Watch (0)

Dates

  • Created:
    05/Sep/08 7:54 AM
    Updated:
    04/Jan/11 2:58 PM
    Resolved:
    27/Sep/08 2:03 PM