[SPR-3390] Better error handling from the <form:errors> tag Created: 18/Apr/07  Updated: 15/Jan/19

Status: Open
Project: Spring Framework
Component/s: Web
Affects Version/s: 2.0.4
Fix Version/s: Waiting for Triage

Type: New Feature Priority: Major
Reporter: William Shields Assignee: Unassigned
Resolution: Unresolved Votes: 20
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
is duplicated by SPR-9221 Extend <form:errors> with something l... Resolved
Days since last comment: 43 weeks ago
Last commented by a User: true
Last updater: Spring Issuemaster

 Description   

<form:errors> is a pretty crude mechanism for displaying multiple errors. It uses a default delimieter of <br>. It should allow for more sophisticated methods of displaying errors.

In the simple case, I would like to see "schemes" introduced. For example:

<form:errors path="*" scheme="ul"/>

which would craete:

<ul>
<li>error1</li>
<li>error2</li>
</ul>

Note: if there were no errors the enclosing <ul> tag should not be rendered.

Example schemes could be:

table
ul
ol

Potentially this may require another attribute to distinguish between the CSS class given to the enclosing tags and that given to each element, although if the enclosing tag got the value of cssClass, a CSS selector could resolve that problem without adding an attribute.

In the more complicated example, it is possibly worthwhile (although arguably unnecessary if you have sufficient schemes as defined above) to allow either the programmer to write their own schemes or to have sufficient attributes to achieve the same thing.

Example:

<form:scheme name="errorTable">

<form:pre>
<table>
<tr>
<th>Error #</th>
<th>Error Description</th>
</tr>
</form:pre>

<form:loop var="count">
<tr>
<td><c:out value="${count}"/></td>
<td><form:error/></td>
</tr>
</form:loop>

<form:post>
</table>
</form:post>

</form:scheme>

The simple example of this kind of thing would be adding attributes:

<form:errors path="*" block="ul" item="li"/>

alternatively have a heading block within:

<form:errors path="*" block="ul" item="li">
<p>The following errors have occurred:</p>
</form:errors>

Anywa, you get the idea.



 Comments   
Comment by Rick Evans [ 10/Jul/07 ]

(For my own reference.)

http://cwiki.apache.org/WW/themes-and-templates.html

Comment by Rick Evans [ 10/Jul/07 ]

Hi William

I agree that <form:errors/> is a pretty coarse mechanism for displaying errors. The delimiter between individual errors can now be controlled (see the Javadoc), but it is nowhere near as flexible as you'd like.

I am not going to have enough time to address this myself in the 2.1 timeframe though. I'm going to have to let this one slip to a later release... I guess it needs to accrue more votes before it becomes a priority.

Cheers
Rick

Comment by Spring Issuemaster [ 14/Jan/19 ]

The Spring Framework has migrated to GitHub Issues. Please visit spring-projects/spring-framework#8073 for further activity, or to subscribe to receive notifications.

Generated at Tue Nov 12 00:25:04 UTC 2019 using Jira 7.13.8#713008-sha1:1606a5c1e7006e1ab135aac81f7a9566b2dbc3a6.