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 UserRoleForm extends ActionForm { 28 29 31 34 private String user = null; 35 36 39 private String role = null; 40 41 42 43 45 49 public String getUser() { 50 return (user); 51 } 52 53 57 public void setUser(String user) { 58 this.user = user; 59 } 60 61 65 public String getRole() { 66 return (role); 67 } 68 69 73 public void setRole(String role) { 74 this.role = role; 75 } 76 77 78 80 86 public void reset(ActionMapping mapping, HttpServletRequest request) { 87 this.user = null; 88 this.role = null; 89 } 90 91 92 102 public ActionErrors validate(ActionMapping mapping, 103 HttpServletRequest request) { 104 ActionErrors errors = new ActionErrors(); 105 if (user == null || user.length()==0) 106 errors.add("user", 107 new ActionError("error.user.required")); 108 if (role == null || role.length()==0) 109 errors.add("role", 110 new ActionError("error.role.required")); 111 112 return (errors); 113 } 114 115 116 117 } 118 119 | Popular Tags |