• 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

Struts 2 validation: how to prevent validation messages from appearing by default

 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

The problem described must be commonplace and surely must have been discussed before. Apologies for bringing it up again.

I have a simple action class named say Hello in struts.xml, and have the validations specified in xml (Hello-validation.xml). The messages come up when invoking Hello. How do we prevent the messages from appearing when invoking 'hello.action'? They should appear only when the user posts the form.

Read somewhere that S2 will ensure this when the action class returns INPUT. That does not seem to work. A bit curious about the best practice to follow here...
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Posting to the form shouldn't be handled by the same means used to reach the form initially. Either display the form via the action's input() method (validation is bypassed for a small list of action methods), or display the form initially through a different action definition.

(Or differentiate between GET and POST in an interceptor, and automagically call input() when it's a GET request.)
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic