Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Visitor Validator with a variable context

 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible in Struts 2 to set up the visitor validator with a ModelDriven action to have a variable context parameter, like so:



I tried this code and I created a "public String getMyContext()" method in my action. However, the method never got called. I don't know if the the context has to be explictly defined or not, and I haven't been able to find anything about it after searching the web.

The goal is to to have some conditional validation at the model level. For instance, say you were creating a new employee. You might have a radio button on your page that let you choose whether you were entering an American street address or a Canadian street address, and you'd want to validate the addresses differently. In addition, you wouldn't want to make any of the American street address fields required because they'd all be blank when you hit the submit button.

Using this, I could return a context of "american" or "candian" and have a Employee-american-validation.xml file and a Employee-canadian-validation.xml file.

Any help would be appreciated.
 
Kev Adams
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does anyone have any information on this, or, do I need to give some other information to help anyone out?

Any help would be appreciated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic