commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "O'Shea, Sean" <Sean.O'S...@fmr.com>
Subject [commons-validator] msg tag and validwhen validator
Date Mon, 11 Sep 2006 13:33:51 GMT
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* &gt; 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* &gt; 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


Mime
View raw message