Announcement Announcement Module
Collapse
No announcement yet.
simple question: Errors.reject() and Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • simple question: Errors.reject() and

    Hi,
    I've searched this forum, the web, and all Spring samples I could find, but didn't find an answer to this simple problem. I have a "change password" screen; the user must enter a new password in field1 and confirm it in field2. I have the following code in a Validator:

    Code:
    public void validate(Object obj, Errors errors) {
      if (!password1.equals(password2))
        errors.reject("changepassword.passwordsnotequal", "no default!");				
    }
    and this is the JSP form:
    Code:
    <spring&#58;hasBindErrors name="command">
      <font color="red">
        <c&#58;forEach var="err" items="$&#123;errors.globalErrors&#125;">
          <tr><td><c&#58;out value="$&#123;err&#125;"/></font></td></tr>
        </c&#58;forEach>
      </font>
    </spring&#58;hasBindErrors>
    When the passwords don't match, the validate() code is called as expected, and the user is forwaded back to the form, but the output on the form is:

    Code:
    Error in object 'command'&#58; codes &#91;changepassword.passwordsnotequal.command,changepassword.passwordsnotequal&#93;; arguments &#91;&#93;; default message &#91;no default!&#93;
    How can I display the message associated with changepassword.passwordsnotequal?

    Thank you in advance for any help,
    grimholtz

  • #2
    In case anyone comes across this thread, here's the answer (found at http://sourceforge.net/mailarchive/m...msg_id=8923552)

    Code:
    <spring&#58;hasBindErrors name="command">
         <spring&#58;bind path="command.*">
           <c&#58;forEach var="error" items="$&#123;status.errorMessages&#125;">
             <tr><td><font color="red"><c&#58;out value="$&#123;error&#125;"/></font></td></tr>
           </c&#58;forEach>
         </spring&#58;bind>
    </spring&#58;hasBindErrors>

    Comment

    Working...
    X