Announcement Announcement Module
No announcement yet.
Error messages are not shown in the user form, but exist in the BindingResult Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error messages are not shown in the user form, but exist in the BindingResult

    Need your assistance. I am using the Spring Roo generated controller SignUpController:
    public class SignUpController {
    List<ObjectError> signUpErrors;
    private SignUpValidator validator;
    public UserRegistrationForm formBackingObject() {
        return new UserRegistrationForm();
    @RequestMapping(params = "form", produces = "text/html")//, method = RequestMethod.GET)
    public String createForm(Model uiModel) {
        populateSignUpForm(uiModel, new UserRegistrationForm());
        //uiModel.addAttribute("signUpErrors", signUpErrors);
        return "signup/index";
    @RequestMapping(method = RequestMethod.POST, produces = "text/html")
    public String create(@Valid UserRegistrationForm userRegistration,
            BindingResult bindingResult, Model uiModel, HttpServletRequest request) {
        validator.validate(userRegistration, bindingResult);
        if (bindingResult.hasErrors()) {
            populateSignUpForm(uiModel, userRegistration);
            //uiModel.addAttribute("signUpErrors", bindingResult.getAllErrors());
            return "signup/index";
    for a custom form-backing object UserRegistrationForm:

    public class UserRegistrationForm {
        @NotNull(message="Must be filled.")
        @Size(min=6, max = 45)
        private String login;
        private String email;
        @Size(min=6, max = 45)
    and try to validate it using custom validator. I can show error messages to users, directly passing BindingResults into the jspx, and using the code as follows:

    <c:if test="${signUpErrors.size()>0}">
            <util:panel id="title" title="${title}">
                    <spring:message code="signup_index_error" />
                <c:forEach var="err" items="${signUpErrors}">
                    <br />
                        <td>${err.objectName} </td>
                        <td>${} </td>
                        <td>${err.arguments} </td>
                        <td>${err.defaultMessage} </td>
    But the standard Roo and Spring tags don't work:
    <field:input field="login"
            id="fc_.._UserRegistrationForm_login" required="true"
            z="" />
        <sf:errors path="login" cssStyle="error"></sf:errors>
        <field:input field="email"
            id="fc_.._UserRegistrationForm_email" required="true"
            z="" />
            <sf:errors path="*" cssStyle="error"></sf:errors>
    How to make it work?
    Last edited by dvperv; Aug 27th, 2012, 01:55 PM.