Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Validation in struts 2

 
pallavi bawa
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Pie
Posts: 9264
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic