File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes ActionErrors or ActionMessages ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "ActionErrors or ActionMessages ?" Watch "ActionErrors or ActionMessages ?" New topic

ActionErrors or ActionMessages ?

Ja vardhan
Ranch Hand

Joined: May 09, 2005
Posts: 169

Whats the differance between ActionErrors and ActionMessages ?
When we go for ActionErrors and when we go for ActionMessages ?

In some validator-rules.xml files I have seen passing ActionErrors and in some files I have seen ActionMessages.

Pls tell me what would happen in both the cases..

Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Since ActionErrors is a subclass of ActionMessages, any method that requires an ActionMessages parameter can be passed an ActionErrors object and it will be automatically cast to an ActionMessages object.

There's very little difference between the two, and for the most part they can be used interchangeably.

Consultant, Sima Solutions
Ja vardhan
Ranch Hand

Joined: May 09, 2005
Posts: 169

Thanks for replying my queries..

In my application, I have written Java class for custom validation and validate method is like this:

And I am passing ActionErrors from validator-rules.xml like this:

But in my validate method ActionErrors is coming as null.
If I use ActionMessages its working fine.

Whats the problem with ActionErrors?

M Sharma
Ranch Hand

Joined: Dec 13, 2001
Posts: 106
Hi Javardhan,

I faced similar problem and got a solution to it.

You can view the solution at

Regards, Manish
SCJP 1.4
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: ActionErrors or ActionMessages ?
jQuery in Action, 3rd edition