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 20 21 public final class PropertyForm extends ActionForm { 22 23 25 28 private String key = null; 29 30 31 34 private String value = null; 35 36 37 39 42 public String getKey() { 43 44 return (this.key); 45 } 46 47 52 public void setKey(String key) { 53 54 this.key = key; 55 } 56 57 60 public String getValue() { 61 62 return (this.value); 63 } 64 65 70 public void setValue(String value) { 71 72 this.value = value; 73 } 74 75 76 78 79 85 public void reset(ActionMapping mapping, HttpServletRequest request) { 86 87 this.key = null; 88 this.value = null; 89 } 90 91 101 public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) { 102 103 ActionErrors errors = new ActionErrors(); 104 105 if (key == null || key.length()==0) 106 errors.add("key", new ActionError("error.key.required")); 107 if (value == null || value.length()==0) 108 errors.add("value", new ActionError("error.value.required")); 109 110 return (errors); 111 112 } 113 } 114 | Popular Tags |