Hi Martin,

Thanks for your help.  That worked but I had to do a few extra things such
as setting the values for '${label0}', etc.  What I don't get is why do we
need to do this extra thing for Form validation classes (extending
AbstractFormValidator) but not for component validation classes
(implementing IValidator).



For others who may face the same problem, this is how got it working:


        @Override
        public void validate(Form<?> form) 
        {
                Date fromDate = fromDateFormComponent.getConvertedInput();
                Date toDate = toDateFormComponent.getConvertedInput();

                if (    fromDate != null
                         && toDate != null
                         && fromDate.after(toDate))
                {                                 
                        ClassStringResourceLoader loader = new
ClassStringResourceLoader(FromDateBeforeToDate.class);
                
Application.get().getResourceSettings().getStringResourceLoaders().add(loader);
                        
                        ValidationError error = new ValidationError();
                        error.addMessageKey(getClass().getSimpleName() + "." +
"fromDateAfterToDate");
                        error.setVariable("label0",
fromDateFormComponent.getLabel().getObject());
                        error.setVariable("label1", 
toDateFormComponent.getLabel().getObject());
                        
                        fromDateFormComponent.newValidatable().error(error);    
                
                }               
        }



 FromDateBeforeToDate.properties 

FromDateBeforeToDate.fromDateAfterToDate=Invalid input: The '${label}' date
is after the '${label}' date


I thank you again for teh quick and helpful response.



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/FormValidators-and-messages-property-file-tp4667767p4667783.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to