Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14

Thread: Validation Error Messages

  1. #11
    Join Date
    May 2006
    Posts
    10

    Default

    Hi Mike,

    A quick and dirty test of your approach worked for me. However, as you mentioned I spot a problem concerning the command object's name in the general case too. You face a problem for e.g. <spring:hasBindErrors name="myCommandObject"> for arbitrary command objects. You could circumvent this problem for example by convention (use always "command" as the command object's name) or by additional programming (you could add the command object's name e.g. in #referenceData() of your controller) However, neither approach is perfect.

    Bye,

    Daniel

  2. #12

    Smile

    Hi Daniel,

    I found out the solution through trial and error.

    For field errors:

    Code:
    <c:forEach items ="${errors.fieldErrors}" var = "err">	
    	   			
    	   			<spring:bind path = command.${err.field}">
    	   				<br><c:out value = "${status.errorMessage}"/>
    	   			</spring:bind> 
    	   		</c:forEach>
    Thanks to Spring Community for help

  3. #13
    Join Date
    Feb 2007
    Location
    New Hampshire
    Posts
    54

    Default

    Code:
    <c:forEach items ="${errors.fieldErrors}" var = "err">	
       <spring:bind path ="command.${err.field}">
    	<c:out value = "${status.errorMessage}"/>
            <br>
       </spring:bind> 
    </c:forEach>
    Didn't work for me. It didn't work when I used "command" or when I used a specific command name, such as <spring:bind path ="login.${err.field}">

    Anyone else have any luck?

  4. #14

    Default

    I've got different issue:
    I reject a value in validator with
    ValidationUtils.rejectIfEmptyOrWhitespace(errors, "price", "validation.field.requred");

    And i would like the error code to be just "validation.field.requred",
    but i get "validation.field.required.item.price"

    There should be easy solution for this I think

    UPD: I display error on JSP with <form:errors path="price" cssClass="fieldError"/> inside <form:form commandName="item">
    Last edited by dhr_padla; Feb 27th, 2007 at 07:51 AM. Reason: missed a string

Posting Permissions

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