1 17 20 package org.apache.forrest.forrestbot.webapp.form; 21 22 import org.apache.log4j.Logger; 23 import org.apache.struts.action.ActionError; 24 import org.apache.struts.action.ActionMessages; 25 import org.apache.struts.action.DynaActionForm; 26 27 28 public class BaseDynaActionForm extends DynaActionForm { 29 private static Logger log = Logger.getLogger(BaseDynaActionForm.class); 30 31 protected boolean isEmptyString(Object o) { 32 return o == null || 33 o.getClass() != String .class || 34 ((String ) o).trim().equals(""); 35 } 36 37 protected ActionMessages checkRequiredFields(String [] fields) { 38 ActionMessages errors = new ActionMessages(); 39 for (int i = 0; i < fields.length; i++) 40 if (isEmptyString(get(fields[i]))) { 41 log.debug(fields[i] + " is empty string"); 42 errors.add(fields[i], new ActionError("error.required", fields[i])); 43 } 44 45 return errors; 46 } 47 } 48 | Popular Tags |