On Wed, Nov 16, 2011 at 6:23 PM, Jablow, Eric R <[email protected]> wrote:
>
>
> From: Martin Grigorov [mailto:[email protected]]
>>Hi,
>
>>Looking at the stacktrace I think you should add this line to Wicket's 
>>resource bundle. Just add it to YourApplication.properties and it should be 
>>fine.
>
> I'm a lot closer to fine, now. However, I think I've exposed a usability 
> problem with the net.ftlines.wicket-bean-validation project. I put  the 
> Hibernate validation properties into the WicketTester's application in the 
> test class (since it does not recognize the properties from the surrounding 
> web project):
>
> @BeforeClass
> public static void initValidation() {
>        conf = new ValidationConfiguration();
> }
>
> @Before
> public void initTester() {
>        tester = new WicketTester();
>        WebApplication application = tester.getApplication();
>        List<IStringResourceLoader> stringResourceLoaders = 
> application.getResourceSettings().getStringResourceLoaders();
>        // My custom messages from a project this depends on.
>        stringResourceLoaders.add(new 
> BundleStringResourceLoader("ValidationMessages"));
>        // The messages from the Hibernate Validator jar.
>        stringResourceLoaders.add(new 
> BundleStringResourceLoader("org.hibernate.validator.ValidationMessages"));
>        conf.configure(application);
>        tester.startPanel(NCategoryTestPanel.class);
>        formTester = tester.newFormTester("form");
> }
>
> When this validates a field that violates an @Size(min=3, max=4) annotation, 
> the message that comes out is:
>        size must be between {min} and {max}
>
> The Hibernate validator running on its own interpolates the values of min and 
> max from the annotation, and it would give the error message.
>        size must be between 3 and 4
> I'm verified that in testing of the POJOs and their HibernateValidator. I do 
> have to suggest that the messages somehow be obtained from the Hibernate 
> Validator framework, and not from pure Wicket. Also, the validator can be 
> driven either by annotations or by an XML file, and so one cannot depend on 
> the annotations to actually exist.

Do HibernateValidator provide bundles for all languages ?
I doubt.
Loading those from YourApplication.properties,
YourApplication_xx_YY.properties will be much easier for you.
I guess you can add xx_YY locale by creating your own
org/hibernate/validator/ValidationMessages_xx_YY.properties
but even then if you want to use xml based properties it will become
nasty with \u0123 escapes ...

>
> Respectfully,
> Eric Jablow
>
> This communication, along with any attachments, is covered by federal and 
> state law governing electronic communications and may contain company 
> proprietary and legally privileged information.  If the reader of this 
> message is not the intended recipient, you are hereby notified that any 
> dissemination, distribution, use or copying of this message is strictly 
> prohibited.  If you have received this in error, please reply immediately to 
> the sender and delete this message.  Thank you.
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to