PDA

View Full Version : static ${status.errorMessage}


faisalloe
May 23rd, 2007, 01:24 AM
Hello,

following this tutorial
http://www.devx.com/Java/Article/22134/1954?pf=true

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

when i use above code when error fires from validation.java, on jsp it displays

"${status.errorMessage}" in red color is it jstl issue or some thing else ?

Thanks
FAisal khan

kuanfai
May 23rd, 2007, 05:33 AM
should you use <c:out value="${status.errorMessage}"/> ?

faisalloe
May 23rd, 2007, 08:27 AM
well either 'c' or 'core' it depends upon the prefix you created, i created by 'core'

Jörg Heinicke
May 23rd, 2007, 11:14 AM
The code is wrong at least. It can be something like


<spring:hasBindErrors name="credentials">
<font color="red"><ul>
<spring:bind path="credentials">
<c:forEach items="${status.errorMessages}" var="error">
<li><c:out value="${error}"/></li>
</c:forEach>
</spring:bind>
</ul></font>
</spring:hasBindErrors>


<spring:hasBindErrors> works more like an if and it exports the Errors instance as variable (see taglib description tld). spring:bind exports BindStatus from which you can access errorMessage(s). It's probably better to use the latter since BindStatus accesses the Errors instance for the actual errors but does some conversions to Strings.

Jörg

faisalloe
May 24th, 2007, 01:03 AM
helo thanks to replay,

but it didn't work instead printed only one bullet not value !!!! :confused:

faisalloe
May 24th, 2007, 01:08 AM
my orignal code is some thing like this
using "hasBindErrors" tag with every maping field.

<spring:bind path="useremailform.model">
<input type="hidden" name="model" id="model"/>
</spring:bind>

<spring:hasBindErrors name="useremailform">
<font color="red"><core:out value="Chose Model"/></font>
</spring:hasBindErrors>

faisalloe
May 24th, 2007, 01:15 AM
currently i m using

<core:out value="Chose Model"/>

which prints static value b/c your error retriving logic was't working want to repalce it with yoru logic.

faisalloe
May 24th, 2007, 01:29 AM
<spring:hasBindErrors name="useremailform">
<font color="red"><ul>
<spring:bind path="useremailform">
<core:forEach items="${status.errorMessages}" var="error">
<li><core:out value="${error}"/></li>
</core:forEach>
</spring:bind>
</ul></font>
</spring:hasBindErrors>


it prints "* ${error}" on jsp when error fires.