Win a copy of Spark in Action this week in the Open Source Projects forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Visitor Validator with a variable context

 
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.
 
See where your hand is? Not there. It's next to this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic