PDA

View Full Version : Problem with ${status.errorMessage} in spring 1.1.3 ?


Big K.
Jan 31st, 2005, 01:39 PM
Hi,

I'm quite new to spring and I've tried to make a logon application. To do this, I used some code of this article : http://www.devx.com/Java/Article/22134

But I have a problem with ${status.errorMessage} in my jsp file :

<spring:hasBindErrors name="credentials">
<font color="red">
<core:out value="${status.errorMessage}"/>
</font>
</spring:hasBindErrors>

The ${status.errorMessage} is always blank. After quite some time, I managed to figure out what was the problem. If I use the spring.jar and spring.tld of the zip file of the article, my code works fine. But If I try the 1.1.3 or 1.1.4 version of the those files (I haven't tested all the versions) it doesn't work: the ${status.errorMessage} is blank.

So I was wondering if It was a bug, or if I did it wrong. Perhaps, there is a new way of doing all the validation stuff.

Thanks, and forgive me my english ;)

huijzer
Feb 1st, 2005, 04:22 AM
Please have a look the documentation for the spring tags:
http://www.springframework.org/docs/taglib/index.html

The status.errorMessage is only available for the <spring:bind> tag. When using <spring:hasBindErrors> you should use other tags, such as:

errors.errorCount: the number of errors
errors.allErrors: all errors in a java.util.List
errors.globalErrorCount: the amount of errors registered for the object (so not for properties)
errors.globalErrors: the errors registerd for the object, in a java.util.List
errors.globalError: the first, non-field-specific error

Hope this helps,
Arjan Huijzer

Big K.
Feb 1st, 2005, 11:09 AM
Ok, thanks, I've tried with <spring:bind> tag, and it works.