java - Spring MVC and JSR 303 - Manual Validation -
i'm using spring mvc 3 , jsr 303. have form backing object has beans of different types in it. depending on request parameter value, i'll have choose bean validate , save. can't use @valid
validation since bean validate not known until runtime.
i able inject javax.validation.validator
controller, i'm not sure how validate bean , store errors in bindingresult/error
in "spring way".
i need in handler method, rather initbinder
method, because of request mapping.
[edit]
the problem i'm having validate(object, errors)
doesn't recognize nested beans. bean validate accessed through foo.getbar().getbean(), foo form backing object. when validate(foo.getbar().getbean(), errors)
, following error message.
jsr-303 validated property 'property-name' not have corresponding accessor spring data binding
has done before? thanks.
just guess, have tried
errors.pushnestedpath("bar.bean"); // path nested bean validate(foo.getbar().getbean(), errors) errors.popnestedpath();
that's how bindingresult
used validation of nested beans.
Comments
Post a Comment