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]