Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Finding ActionForm errors in Action

 
Tavia Young
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tavia Young
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Super. Thanks again, Marc!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic