On 5/25/06, Yildiz Terkesli <[EMAIL PROTECTED]> wrote:
Hi,
I am using Apache Struts and Validator framework for
my current project. I have encountered this problem
when I tried to create my own validation rule:
I want to validate a field against another field. For
this purpose I have created my own validation method,
created new XML file instead of changing the original
validator-rules.xml file, and updated validation.xml
file. Everything has been fine so far. I have
configured validation for the new rule in
validation.xml as follows:
<field property="priority" depends="urgency">
<arg0 key="prompt.urgency"/>
<var>
<var-name>explainUrgency</var-name>
<var-value>urgency</var-value>
</var>
</field>
Here, the name of first field is "priority" and the
second is "urgency".
When I use:
String explainUrgency =
field.getVarValue("explainUrgency");
in my own validation method to get the real value of
the field urgency, I get the text "urgency". What
should I do to get the value of the field "urgency" in
the form?
Typically you would use the <var> element if you wanted to make the
name of the second field "configurable" and then use the configured
property name along with introspection to get the value from the
ActionForm.
If for this rule the field is always going to be "urgency" then you
don't need to use a <var> element at all - just access the property
directly from the ActionForm passed to your validation method.
Niall
Any help is appreciated.
Thanks
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]