Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to print Global errors only with form:errors?

In my form, i have some specific targeted errors (with path="myField") and i'd like to throw global errors, because they span multiple fields.

But if i use <form:errors path="*">, it will print global AND re-print local errors !

How can i print only the global ones ?

like image 956
Maxime ARNSTAMM Avatar asked Jan 14 '11 14:01

Maxime ARNSTAMM


2 Answers

As far as I remember, you need to use <form:errors /> without path attribute to do it.

like image 163
axtavt Avatar answered Nov 15 '22 19:11

axtavt


I am not sure about using form tag to do that. But Errors object has methods to getglobalerrors.

EDIT

    <spring:hasBindErrors name="input">
            <c:forEach items="${errors.globalErrors}" var="errorMessage">
                <div id="errors" class="errors">
                        <c:out value="${errorMessage.defaultMessage}" />
                </div>
            </c:forEach>
    </spring:hasBindErrors>
like image 5
Teja Kantamneni Avatar answered Nov 15 '22 17:11

Teja Kantamneni