Return-Path: Delivered-To: apmail-jakarta-commons-user-archive@www.apache.org Received: (qmail 35379 invoked from network); 11 Nov 2003 17:02:26 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 11 Nov 2003 17:02:26 -0000 Received: (qmail 48287 invoked by uid 500); 11 Nov 2003 17:02:16 -0000 Delivered-To: apmail-jakarta-commons-user-archive@jakarta.apache.org Received: (qmail 48129 invoked by uid 500); 11 Nov 2003 17:02:15 -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 48103 invoked from network); 11 Nov 2003 17:02:15 -0000 Received: from unknown (HELO web20706.mail.yahoo.com) (216.136.226.179) by daedalus.apache.org with SMTP; 11 Nov 2003 17:02:15 -0000 Message-ID: <20031111170218.21929.qmail@web20706.mail.yahoo.com> Received: from [32.97.110.142] by web20706.mail.yahoo.com via HTTP; Tue, 11 Nov 2003 09:02:18 PST Date: Tue, 11 Nov 2003 09:02:18 -0800 (PST) From: David Graham Subject: Re: Validator Exception To: Jakarta Commons Users List In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 Comment out all of your validation code except for the call to super.validate(). If the exception is not thrown the error is in your code. If it's still throwing the exception, comment out all of your xml rules for the form and test one of them at a time until you find the rule that is throwing the exception. David --- Srinivas Gunturu wrote: > Here is the validate code. I am not event seeing "Validate 1" in my > console output as is the first line in my validate method. Makes me > think, my validation rules xml might be throwing this exception. I have > enclosed my validation rules too. > > public ActionErrors validate(ActionMapping mapping, > HttpServletRequest request) { > > > // if (Constants.CLEAR.equals(request.getParameter("submitField"))) > return new ActionErrors(); > > System.out.println("Validate 1"); > HttpSession session = request.getSession(); > SafetyEvent safetyEvent = ((SafetyEvent) > session.getAttribute(Constants.EVENT_BEAN_KEY)); > > > // Perform validator framework validations > ActionErrors errors = super.validate(mapping, request); > System.out.println("Validate 1.1"); > > if ( safetyEvent == null || > safetyEvent.getSafetyEventID() == null || > safetyEvent.getSafetyEventID().intValue() <= 0 ) { > if ( getEventDetailBean().getSourceCode() != null && > ("141".equals(getEventDetailBean().getSourceCode().toString()) || > "1337".equals(getEventDetailBean().getSourceCode().toString())) ) > { > errors.add(ActionErrors.GLOBAL_ERROR, new > ActionError("error.eventdetail.invalidSource")); > } > } > System.out.println("Validate 2"); > //Determine if eventDateTime is greater than reportedDateTime. > String eventDateTime = null; > if (eventDetailBean.getEventDate() != null) > { > eventDateTime = eventDetailBean.getEventDate(); > if (GenericValidator.isBlankOrNull(eventDetailBean.getHour())) > { > eventDateTime += " 00"; > } else { > eventDateTime += " " + eventDetailBean.getHour(); > } > if (GenericValidator.isBlankOrNull(eventDetailBean.getMin())) > { > eventDateTime += ":00"; > } > else > { > eventDateTime += ":" + eventDetailBean.getMin(); > } > } > > System.out.println("Validate 3"); > if (! GenericValidator.isBlankOrNull(eventDateTime) && > GenericValidator.isDate(eventDateTime,"MM/dd/yyyy HH:mm",true)) > { > String inputFormat = "MM/dd/yyyy HH:mm"; > SimpleDateFormat inputDateFormat = new SimpleDateFormat(inputFormat); > try { > Date eventDate = inputDateFormat.parse(eventDateTime); > Date currentDate = new Date(); > > if ((eventDetailBean.getReportedDateTime() == null && > eventDate.after(currentDate)) || > (eventDetailBean.getReportedDateTime() != null && > eventDate.after(eventDetailBean.getReportedDateTime()))) { > errors.add(ActionErrors.GLOBAL_ERROR, new > ActionError("error.eventdetail.eventDateLaterThanReportedDate", "Event > Date")); > } > } catch (ParseException e) { > } > > System.out.println("Validate 4"); > > } > > return errors; > } > > > Validation.xml > >
> > > > > > > > > > > > > datePatternStrict > MM/dd/yyyy > > > > > > > > > depends="required"> > > >
> > > >>> grahamdavid1980@yahoo.com 11/11/03 10:34AM >>> > > --- Srinivas Gunturu wrote: > > Thanks for the response. I was trying to avoid explain what I was > > doing. I will try to be short. > > > > We are migrating a legacy system to an intranet website in a phased > out > > manner. While some users use the legacy system to enter data, some > will > > be using online system. Legacy system is very lenient as far as data > > validation goes. We have a nightly batch process that transfers data > > from legacy system to the new intranet system. > > > > The data is entered using a wizard flow and consists of 6-10 screens. > > At the end user has a summary/review screen before data is persisted. > > We have reviewers reviewing data coming from legacy system and fix it. > > > When a reviewer opens legacy data on the intranet, we take them > directly > > to summary page. On summary page, we would like to validate all > legacy > > data and display visual indicators for each form that fails > validation. > > > > Instead of re-writig the validation, I am trying to invoke validator > > with in my action class by passing one form at a time to validate. I > am > > only at the begining and have 15+forms to go. > > > > Now to answer your question, No, my validate method does not throw an > > exception. > > > > I can include my validate code if needed. > > Please send the validate method that causes the exception. Try putting > a > try...catch (Exception e) block around all of the code in your > validation > method and print out any exception that occurs. Your method may be > throwing a RuntimeException that you're not seeing. > > David > > > > > >>> grahamdavid1980@yahoo.com 11/11/03 10:18AM >>> > > > > --- Srinivas Gunturu wrote: > > > Hi All, > > > > > > I am using commons validator and struts. The validation works fine > > > within struts. However, I have a business need to re-use validation > > > outside struts. I am trying to invoke validator with following > code. > > > However, I am getting an exception. Any idea what might be the > > reason? > > > > > > > The stack trace indicates you're running this from Struts but you say > > that > > it works fine from Struts? InvocationTargetException is thrown when a > > dynamically called method throws an exception. Does your validation > > method throw an exception? > > > > David > > > > > Thanks in advance. > > > > > > Srinivas > > > > > > Here is my code > > > ------------------------------------------------------------ > > > ValidatorResources resources = new ValidatorResources(); > > > > > > InputStream rules = > > > > > > getServlet().getServletContext().getResourceAsStream("/WEB-INF/validator-rules.xml"); > > > > > > ValidatorResourcesInitializer.initialize(resources, rules); > > > > > > InputStream forms = > > > > > > getServlet().getServletContext().getResourceAsStream("/WEB-INF/validation.xml"); > === message truncated === __________________________________ Do you Yahoo!? Protect your identity with Yahoo! Mail AddressGuard http://antispam.yahoo.com/whatsnewfree --------------------------------------------------------------------- To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-user-help@jakarta.apache.org