This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Struts and the fly likes struts 2 validation problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "struts 2 validation problem" Watch "struts 2 validation problem" New topic
Author

struts 2 validation problem

vydehi vajanapally
Greenhorn

Joined: Mar 02, 2009
Posts: 9
i have a XYZ form with two radio buttons. when we click first radio button some of the fileds will be displayed and those are mandatory fields which we have to enter.
when i select second radio button some other field will be displayed on the same page, and in this we have some fields as mandatory.

I am using Action-validation.xml method to do validations.
When i submit the XYZ form, it will go to the same action class and it will validate with the same action-validation for both radio button clicks.

Now when i click on first radio button(there are no second radio button related fileds displayed),
it is giving problem with validation, because i mentioned the second radio button fileds also mandatory in the validation.xml

Could you sujjest me any solution to come out from this?

Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

You'll have to use non-field validators and create an expression which will check the value of the radio button with the value of the field. If the radio button isn't checked, the field would not be validated (there might be an easier solution but this is the solution that I know of)...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: struts 2 validation problem