Hello
I'm trying to plug commons validator.
I didn't manage to find an example of commons-validator standalone.
I have some problems, can anyone help me?
Here is what I try
try {
_resources = ValidatorResourcesInitializer.initialize
("C:/validator/validator.xml");
} catch (IOException e) {
e.printStackTrace();
}
_validator = new Validator(_resources, "ExampleForm");
ExampleForm myForm;
myForm = new ExampleForm();
_validator.addResource(Validator.BEAN_KEY, myForm);
// Get results of the validation.
Map hResults = null;
try {
hResults = _validator.validate().getResultValueMap();
} catch (ValidatorException e) {
e.printStackTrace();
}
if (hResults.get("firstName") == null) {
// no error
} else {
// number of errors for first name int errors =
((Integer)hResults.get("firstName")).intValue();
}
And I get this error :
7 nov. 2003 09:42:54 org.apache.commons.validator.Validator validateFieldForRule
FATAL: reflection: null
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at
org.apache.commons.validator.Validator.validateFieldForRule(Validator.java:454)
at org.apache.commons.validator.Validator.validateField(Validator.java:544)
at org.apache.commons.validator.Validator.validate(Validator.java:582)
at main.Example.InitValidator(toto.java:55)
This message and any attachments (the "message") is intended solely for the addressees
and is confidential.
If you receive this message in error, please delete it and immediately notify the
sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole or partial, is prohibited
except formal approval.
The internet can not guarantee the integrity of this message. BNP PARIBAS (and its
subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le "message") sont etablis a
l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de
le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce message non conforme a sa
destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse.
L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses filiales) decline(nt) toute
responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]