This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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
 
Similar Threads
problems validation.xml in struts 2
Struts2:Conditional visitor validator not conditional
validation in struts2
problems in validation part of struts 2
Struts 2 visitor validation not able to get any error message