Results 1 to 2 of 2

Thread: Displaying global error message with arguments resolved

Hybrid View

  1. #1
    Join Date
    Jan 2009
    Posts
    4

    Default Displaying global error message with arguments resolved

    Hello,

    I just began learning and using Spring and this is my first post to the forums.

    In the Validator class, I have registered a global error:
    Code:
    errors.reject("error.required.fields.blank", new Object[]{new String("My Arguments")}, "Required fields cannot be blank");
    In the errors.properties file, I have an entry for the above error code:
    Code:
    error.required.fields.blank=Required Field(s) {0} cannot be blank
    In the JSP, I am trying to display the error message using:
    Code:
    <spring:hasBindErrors name="user">
            <c:forEach items="${errors.allErrors}" var="err">
                    <spring:message code="${err.code}" text="${err.defaultMessage}"/><br>
            </c:forEach>
    </spring:hasBindErrors>
    But the error message is displayed as
    Required Field(s) {0} cannot be blank
    I would like the arguments in the error message to be substituted by the values I provide in the Validator class.

    If I tie the same error message to a form field using error.rejectValue() and display it using <form:errors> tag in the JSP, it gets displayed fine.

    Any help is appreciated.

    Thanks,
    Anand

  2. #2
    Join Date
    Jan 2009
    Posts
    4

    Default

    Can somebody please help?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •