This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Im having some difficulties finding a suitable way to solve my little problem.
I have a form with several fields. This form is validated by several inhouse-built customvalidators and are executed by @Validations annotation on the update() metode of our action class.
Now we are introducing a new radiobutton, and when this radiobutton is set to a specific value there should be no validation of 6 fields in our form.
This seemed quite straight forward, but now im stuck.
Can this problem be easily solved within the annotations? Is there some way to tell the validators not to validate if radiobutton is set to specific value within the annotation?
I couldnt find a way, so i tried a different solution.
My next idea was that I could do an if statement within the prepare() metode. I'll do a check within the prepare, and if the radiobutton is set to no-validation, then i would simply populate the fields myself with some default-values that i knew would validate.
Ok, that should work i though, but the validation still failed. After debugging i found that the values i had set in the prepare() somehow had dissappeared when the customvalidators did their validation. I mean the fields i specificly set to a value in the prepare metode are set back to the values from the form before validation is run.
I'm running out of ideas. Any Struts2 validation gurus have some tips?