aspose file tools*
The moose likes Struts and the fly likes Visitor Validator with a variable context Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Visitor Validator with a variable context" Watch "Visitor Validator with a variable context" New topic
Author

Visitor Validator with a variable context

Kev Adams
Greenhorn

Joined: Oct 27, 2009
Posts: 23
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

Joined: Oct 27, 2009
Posts: 23
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Visitor Validator with a variable context