Struts only differentiates the two message types, so you would have to pick one of your three categories and arrange for those messages to be stored under a different key. You'd then need to use something other than the html:messages tag to display them, since that tag only knows about the two message types supported by Struts.

A possible alternative might be to use the message key as the differentiator, if you can ensure that (a) all validation errors use a field-name key and all non-validation errors use ActionMessages.GLOBAL_MESSAGE.

L.

Rick Reumann wrote:
Struts 1.1..

How would I display validation messages different than other standard
messages that I want to display? I'm using a common messages header,
but I'd like to modify it so that I could display errors differently.
It probably has to do with how I'm saving messages...

For example for Validation errors:

//validation
errors.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("errors.req", "Something"));
saveErrors(request, errors);

//display a success message
messages.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("message.update.success", person.getName()));
saveMessages(request, messages);

The problem is I'm doing the same thing for other types of errors as well:

//display and error message of update of person failed
errors.add(ActionMessages.GLOBAL_MESSAGE, new
ActionMessage("errors.update.failed", person.getName()));
saveErrors(request, errors);

Everything is fine between success messages, but I'd like to be able
to display my validation errors differenty.. for example below I'm
using a <li> but maybe for regular error messages I don't want to use
a list. What's the best way to save different type of messages .. I'll
only have three.. validationErrors, regularErrors, and
successMessages.

Here is my common page header for the display...

<div id="messageSection">
        <c:if test='${ !empty
requestScope["org.apache.struts.action.ACTION_MESSAGE"] }'>
            <html:messages id="msg" message="true">
                <span class="message"><c:out value="${msg}"
escapeXml="true"/></span><br/>
            </html:messages>
        </c:if>
        <c:if test='${ !empty requestScope["org.apache.struts.action.ERROR"] }'>
            <ul class="listError">
            <html:messages id="error" message="false">
                <li><c:out value="${error}" escapeXml="true"/></li>
            </html:messages>
            </ul>
        </c:if>
</div>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to