File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts2:Conditional visitor validator not conditional 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 "Struts2:Conditional visitor validator not conditional" Watch "Struts2:Conditional visitor validator not conditional" New topic
Author

Struts2:Conditional visitor validator not conditional

Kev Adams
Greenhorn

Joined: Oct 27, 2009
Posts: 23
I'm having a little trouble with the "conditionalvisitor" validator in Struts2. The "conditionalvisitor" validator is supposed to redirect the validation to the model, based on a condition. In my case, it is performing both sets of validation. This is causing false validation errors in my form.

My form has two radio buttons like so:



The "enableSingle()" and "enableMultiple()" call javascript functions to enable the fields of the radio button that is currently selected and disable the fields of the button that is not selected.

I'm using the ModelDriven approach and I have a single CRUD action (a la the Struts 2 In Action book). Inside that action, I have a "save" method, and my action alias looks like "CrudAction-save-validation.xml"

Here is the snippet from my CrudAction-save-validation.xml.



Normally, I'd never use the "==" to compare two strings, but this is how it is described on the Struts2 site here

I'm running this on a Websphere 6.1 server.

Has anyone encountered this before, and if so, what did you do? Unfortunately, there's not a lot of information about the "conditionalvisitor" validator from Google searches.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Struts2:Conditional visitor validator not conditional
 
Similar Threads
Struts2 conversion/validation problem
Struts2 & validation [SOLVED]
validation in struts2
Multiple field validation in Struts2 Validation using validation.xml file
Visitor Validator with a variable context