Results 1 to 3 of 3

Thread: <vld:annotation-based-validator id="validator"/>

  1. #1
    Join Date
    Mar 2007
    Posts
    566

    Default <vld:annotation-based-validator id="validator"/>

    Hi,

    I want to use bean validation framework 0.8 with the annotation driven configuration:
    <vld:annotation-based-validator id="validator"/>

    First - there seems to be a dependency to javax.servlet.ServletContext:

    org.springframework.beans.factory.BeanCreationExce ption: Error creating bean with name '__handler_registry_validator': Instantiation of bean failed; nested exception is java.lang.NoClassDefFoundError: javax/servlet/ServletContext

    Why that?

    And:

    Validation takes not place

    Do I have to do anything more than adding <vld:annotation-based-validator id="validator"/> the my applicationContext.xml annd annotating my class?

    Thx.

  2. #2
    Join Date
    Mar 2007
    Posts
    566

    Default

    OK, it seems that BeanValidation was designed for web apps and mvc-validation. Therefore the dependency to Servlets.

    This is, how it works:

    Code:
    xml:
    <vld:annotation-based-validator id="validator"/>
    
    java:
    	Foo f  = new Foo();
    	f.setBar("Bla"); //bar has an @Email-Annotation
    	Validator v = (Validator)applicationContext.getBean("validator");
    	BindException e = new BindException(f, "foo");
    	v.validate(f, e);

  3. #3
    Join Date
    Mar 2007
    Posts
    566

    Default

    Another thing:

    the validator stops after the first error for a single property, e.g.:

    Code:
    @Email
    @Length(min=10)
    private String foo;
    If the foo is not a valid email, the length is not validated.

    Can it be configured that all annotations are processed?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •