Announcement Announcement Module
Collapse
No announcement yet.
displaying multiple errors with spring:bind Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • displaying multiple errors with spring:bind

    When using the spring:bind tag, ${status.errorMessage} seems to displaying only one error message even if there happen to be multiple errors, at least when I use the tag in this way:
    Code:
    			<spring&#58;bind path="priceIncrease.percentage">        
    				<td width="20%">          
    					<input type="text" name="percentage" value="<c&#58;out value="$&#123;status.value&#125;"/>">   
    				</td>        
    				<td width="60%">          
    					<font color="red"><c&#58;out value="$&#123;status.errorMessage&#125;"/></font>        
    				</td>      
    			</spring&#58;bind>
    That behavior is fine in some instances. (It's probably enough to print out only one error for an object property.) But there are times when I'd like to be able to display all errors. In fact, I think I'd almost always want to print out all object-level errors-- that is, errors based on an interaction of object properties, as in "A comment is required when price increase is > 30" and "Price reductions require management approval."

    So how does one display multiple errors?

  • #2
    Code:
    #macro&#40; ferr &#41;
    	#springBind&#40;$path&#41;
    #if&#40; $status.error &#41;
    <div id="ferr-$&#123;status.expression&#125;" class="fldErrBlk"><ul
    	#foreach&#40;$error in $status.errorMessages&#41;
    ><li>$&#123;error&#125;#if&#40; $velocityCount < $status.errors.getFieldErrorCount&#40;"*"&#41; &#41;<span class="divider"></span>#end</li
    	#end
    ></ul></div>
    #end
    #end

    Comment

    Working...
    X