I'm currently using JSR-303 Bean Validation API for validating the bean.
I did a small program wh just primitive types.
Book.java
form.jspCode:public class Book { @NotEmpty private String name; @Size(min=1, max=50) private String description; // Getters and setters here }
Everything was working fine.Code:<form:form method="post" action="book.html" commandName="book"> <table> <tr> <td>Name:</td> <td><form:input path="name" /></td> <td><form:errors path="name" /></td> </tr> <tr> <td>Description:</td><td><form:textarea path="description"/></td> <td><form:errors path="description" /></td> </tr> </table> <input type="submit" value="Create" /> </form:form>
Then I introduced an object Author inside book.
Book.Java
Author.javaCode:Public Class Book{ @NotEmpty private String name; @Size(min=1, max=50) private String description; private Author author; //Getters and Setters }
Now I get an error:Code:Public Class Author{ @NotEmpty private String authorName; //Getters and Setters }
javax.validation.UnexpectedTypeException: No validator could be found for type: com.ratzzak.form.Author
What is the right way to do the validation?


Reply With Quote