Re: generic validator questions
right now you have a few choices: you can load that .properties file yourself from inside your validator you can put these properties into application-scoped .properties file. you can also add an rfe into our jira to allow validators to have their own .properties bundles. -igor On 8/18/07, Stojce Dimski [EMAIL PROTECTED] wrote: Hi I am new to wicket and during my studying phase (1.3b2) I wrote a small validator for my pilot project. Validator checks that class indicated by some control implements specified interface or is subclass of specified class. It works like charm. But I have a big problems locating the messages for display purposes. What is the correct way to make a _generic_ validator (like 'PatternValidator') not tied to any form and specify his messages in some .properties file ??? Can some kind soul enlight me ? import org.apache.wicket.validation.*; import org.apache.wicket.validation.validator.*; public class ClassValidator extends AbstractValidator { private static final long serialVersionUID = 1L; private final Class ? validClass; public ClassValidator (final Class ? validClass) { this.validClass = validClass; } @Override protected void onValidate (final IValidatable validatable) { final String validatableClassName = (String) validatable.getValue(); try { final Class ? validatableClass = Class.forName(validatableClassName); final Object validatableInstance = validatableClass.newInstance(); if (!validClass.isInstance(validatableInstance)) error(validatable, notValid); } catch (ClassNotFoundException problem) { error(validatable, notFound); } catch (InstantiationException problem) { error(validatable, instantiation); } catch (IllegalAccessException problem) { error(validatable, illegalAccess); } } } ___ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: generic validator questions
Hi Igor The error message says: Could not locate error message for error: [org.apache.wicket.validation.ValidationError message=[null], keys=[notFound, ClassValidator], variables=[]] notFound - is my key ClassValidator - is the name of the class the .propeties file is together with .class file and and have identical names... inside .properties i have a row like this: ClassValidator.notFound=${input} cannot be found on a classpath. What is wrong with this ? Thanks, Stojce ___ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: generic validator questions
On 8/18/07, Stojce Dimski [EMAIL PROTECTED] wrote: Hi Igor The error message says: Could not locate error message for error: [org.apache.wicket.validation.ValidationError message=[null], keys=[notFound, ClassValidator], variables=[]] the problem looks like is that its looking for a notFound key or a ClassValidator key, not for a ClassValidator.notFound key. so just adjust your code. -igor notFound - is my key ClassValidator - is the name of the class the .propeties file is together with .class file and and have identical names... inside .properties i have a row like this: ClassValidator.notFound=${input} cannot be found on a classpath. What is wrong with this ? Thanks, Stojce ___ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: generic validator questions
Hi Igor, First thing, thanks, your hints gave me the direction and I solved the issue... I like the approach 'Classname.Key' and I think it's right for this category of generic validators as are those in 'validator' package. It was just a question of overriding one method: @Override public void error (final IValidatable validatable, final String resourceKey) { super.error(validatable, resourceKey() + . + resourceKey); } and everything worked like a charm ;-) What do you think of adding this validator in trunk ? Cheers, Stojce ___ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: generic validator questions
im not sure exactly what your usecase is. we have something that is kind of similar, namely new TextField(number, Integer.class); which would type convert the entered string into an Integer and error out if the conversion could not be performed. but i dont think this is the exact match to whatever it is you are trying to achieve. -igor On 8/18/07, Stojce Dimski [EMAIL PROTECTED] wrote: Hi Igor, First thing, thanks, your hints gave me the direction and I solved the issue... I like the approach 'Classname.Key' and I think it's right for this category of generic validators as are those in 'validator' package. It was just a question of overriding one method: @Override public void error (final IValidatable validatable, final String resourceKey) { super.error(validatable, resourceKey() + . + resourceKey); } and everything worked like a charm ;-) What do you think of adding this validator in trunk ? Cheers, Stojce ___ L'email della prossima generazione? Puoi averla con la nuova Yahoo! Mail: http://it.docs.yahoo.com/nowyoucan.html - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]