This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes Struts and the fly likes Finding ActionForm errors in Action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Finding ActionForm errors in Action" Watch "Finding ActionForm errors in Action" New topic
Author

Finding ActionForm errors in Action

Tavia Young
Ranch Hand

Joined: Mar 15, 2004
Posts: 31
Hi Everyone,

I have an ActionForm which makes use of the Struts Validator and adds errors to an ActionErrors object. I am wondering if it is possible to detect the presence of these errors when Struts redirects back to the input Action.

Thanks very much!
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Struts does not redirect to an input action.

If validate is set to true in the actionmapping and validation returns errors, the action never gets called and the request gets forwarded to the page defined in the input attribute (which is typically the same as the page that submitted the form).

If you really need some extra functionality, there's a way around it.

Be specific what you wish to accomplish and I'll be more than happy to help out.


A good workman is known by his tools.
Tavia Young
Ranch Hand

Joined: Mar 15, 2004
Posts: 31
Thanks for the clarification, Marc. I should have better explained what I would like to do. If validate is set to "true" and the validation returns errors, is it possible to detect for the presence of such errors in the Action class defined in the input attribute? Thanks again for your help!
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Well, again... usually input is a jsp or tile, not an action.

Buuuuut, if you really want it to hit an action I suppose that's cool too.

request.getAttribute(org.apache.struts.Globals.ERROR_KEY)

that will give you the ActionErrors object.
Tavia Young
Ranch Hand

Joined: Mar 15, 2004
Posts: 31
Super. Thanks again, Marc!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Finding ActionForm errors in Action