File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes struts2:Validate specific method in an action(through xxx-validation.xml or Vlidation Annotation) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts2:Validate specific method in an action(through xxx-validation.xml or Vlidation Annotation)" Watch "struts2:Validate specific method in an action(through xxx-validation.xml or Vlidation Annotation)" New topic
Author

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

Ivy chen
Greenhorn

Joined: Aug 31, 2010
Posts: 16
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!
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8836
    
    7

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


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
 
subject: struts2:Validate specific method in an action(through xxx-validation.xml or Vlidation Annotation)
 
Similar Threads
Struts2 concepts doubts
Struts2 Validation..Need Help
XML Vlidation against a DTD
Struts and Vlidation
Validation Problem in struts2