struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Laurie Harper <lau...@holoweb.net>
Subject Re: acessing form values in validation.xml
Date Wed, 09 Jan 2008 23:02:10 GMT
Sivaswamynatha K wrote:
> Hi,
> 
>  
> 
> Is it possible to access the form variables in the validation.xml file.
> I am using Struts 1.2.9
> 
> Ie. I have a requirement to enter the year field between 1800 to current
> year + years.
> 
>  
> 
> In validation.xml
> 
> <field property="builtYear" depends="mask,validwhen">
> 
> <msg resource="true" key="errors.builtYear" name="validwhen" />
> 
>       <msg resource="true" key="errors.mask" name="mask" />
> 
>       <arg position="0" key="label.mortgageinfo.builtyear" />
> 
> ????<arg position="1" ?/>                       
> 
>                         
> 
>       <var>
> 
>             <var-name>mask</var-name>
> 
>             <var-value>${year}</var-value>
> 
>       </var>
> 
>       <var>
> 
>             <var-name>test</var-name>
> 
>             <var-value>((builtYear == null) or ((builtYear >1800) and
> (builtYear &lt; futureYear)))</var-value>
> 
>       </var>                        
> 
> </field>
> 
>  
> 
> I set the value of futureYear is action and it changes according to the
> current year. The validation is fine. Now I want to show the error
> message when the validation fails.
> 
> The error is just like 
> 
> 'The built year ranges between 1800 and <customizedvalue>'
> 
>  
> 
> In message resources 
> 
> errors.builtYear= The {0}  ranges between 1800 and {1}

So what's your question? How to pass in a value for {1}? i.e. what to 
put for the <arg> tag with position="1"? You just need to pass the value 
of futureYear, no?

   <arg position="1" ressource="false" key="futureYear"/>

or possibly key="formName.futureYear" or something, I'm not sure if it 
needs to be fully qualified or not.

L.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message