1 4 package hero.struts.forms; 5 6 7 import javax.servlet.http.HttpServletRequest ; 8 import org.apache.struts.action.ActionError; 9 import org.apache.struts.action.ActionErrors; 10 import org.apache.struts.action.ActionForm; 11 import org.apache.struts.action.ActionMapping; 12 13 14 25 26 27 public final class RoleForm extends ActionForm { 28 29 31 34 private String name = null; 35 36 39 private String groupName = null; 40 41 42 44 48 public String getName() { 49 return (name); 50 } 51 52 56 public void setName(String name) { 57 this.name = name; 58 } 59 60 64 public String getGroupName() { 65 return (groupName); 66 } 67 68 72 public void setGroupName(String groupName) { 73 this.groupName = groupName; 74 } 75 76 78 84 85 public void reset(ActionMapping mapping, HttpServletRequest request) { 86 this.name = null; 87 this.groupName = null; 88 89 } 90 91 101 public ActionErrors validate(ActionMapping mapping, 102 HttpServletRequest request) { 103 ActionErrors errors = new ActionErrors(); 104 if (name == null || name.length()==0) 105 errors.add("name", 106 new ActionError("error.name.required")); 107 if (groupName == null || groupName.length()==0) 108 errors.add("groupName", 109 new ActionError("error.groupname.required")); 110 111 return (errors); 112 } 113 114 115 116 } 117 118
| Popular Tags
|