tags:

views:

380

answers:

1

I am using Struts2 and a bunch of Validation with Annotations. How do I add a global error message as well on top of field validation errors. Thanks, Fedor

A: 

An action has a collection called fieldErrors as well as a collection called actionErrors. I can't remember if its in the base class ActionSupport, but you can try the method addActionError(String message) and then it will be available along with any field errors.

Keep in mind that action errors are separate from field errors and kept in a different collection. The field errors are in a Map so the UI can match up the error with the field name where as the action errors are just a List I think.

I think there are two UI tags and but you should check the Struts2 tag reference.

Dusty Pearce