My question is how does the validaotr return errors (if any ) to the jsp page
Effectively this just calls...
Code:
errors.rejectValue(field, errorCode, errorArgs, defaultMessage);
if the quantity field is empty. The errors object is passed to the JSP.
If so, how do i get and display the errors on the jsp page?
From the petclinic sample:
Code:
<spring:bind path="command.name">
<FONT color="red">
<B><c:out value="${status.errorMessage}"/></B>
</FONT>
<BR><INPUT type="text" maxlength="30" size="30" name="name" value="<c:out value="${status.value}"/>" >
</spring:bind>
The <c:out value="${status.errorMessage}"/> will display the error.
Is it possible for me to use the validator without using this tag to display errors on the jsp?
Yes. Add you're error:
Code:
errors.reject(code);
Then display:
Code:
<spring:hasBindErrors name="command">
<c:forEach items="${errors.globalErrors}" var="error">
<div class="error">
<spring:message code="${error.code}" />
</div>
</c:forEach>
</spring:hasBindErrors>
I'd also appreciate it if you coud point me to examples or tutorials.
The samples in the Spring distribution are a great place to start.