1 16 17 18 package org.apache.struts.webapp.example; 19 20 21 import javax.servlet.http.HttpServletRequest ; 22 import org.apache.struts.action.ActionError; 23 import org.apache.struts.action.ActionErrors; 24 import org.apache.struts.action.ActionForm; 25 import org.apache.struts.action.ActionMapping; 26 27 28 39 40 public final class LogonForm extends ActionForm { 41 42 43 45 46 49 private String password = null; 50 51 52 55 private String username = null; 56 57 58 60 61 64 public String getPassword() { 65 66 return (this.password); 67 68 } 69 70 71 76 public void setPassword(String password) { 77 78 this.password = password; 79 80 } 81 82 83 86 public String getUsername() { 87 88 return (this.username); 89 90 } 91 92 93 98 public void setUsername(String username) { 99 100 this.username = username; 101 102 } 103 104 105 107 108 114 public void reset(ActionMapping mapping, HttpServletRequest request) { 115 116 this.password = null; 117 this.username = null; 118 119 } 120 121 122 132 public ActionErrors validate(ActionMapping mapping, 133 HttpServletRequest request) { 134 135 ActionErrors errors = new ActionErrors(); 136 if ((username == null) || (username.length() < 1)) 137 errors.add("username", new ActionError("error.username.required")); 138 if ((password == null) || (password.length() < 1)) 139 errors.add("password", new ActionError("error.password.required")); 140 141 return errors; 142 143 } 144 145 146 } 147 | Popular Tags |