You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by "O'Shea, Sean" <Se...@fmr.com> on 2006/09/11 15:33:51 UTC
[commons-validator] msg tag and validwhen validator
Hi all,
I have a situation where I need to get the run-time value of a field and
display it should a validation error occur.
Taking the validwhen example from the struts sample application:
<field property="max" depends="required,integer,validwhen">
<arg key="validWhenForm.max" position="0"/>
<msg name="validwhen" key="validWhenForm.error.numeric" />
<var>
<var-name>test</var-name>
<var-value>(*this* > min)</var-value>
</var>
</field>
I need to be able to display something like "The max field cannot be
less than 12".
In order to do this I guess I need my validWhenForm.error.numeric
resource entry to look something like this: The {0} field cannot be less
than {1}
What I'm stuck at though is how to get the run-time minimum value into
an argument. I tried this
<field property="max" depends="required,integer,validwhen">
<arg key="validWhenForm.max" position="0"/>
<arg name="validWhenForm.min" position="1" resource="false"
key="${var:min}"/>
<msg name="validwhen" key="validWhenForm.error.numeric" />
<var>
<var-name>test</var-name>
<var-value>(*this* > min)</var-value>
</var>
<var>
<var-name>min</var-name>
<var-value>min</var-value>
</var>
</field>
But all I get displayed is "The Maximum field cannot be less than null"
Any ideas on this would be greatly appreciated
Thanks
Sean O Shea
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org