kendy lau opened SPR-7358 and commented
How to deal with two @ModelAttribute(s) like the follows:
@RequestMapping(method = RequestMethod.POST)
public String processSubmit(@ModelAttribute("owner") Owner owner, @ModelAttribute("contact") Contact contact,
BindingResult result, SessionStatus status) {
new OwnerValidator().validate(owner, result);
if (result.hasErrors()) {
return "owners/form";
}
else {
this.clinic.storeOwner(owner);
status.setComplete();
return "redirect:/owners/" + owner.getId();
}
}
When error occures during the OwnerValidator validate the command owner, the BingingResult don't know which command object is the errors binded for.
the validator is like this
public class OwnerValidator {
public void validate(Owner owner, Errors errors) {
if (!StringUtils.hasLength(owner.getFirstName())) {
errors.rejectValue("firstName", "required", "required");
}
if (!StringUtils.hasLength(owner.getLastName())) {
errors.rejectValue("lastName", "required", "required");
}
.....
Affects: 3.0.2
Attachments:
Issue Links:
kendy lau opened SPR-7358 and commented
How to deal with two
@ModelAttribute(s) like the follows:@RequestMapping(method = RequestMethod.POST)public String processSubmit(
@ModelAttribute("owner") Owner owner,@ModelAttribute("contact") Contact contact,BindingResult result, SessionStatus status) {
When error occures during the OwnerValidator validate the command owner, the BingingResult don't know which command object is the errors binded for.
the validator is like this
public class OwnerValidator {
.....
Affects: 3.0.2
Attachments:
Issue Links: