in my application i need to do a bean validation on a loaded (persistent) form element in a http-get method. To do this, i used the following code:
DataBinder binder = new DataBinder(formObject);
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
SpringValidatorAdapter springValidator = new SpringValidatorAdapter(validator);
binder.setValidator(springValidator);
binder.validate();
// TODO resolve error codes by message source
BindingResult results = binder.getBindingResult();
modelAndView.addObject(BindingResult.MODEL_KEY_PREFIX + "model", results);
Now i have the problem that the defaultMessages in the BindingResult errors contains the message keys, not the resolved message (e.g. "{my.message.key}"). If i do a bean validation by the @Valid annotation in my controller methods, the BindingResult contains the resolved messages. Did I miss something in my manual validation? Or is it now necessary to resolve the message key manually with the MessageSource bean?