This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
Hi,
I want to pass a value to my own validation method. Basically i want to do the same thing as mask or minlength where you tell it a variable name and value. Anyone know how i can access a variable defined in this way?
Stu Johns wrote:I want to pass a value to my own validation method.
Which validation method you're using, is it ValidatorForm#validate() method OR Validator Plugin(validator.xml). In former case, you can pass the name=value parameters using 'request' object and accessing them "validate()" method, this is my wild guess and you may not get any success. In later case I don't think we can do this OR I don't know.
Meanwhile, why do you want to this complications ?
I wanted to try and use the validation.xml approach.
It was purely from an educational point of view, I didnt know if it was possible or if the mask validation (and other struts inbuilts) was a special case.
Stu Johns wrote:It was purely from an educational point of view,
Then its OK, you can play around with Struts validator framework. Validation is predefined thing which ensures the data is coming the format we wanted, its not a runtime/user wished thing to do
Stu Johns
Ranch Hand
Joined: Aug 11, 2008
Posts: 63
posted
0
You may have misunderstood the question?
What i'm trying to do was pass a value using the <var-name> and <var-value> tags of <field> in validation-rules.xml
Are you writing a custom validator, or writing a validate() method in your action form? If the latter, then AFAIK you don't have access to anything in the validation config.
If the former, follow the example in the documentation.
hmm hard to do, but there are NO classes I saw in Struts API which can have an access to validatore.xml which returns the <field> element,t still have look at this method, may this methods put some light. OR I don't know much about your requirement
You may be right David, but the thing is I didn't understand the authors requirement, and what I concluded finally was, the author want to get the <var-name> and <var-value> from validator.xml for the specific bean/form.