• 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

struts2:Validate specific method in an action(through xxx-validation.xml or Vlidation Annotation)

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In an action, there will be lots of methods,"struts2 docs" tells me i can override validateXxx() to validate the specific method in the action.

And also we can use "actionClass-validation.xml" or Vlidation Annotation to validate methods in the action.

question:Can I use these "actionClass-validation.xml" or "Vlidation Annotation" to validate the specific method in the action?

------------------------------------------------

For example:
in the "myStrutsAction",i have 2 methods:"barRegist()" and "fooLogin()", Three parameters:"name","password","age";

in method"barRegist()",i will use these three parameters to regist an User,that i should validate the whole parameters.

in method"fooLogin()",i just only use "name" and "password" for User login, i just have to validate "name" and "password".

----------------------------------------------

Then how can i config the "actionClass-validation.xml" or "Vlidation Annotation" to validate the specific method?

i know "Client Validation" can do this,it just like a basic validation, it can not satisfy my requirement and it can not set a "message".

waiting for your answer~Thanks!
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ivy chen wrote:
question:Can I use these "actionClass-validation.xml" or "Vlidation Annotation" to validate the specific method in the action?


Yes. According to the validation documentation validator configuration files can be named:


* <actionClass>-validation.xml
* <actionClass>-<actionAlias>-validation.xml


With the latter example specific to a particular alias/action method
 
reply
    Bookmark Topic Watch Topic
  • New Topic