1 package hero.struts.forms; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import org.apache.struts.action.ActionError; 5 import org.apache.struts.action.ActionErrors; 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionMapping; 8 9 10 22 23 public final class HookForm extends ActionForm { 24 25 26 28 29 32 private String name = null; 33 34 35 38 39 private String event = null; 40 41 44 45 private String type = null; 46 47 50 private String value = null; 51 52 53 55 56 59 public String getName() { 60 61 return (this.name); 62 63 } 64 65 69 public void setName(String name) { 70 71 this.name = name; 72 73 } 74 75 78 public String getEvent() { 79 80 return (this.event); 81 82 } 83 84 88 public void setEvent(String event) { 89 90 this.event = event; 91 92 } 93 94 97 public String getType() { 98 99 return (this.type); 100 101 } 102 103 107 public void setType(String type) { 108 109 this.type = type; 110 111 } 112 113 116 public String getValue() { 117 118 return (this.value); 119 120 } 121 122 126 public void setValue(String value) { 127 128 this.value = value; 129 } 130 131 132 134 135 141 public void reset(ActionMapping mapping, HttpServletRequest request) { 142 143 this.name = null; 144 this.event = null; 145 this.type = null; 146 this.value = null; 147 } 148 149 159 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 160 161 ActionErrors errors = new ActionErrors(); 162 163 if (name == null || name.length()==0) 164 errors.add("name", 165 new ActionError("error.name.required")); 166 if (event == null || event.length()==0) 167 errors.add("event", 168 new ActionError("error.event.required")); 169 if (type == null || type.length()==0) 170 errors.add("type", 171 new ActionError("error.type.required")); 172 173 return (errors); 174 175 } 176 } 177 | Popular Tags |