1 20 package org.enhydra.barracuda.core.forms; 21 22 import java.util.*; 23 24 import org.enhydra.barracuda.core.forms.*; 25 import org.enhydra.barracuda.plankton.*; 26 import org.apache.log4j.*; 27 28 31 public abstract class AbstractFormValidator implements FormValidator { 32 33 protected static final Logger localLogger = Logger.getLogger(AbstractFormValidator.class.getName()); 34 35 private String myErrMsg = null; 36 37 43 public void setErrorMessage(String ierrmsg) { 44 this.myErrMsg = ierrmsg; 45 } 46 47 53 public String getErrorMessage() { 54 return this.myErrMsg; 55 } 56 57 68 public ValidationException generateException(Object source, boolean deferExceptions, String defaultMsg) { 69 if (localLogger.isDebugEnabled()) localLogger.debug("Generating exception... defer="+deferExceptions); 70 String errmsg = (null==this.getErrorMessage()) ? defaultMsg : this.getErrorMessage(); 71 if (deferExceptions) return new DeferredValidationException(source, errmsg); 72 else return new ValidationException(source, errmsg); 73 } 74 75 85 public boolean isNull(Object val, FormElement element){ 86 return ((val==null) || (val.toString().trim().length() < 1)); 87 } 88 90 } 91 | Popular Tags |