Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 33791 invoked from network); 12 Jan 2004 18:41:36 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 12 Jan 2004 18:41:36 -0000 Received: (qmail 73133 invoked by uid 500); 12 Jan 2004 18:41:24 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 72963 invoked by uid 500); 12 Jan 2004 18:41:23 -0000 Mailing-List: contact commons-user-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Users List" Reply-To: "Jakarta Commons Users List" Delivered-To: mailing list commons-user@jakarta.apache.org Received: (qmail 72950 invoked from network); 12 Jan 2004 18:41:22 -0000 Received: from unknown (HELO mail.safehost.us) (65.113.114.210) by daedalus.apache.org with SMTP; 12 Jan 2004 18:41:22 -0000 Received: (qmail 18177 invoked from network); 12 Jan 2004 18:41:24 -0000 Received: from unknown (HELO ?10.40.210.143?) (66.0.217.115) by 0 with SMTP; 12 Jan 2004 18:41:24 -0000 Mime-Version: 1.0 (Apple Message framework v609) In-Reply-To: <513F1D9DFA0CD311BC5B0008C773DC5F03453AF3@moscow.sri.srg-ssr.ch> References: <513F1D9DFA0CD311BC5B0008C773DC5F03453AF3@moscow.sri.srg-ssr.ch> Content-Type: multipart/alternative; boundary=Apple-Mail-41--1011031708 Message-Id: <08FDD2D4-452F-11D8-877B-000A95A5C6F4@duocash.com> From: Juan Alvarado Subject: Re: Validator: Using stand-alone validation fails Date: Mon, 12 Jan 2004 13:42:12 -0500 To: "Jakarta Commons Users List" X-Mailer: Apple Mail (2.609) X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N --Apple-Mail-41--1011031708 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Actually, please disregard my last post. Why don't you just use the regular commons-validator package. import org.apache.commons.validator.*; import org.apache.commons.validator.util.*; public boolean isValidEmailAddress(String email){ EmailValidator val = EmailValidator.getInstance(); return val.isValid(email); } That's what I used when I needed to do an email validation in standalone mode. I would be curious if anyone has a better suggestion. Thanks On Jan 12, 2004, at 1:23 PM, Eric.Lewis@swissinfo.ch wrote: > Hi > > I'm new to this list, so please forgive any stupid questions :-)) > > I'm trying to use the Struts Validator for a stand-alone (non-Struts) > class. > I used the ValidatorLoader from "Programming Jakarta Struts" > (O'Reilly), and > it works up to a point. When I try to validate an e-mail address which > is > correct, my code works. However, when I try to validate an invalid > e-mail > address, I get the following Exception: > > > ERROR - reflection: null [12 Jan 2004 18:05:05,984] @ > org.apache.commons.validator.Validator > java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja > va:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso > rImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at > org.apache.commons.validator.Validator.validateFieldForRule(Validator.j > ava:4 > 54) > at > org.apache.commons.validator.Validator.validateField(Validator.java: > 544) > at > org.apache.commons.validator.Validator.validate(Validator.java:582) > at > ch.xobix.validation.model.ValidateBp.processObject(ValidateBp.java:105) > at > ch.xobix.core.model.BaseWithoutConnectionBp.runBp(BaseWithoutConnection > Bp.ja > va:38) > at > ch.xobix.validation.model.ValidationBpImpl.validate(ValidationBpImpl.ja > va:82 > ) > at > ch.xobixtest.validation.model.ValidationBpTest.testValidationFramework( > Valid > ationBpTest.java:73) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.ja > va:39 > ) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccesso > rImpl > .java:25) > at java.lang.reflect.Method.invoke(Method.java:324) > at junit.framework.TestCase.runTest(TestCase.java:154) > at junit.framework.TestCase.runBare(TestCase.java:127) > at junit.framework.TestResult$1.protect(TestResult.java:106) > at junit.framework.TestResult.runProtected(TestResult.java:124) > at junit.framework.TestResult.run(TestResult.java:109) > at junit.framework.TestCase.run(TestCase.java:118) > at junit.framework.TestSuite.runTest(TestSuite.java:208) > at junit.framework.TestSuite.run(TestSuite.java:203) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteT > estRu > nner.java:392) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRu > nner. > java:276) > at > org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestR > unner > .java:167) > Caused by: java.lang.NullPointerException > at > org.apache.struts.validator.Resources.getMessageResources(Resources.jav > a:150 > ) > at > org.apache.struts.validator.Resources.getActionError(Resources.java: > 222) > at > org.apache.struts.validator.FieldChecks.validateEmail(FieldChecks.java: > 780) > ... 26 more > > > My validation.xml file looks like this: > > > "-//Apache Software Foundation//DTD Commons Validator Rules > Configuration 1.0//EN" > "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd"> > > > > > > >
> depends="required,email" /> > >
> >
> > > and my validator-rules.xml looks like this (excerpt): > > ... > > classname="org.apache.struts.validator.FieldChecks" > method="validateEmail" > methodParams="java.lang.Object, > org.apache.commons.validator.ValidatorAction, > org.apache.commons.validator.Field, > org.apache.struts.action.ActionErrors, > javax.servlet.http.HttpServletRequest" > depends="" > msg="errors.email"> > > ... > > > However, from what I can see, the Resource file for errors.email can't > be > found. Is that right? > I have a resource file ApplicationResources.properties which is in a > package. Could this be the problem? Also, how can I specify a certain > Properties file to the Validator? > > Any help is very appreciated! > > Eric > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org > For additional commands, e-mail: commons-user-help@jakarta.apache.org > > --Apple-Mail-41--1011031708--