<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=marceloverdijk" rel="nofollow">Marcel Overdijk</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9221?redirect=false" rel="nofollow">SPR-9221</a></strong> and commented</p>
<p dir="auto">It would be nice to add more flexibility to the form:errors tag.<br>
E.g. to render something like</p>
<p dir="auto">&lt;ul&gt;<br>
&lt;li&gt;error1&lt;/li&gt;<br>
&lt;li&gt;error2&lt;/li&gt;<br>
&lt;ul&gt;</p>
<p dir="auto">With element="ul" a part can be implemented but the &lt;li&gt; element is not possible.<br>
The delimiter attribute just outputs it content after eacht error.</p>
<p dir="auto">Maybe the form:errors tag can be extended with something like errorElement or itemElement indicating a wrapper element for the each error.</p>
<p dir="auto">Something like this:</p>
<p dir="auto">&lt;form:errors path="*" element="ul" errorElement="li" /&gt;</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398077274" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/8073" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/8073/hovercard" href="https://github.com/spring-projects/spring-framework/issues/8073">#8073</a> Better error handling from the form:errors tag (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=wshields" rel="nofollow">William Shields</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-3390?redirect=false" rel="nofollow">SPR-3390</a></strong> and commented</p>
<p dir="auto">form:errors is a pretty crude mechanism for displaying multiple errors.  It uses a default delimieter of &lt;br&gt;.  It should allow for more sophisticated methods of displaying errors.</p>
<p dir="auto">In the simple case, I would like to see "schemes" introduced.  For example:</p>
<p dir="auto">&lt;form:errors path="*" scheme="ul"/&gt;</p>
<p dir="auto">which would craete:</p>
<p dir="auto">&lt;ul&gt;<br>
&lt;li&gt;error1&lt;/li&gt;<br>
&lt;li&gt;error2&lt;/li&gt;<br>
&lt;/ul&gt;</p>
<p dir="auto">Note: if there were no errors the enclosing &lt;ul&gt; tag should not be rendered.</p>
<p dir="auto">Example schemes could be:</p>
<p dir="auto">table<br>
ul<br>
ol</p>
<p dir="auto">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.</p>
<p dir="auto">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.</p>
<p dir="auto">Example:</p>
<p dir="auto">&lt;form:scheme name="errorTable"&gt;</p>
<p dir="auto">form:pre</p>
<p dir="auto">&lt;table&gt;<br>
&lt;tr&gt;<br>
&lt;th&gt;Error #&lt;/th&gt;<br>
&lt;th&gt;Error Description&lt;/th&gt;<br>
&lt;/tr&gt;<br>
&lt;/form:pre&gt;</p>
<p dir="auto">&lt;form:loop var="count"&gt;</p>
<p dir="auto">&lt;tr&gt;<br>
&lt;td&gt;&lt;c:out value="${count}"/&gt;&lt;/td&gt;<br>
&lt;td&gt;&lt;form:error/&gt;&lt;/td&gt;<br>
&lt;/tr&gt;<br>
&lt;/form:loop&gt;</p>
<p dir="auto">form:post</p>
<p dir="auto">&lt;/table&gt;<br>
&lt;/form:post&gt;</p>
<p dir="auto">&lt;/form:scheme&gt;</p>
<p dir="auto">The simple example of this kind of thing would be adding attributes:</p>
<p dir="auto">&lt;form:errors path="*" block="ul" item="li"/&gt;</p>
<p dir="auto">alternatively have a heading block within:</p>
<p dir="auto">&lt;form:errors path="*" block="ul" item="li"&gt;</p>
<p dir="auto">&lt;p&gt;The following errors have occurred:&lt;/p&gt;<br>
&lt;/form:errors&gt;<br>
Anywa, you get the idea.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 2.0.4</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398117956" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13859" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13859/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13859">#13859</a> Extend form:errors with something like errorElement (<em><strong>"is duplicated by"</strong></em>)</li>
</ul>
<p dir="auto">20 votes, 14 watchers</p>