I don't know about the problem in question but in this case, I was trying to display error messages based on whether a particular field has an error or not.
In this case, since field errors are stored in the fieldErrors
map, specific field errors can be checked using <s:if>
like as follows.
<s:if test="fieldErrors.containsKey('transporterId') or fieldErrors.containsKey('chk') or fieldErrors.containsKey('currentPage')">
<div class="errorblock">
<s:fielderror fieldName="transporterId"/>
<s:fielderror fieldName="chk"/>
<s:fielderror fieldName="currentPage"/>
</div>
</s:if>
This is sufficient to suit my requirements.
This is also possible by using the following simple conditional check as usual.
<s:if test="hasFieldErrors()">
<div class="errorblock">
<s:fielderror fieldName="transporterId"/>
<s:fielderror fieldName="chk"/>
<s:fielderror fieldName="currentPage"/>
</div>
</s:if>
But in this case, I need to check only for a selected fields to see if they have generated some errors and not for all the fields which are submitted by a request. Hence, there is a need to check for all those selected fields (not all) like the first case.
These selected fields are generally hidden fields or query-string parameters.
Any errors generated by them are displayed at one place in a block whereas any errors generated by the rest of the fields like input components such as <s:textfield>
are displayed just beside them.