|
From: Kopylenko, D. <dko...@ac...> - 2003-10-02 15:31:59
|
I've now committed the suggested change. The behavior of this tag is =
now
based on the "property" parameter:
- "property" empty =3D global errors
- "property=3DmyProperty" =3D just the errors for "myProperty"
- "property=3D*" =3D all errors, both global and for all properties
Regards,
Dmitriy
-----Original Message-----
From: j=FCrgen h=F6ller [werk3AT] [mailto:jue...@we...]=20
Sent: Thursday, October 02, 2003 5:13 AM
To: Kopylenko, Dmitry; Spring Developers
Subject: Re: [Springframework-developer] New addition to BindTag
Dmitriy,
=20
That's definitely useful. I'm wondering if there's an alternative to a
"showAllErrors" boolean, though - as this parameter is just applied if
parameter "property" is empty. We could for example define =
"property=3D*" as
showing all errors, for all properties. That would mean:
=20
- "property" empty =3D global errors
- "property=3DmyProperty" =3D just the errors for "myProperty"
- "property=3D*" =3D all errors, both global and for all properties
=20
The good thing would be that there's no ambiguity, i.e. no invalid
combinations of parameters.
=20
Juergen
=20
-----Urspr=FCngliche Nachricht-----=20
Von: Kopylenko, Dmitry [mailto:dko...@ac...]=20
Gesendet: Mi 01.10.2003 15:00=20
An: 'Spring Developers'=20
Cc:=20
Betreff: [Springframework-developer] New addition to BindTag
=09
=09
Hello everyone,=20
I came across the following limitation in using BindTag to render
ObjectErrors (in our case anyway :-). The thing is that we use generic =
JSP
to render validation errors which we include in each JSP by using it =
like
this:
<spring:bind path=3D"${command}">=20
<div class=3D"error">=20
<ul style=3D"margin:0;padding:0;">=20
<c:forEach
items=3D"${status.errorMessages}" var=3D"msg">=20
<li><c:out
value=3D"${msg}"/></li>=20
</c:forEach>=20
</ul>=20
</div>=20
</spring:bind>=20
By using it like this(without specifying property name) it shows
only "Global Errors, but we need to show all errors (like typeMismatch =
etc.)
So, I've added an optional boolean attribute to the tag called
showAllErrors and when it's set to "true" then the tag will expose all
errors. By default it's false:
<spring:bind path=3D"${command}" =
showAllErrors=3D"true">
<div class=3D"error">=20
<ul style=3D"margin:0;padding:0;">=20
<c:forEach
items=3D"${status.errorMessages}" var=3D"msg">=20
<li><c:out
value=3D"${msg}"/></li>=20
</c:forEach>=20
</ul>=20
</div>=20
</spring:bind>=20
Here are the code changes in BindTag.java:=20
private boolean showAllErrors =3D false;=20
public void setShowAllErrors(String showAllErrors){=20
CustomBooleanEditor booleanEditor =3D new
CustomBooleanEditor(false);=20
booleanEditor.setAsText(showAllErrors);=20
this.showAllErrors =3D
((Boolean)booleanEditor.getValue()).booleanValue();=20
}=20
protected int doStartTagInternal() throws Exception {=20
//...Previous code=20
if (this.property !=3D null) {=20
fes =3D this.errors.getFieldErrors(this.property);=20
value =3D this.errors.getFieldValue(this.property);=20
editor =3D this.errors.getCustomEditor(this.property);=20
if (isHtmlEscape() && value instanceof String) {=20
value =3D HtmlUtils.htmlEscape((String) value);=20
}=20
}=20
//This is my change=20
else {=20
if(showAllErrors)=20
fes =3D this.errors.getAllErrors();=20
else=20
fes =3D this.errors.getGlobalErrors();=20
}=20
If there are no serious objections, I could commit this.=20
Regards,=20
Dmitriy.=20
|