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 Validation in struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Validation in struts 2" Watch "Validation in struts 2" New topic
Author

Validation in struts 2

pallavi bawa
Greenhorn

Joined: May 22, 2014
Posts: 1

In struts2, I want to validate address 1 input value on 4 different pages. I dont want to copy the regex in 4 different action_name-validation.xml. Can I create a global validation.xml where I can define a variable and is use it in other action_name-validation.xml files? Please provide an example.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8876
    
    8

Welcome to the JavaRanch.
The best solution would be to create your own validator and use it in your XML files where necessary. Here is a tutorial but I've never done this myself, so I can't speak to how good the tutorial is.
Personally, when I have to do anything more complex than a make sure a required field is filled in, I use the Validateable interface (built in to ActionSupport) and do the validation programmatically.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Validation in struts 2