A Techno Blog, mainly about Java


The page I am working on uses struts which means a validate method as well. So, I thought I should get a better understand the ActionError and ActionErrors classes. Note that these two classes are in the org.apache.struts.action package. I found this article.

The ActionError contains two pieces of information. A key and a value. The key is a string , and the value is an array of replacement values (i.e. error messages).

The ActionErrors stores a collection of ActionError objects. You add objects using its add method which stores the object in an internal hashmap. You pass in a property name and the ActionError object. The property name is just a property name or ActionErrors.GLOBAL_ERROR

The article is old, so I did run into some deprecations.

Here is a jsp snippet:

ActionErrors e = (ActionErrors) request.getAttribute(org.apache.struts.Globals.ERROR_KEY);
if ( e!=null && !e.isEmpty()){
out.println(e.size() + “errors(s) found”);
Iterator detail = e.get();
while (detail.hasNext()){
org.apache.struts.action.ActionError ae = (org.apache.struts.action.ActionError);
String s = ae.getKey();
String x = (String) (ae.getValues()) [0];
out.println(“-” + x + “br”);


October 7, 2004 - Posted by | Struts

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: