Mick- The ActionForm.validate method return an ActionErrors object that encapsulates any validation errors that have been found. If no errors are found, return null or an ActionErrors object with no recorded error messages. The default implementation performs no validation and returns null. Subclasses must override this method to provide any validation they wish to perform.
take a look at http://struts.apache.org/api/index.html In other words override validate and handle the building of ActionErrors object for any returned errors. Martin- ----- Original Message ----- From: <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, December 09, 2004 9:15 PM Subject: Custom rule NullPointer errors With the new version of Struts, we are getting a NullPointerException whenever custom rules are being run because they are expecting a parameter list of: Object Bean, ValidatorAction va, Field field, ActionErrors errors, org.apache.commons.validator.Validator validator, HttpServletRequest request and the ActionErrors.errors object is being sent in as null. This did not happen in struts 1.1 Has the custom error handling for Struts changed in the new version? Here are some of our rules: ========================= <validator name="dateIsPast" classname="com.wf.bd.ice.rules.validation.ICEFieldChecks" method="validateDateIsPast" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest" msg="errors.dateIsPast"> </validator> And here is the Java Class: ====================== public static boolean validateDateIsPast( Object bean, ValidatorAction va, Field field, ActionErrors errors, org.apache.commons.validator.Validator validator, HttpServletRequest request ) { Object form = validator.getResource( org.apache.commons.validator.Validator.BEAN_KEY ); String monthVal = null; if(isString(bean)) { monthVal = (String) bean; } else { monthVal = ValidatorUtil.getValueAsString(bean, field.getProperty()); } String yearVal = null; if(!GenericValidator.isBlankOrNull(field.getVarValue("year"))) { String yearProp = field.getVarValue("year"); yearVal = ValidatorUtil.getValueAsString(form, yearProp); } if((monthVal == null) || (yearVal == null)) { return false; } int month; int year; try { month = Integer.parseInt(monthVal); year = Integer.parseInt(yearVal); } catch(NumberFormatException nfe) { return false; } // set the month-year date with the 1st of the month Calendar then = new GregorianCalendar(year, month - 1, 1); Calendar now = new GregorianCalendar(); if(then.after((Calendar) now)) { errors.add( field.getKey(), Resources.getActionError(request, va, field) ); return false; } return true; } -------------------- Mick Knutson Wells Fargo Business Direct Information Systems (415) 222-1020 "This message may contain confidential and/or privileged information. If you are not the addressee or authorized to receive this for the addressee, you must not use, copy, disclose, or take any action based on this message or any information herein. If you have received this message in error, please advise the sender immediately by reply e-mail and delete this message. Thank you for your cooperation." -------------------- --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]