Uploaded image for project: 'Spring Framework'
  1. Spring Framework
  2. SPR-3390

Better error handling from the <form:errors> tag

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 2.0.4
    • Fix Version/s: Waiting for Triage
    • Component/s: Web
    • Labels:
      None
    • Last commented by a User:
      true

      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.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                wshields William Shields
                Last updater:
                Spring Issuemaster
              • Votes:
                20 Vote for this issue
                Watchers:
                14 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Days since last comment:
                  40 weeks, 1 day ago