|
From: Matt R. <li...@ra...> - 2004-04-30 18:34:48
|
There's nothing like banging your head against the wall trying to figure
something out.
The issue turned out to be that my ApplicationResources file had single
quotes for validation error messages:
errors.invalid='{0}' is invalid.
I had to change it to:
errors.invalid={0} is invalid.
Then everything worked as desired. So, in short, using Commons
Validator with Struts allows this, but using it with Spring does not.
It's easy enough to remove the quotes - but this should probably be
fixed and/or documented.
Matt
> -----Original Message-----
> From: spr...@li...
> [mailto:spr...@li...]
> On Behalf Of Matt Raible
> Sent: Friday, April 30, 2004 4:23 AM
> To: spr...@li...
> Subject: [Springframework-developer] [Commons Validator]
> Messages not resolved
>
>
> I have two apps - one is based on Servlet 2.4 and one on 2.3.
> From what I can tell, all the configuration is the same for
> commons validator. I'm certain that the JARs are the same on
> both projects. Now I'm having a really strange problem. On
> the 2.4 project (done with an XSD in web.xml), the messages
> resolve fine, so if lastName is required, I get "Last Name is
> a required field." If I try the same thing on the 2.3
> project, I get "{0} is a required field." Everything looks
> right for JSTL and all my other messages are getting resolved
> - except for messages from the validation engine. I've
> pasted my relevant config below. I tried manipulating the
> 2.3/2.4 thing too - that didn't help.
>
> Another difference b/w the 2 projects is one uses
> org.springframework.web.servlet.view.JstlView and the 2nd
> (non-working) one uses TilesJstlView.
>
> I'm using the latest stuff from CVS.
>
> Thanks,
>
> Matt
>
> <bean id="userFormController"
> class="org.appfuse.webapp.action.UserFormController">
> ...
> <property name="validator"><ref
> bean="beanValidator"/></property>
> ...
> </bean>
>
> <!-- This file is really named
> ApplicationResources_en.properties to JSTL will pick
> it up as the default. I know it doesn't sound right,
> but it works. I tried
> renaming w/o the extension, no dice. -->
> <bean id="messageSource"
>
> class="org.springframework.context.support.ResourceBundleMessa
> geSource">
> <property
> name="basename"><value>ApplicationResources</value></property>
> </bean>
>
> <bean id="validatorFactory"
> class="org.springframework.validation.commons.DefaultValidator
> Factory"
> init-method="init">
> <property name="resources">
> <list>
> <value>WEB-INF/validation.xml</value>
> <value>WEB-INF/validator-rules.xml</value>
> <value>WEB-INF/validator-rules-custom.xml</value>
> </list>
> </property>
> </bean>
>
> <bean id="beanValidator"
> class="org.springframework.validation.commons.BeanValidator">
> <property name="validatorFactory"><ref
> local="validatorFactory"/></property>
> </bean>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: Oracle 10g
> Get certified on the hottest thing ever to hit the market...
> Oracle 10g.
> Take an Oracle 10g class now, and we'll give you the exam FREE.
> http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
> _______________________________________________
> Springframework-developer mailing list
> Spr...@li...
> https://lists.sourceforge.net/lists/listinfo/springframework-developer
>
|