|
From: Alef A. \(JTeam\) <al...@jt...> - 2003-10-01 13:23:28
|
Seems useful, as long as the default is indeed false it;s ok with me...
By the way, I recently added the transform tag (to also transform
reference data using hte same propertyeditors in the object). I did
_not_ include it in the TLD yet, maybe people want to first check it
out...
alef
-----Oorspronkelijk bericht-----
Van: spr...@li...
[mailto:spr...@li...] Namens
Kopylenko, Dmitry
Verzonden: Wednesday, October 01, 2003 3:01 PM
Aan: 'Spring Developers'
Onderwerp: [Springframework-developer] New addition to BindTag
Hello everyone,
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="${command}">
<div class="error">
<ul style="margin:0;padding:0;">
<c:forEach
items="${status.errorMessages}" var="msg">
<li><c:out
value="${msg}"/></li>
</c:forEach>
</ul>
</div>
</spring:bind>
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="${command}" showAllErrors="true">
<div class="error">
<ul style="margin:0;padding:0;">
<c:forEach
items="${status.errorMessages}" var="msg">
<li><c:out
value="${msg}"/></li>
</c:forEach>
</ul>
</div>
</spring:bind>
Here are the code changes in BindTag.java:
private boolean showAllErrors = false;
public void setShowAllErrors(String showAllErrors){
CustomBooleanEditor booleanEditor = new
CustomBooleanEditor(false);
booleanEditor.setAsText(showAllErrors);
this.showAllErrors =
((Boolean)booleanEditor.getValue()).booleanValue();
}
protected int doStartTagInternal() throws Exception {
//...Previous code
if (this.property != null) {
fes = this.errors.getFieldErrors(this.property);
value = this.errors.getFieldValue(this.property);
editor = this.errors.getCustomEditor(this.property);
if (isHtmlEscape() && value instanceof String) {
value = HtmlUtils.htmlEscape((String) value);
}
}
//This is my change
else {
if(showAllErrors)
fes = this.errors.getAllErrors();
else
fes = this.errors.getGlobalErrors();
}
If there are no serious objections, I could commit this.
Regards,
Dmitriy.
|