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.

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.

Reply via email to