I am trying to add validation to my model objects (which double as my form backing beans) using javax.validation annotations.
My model looks like this:
public Class TestObject {
private String myProp;
private InnerObject innerObject;
//getters and setters omitted
}
public Class InnerObject {
private BigDecimal myValue;
@NotNull
public BigDecimal getMyValue();
}
In my controller I have the method call like this:
public View calculate(@ModelAttribute("testObject") @Valid TestObject testObject, BindingResult result)
I also have the <mvc:annotation-driven/>
in my spring-servlet.xml file.
Everytime I run the form with a null value it tells me there are 0 binding result errors.
I am using Java 1.6 with Hibernate-Validator-4.2.0 and Validation-API-1.0.0 on my classpath.
Can anyone help me and let me know what I am doing wrong? Been playing around with this for a while and can't get it to work.
Thanks