Announcement Announcement Module
Collapse
No announcement yet.
Validation and Message Joining Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Validation and Message Joining

    Hi everyone,

    I've tried to implement a validation service to my project. My Validator Code looks like this:
    Code:
    public class UserValidator implements Validator{
    	
    	public boolean supports(Class<?> clazz) {
    		return Ort.class.isAssignableFrom(clazz);
    	}
    
    	public void validate(Object target, Errors errors) {
    		Ort ort = (Ort) target;
    		if((ort.getcountryname().length() == 0) && (ort.getzip().length() == 0))
    		{
    		errors.reject("error.zip");
    		errors.reject("error.countryname");
    		}
    		
    	}
    
    }
    I have an message xml witht he following entrys:
    Code:
    ......
    error.zip=There is an Error at Zip-Code
    error.countryname=There is an Error at Countryname
    Everythink works fine. I make an outprint on my jsp like this:
    Code:
    <form:errors path="*" cssClass="error message" element="div"/>
    My HTML Code looks like this if i get an error:
    Code:
    There is an Error at Zip-Code<br>There is an Error at Countryname
    My Question:
    How can I join the message so that i get an outprint on my jsp with looks so:
    Code:
    There is an Error at Zip-Code, There is an Error at Countryname
    Can i do somethink like that in my validation class?:
    Code:
    ......
    		errors.reject("error.zip"+"error.countryname");
    ......
    Thanks for your help

    Regards
    Crazymodder

  • #2
    thanks dude:-)

    http://www.steam-n-dry.co.nz
    http://www.pestcontrolauckland.org.nz
    http://www.carpetcleaningauckland.org.nz
    http://www.aucklandcarpetcleaning.org.nz

    Comment


    • #3
      Crazymodder, you should be able to control individual style of your error messages like this
      Code:
      <spring:hasBindErrors name="form">
      	<div class="message-error">
      	<c:forEach items="${errors.allErrors}" var="error">
      		<div><spring:message message="${error}"/></div>
      	</c:forEach>
      	</div>
      </spring:hasBindErrors>
      Its form one of the recent postings here on the forum.

      Comment

      Working...
      X