1 16 package dlog4j.formbean; 17 18 import javax.servlet.http.HttpServletRequest ; 19 20 import org.apache.commons.lang.StringUtils; 21 import org.apache.struts.action.ActionError; 22 import org.apache.struts.action.ActionErrors; 23 import org.apache.struts.action.ActionMapping; 24 25 29 public class ParamForm extends DlogActionForm { 30 31 public final static int TYPE_INTEGER = 0x01; 32 public final static int TYPE_STRING = 0x02; 33 public final static int TYPE_BOOLEAN = 0x03; 34 public final static int TYPE_DATE = 0x04; 35 public final static int TYPE_TIME = 0x08; 36 public final static int TYPE_DATETIME= 0x10; 37 38 private int id; 39 private String name; 40 private int type; 41 private String value; 42 private String desc; 43 44 private SiteForm site; 45 46 49 public ActionErrors validate(ActionMapping mapping, HttpServletRequest req) { 50 ActionErrors es = new ActionErrors(); 51 if(type==TYPE_INTEGER && !StringUtils.isNumeric(value)) 52 es.add("value",new ActionError("illegal_input_value")); 53 return es; 54 } 55 58 public String getName() { 59 return name; 60 } 61 62 65 public int getType() { 66 return type; 67 } 68 69 public String getTypeDesc() { 70 switch(type) { 71 case TYPE_INTEGER: 72 return "INTEGER"; 73 case TYPE_STRING: 74 return "STRING"; 75 case TYPE_BOOLEAN: 76 return "BOOLEAN"; 77 case TYPE_DATE: 78 return "DATE"; 79 case TYPE_TIME: 80 return "TIME"; 81 case TYPE_DATETIME: 82 return "DATETIME"; 83 } 84 return "UNKNOWN"; 85 } 86 87 90 public String getValue() { 91 return value; 92 } 93 94 97 public void setName(String string) { 98 name = string; 99 } 100 101 104 public void setType(int i) { 105 type = i; 106 } 107 108 111 public void setValue(String string) { 112 value = string; 113 } 114 115 116 119 public String getDesc() { 120 return desc; 121 } 122 123 126 public void setDesc(String string) { 127 desc = string; 128 } 129 130 133 public SiteForm getSite() { 134 return site; 135 } 136 137 140 public void setSite(SiteForm form) { 141 site = form; 142 } 143 144 147 public int getId() { 148 return id; 149 } 150 151 154 public void setId(int i) { 155 id = i; 156 } 157 158 } 159 | Popular Tags |