Results 1 to 2 of 2

Thread: simple question: Errors.reject() and

  1. #1
    Join Date
    Apr 2005
    Posts
    14

    Default 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. #2
    Join Date
    Apr 2005
    Posts
    14

    Default

    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>

Similar Threads

  1. Simple configuaration question
    By soniks in forum Container
    Replies: 10
    Last Post: Mar 10th, 2006, 12:05 PM
  2. Very simple question
    By rogerf in forum Container
    Replies: 19
    Last Post: Oct 10th, 2005, 06:33 PM
  3. simple question
    By yukster in forum Security
    Replies: 6
    Last Post: Sep 19th, 2005, 07:58 AM
  4. Simple question
    By haninaguib in forum Web Flow
    Replies: 1
    Last Post: Jun 21st, 2005, 01:16 PM
  5. simple question about use quote in value
    By jackyliuq in forum Container
    Replies: 2
    Last Post: Jun 10th, 2005, 02:17 PM

Posting Permissions

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