• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Finding ActionForm errors in Action

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Super. Thanks again, Marc!
 
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic