Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package les_forms;
- import java.util.Enumeration;
- import ironman.StudentData;
- import ironman.Util;
- import javax.servlet.http.HttpServletRequest;
- import org.apache.struts.action.ActionErrors;
- import org.apache.struts.action.ActionForm;
- import org.apache.struts.action.ActionMapping;
- import org.apache.struts.action.ActionMessage;
- public class RegistrationForm extends ActionForm {
- private static final long serialVersionUID = 1L;
- private String username , password , cpassword, email;
- public void setUsername(String username) {
- this.username = username;
- }
- public String getUsername() {
- return username;
- }
- public void setPassword(String password) {
- this.password = password;
- }
- public String getPassword() {
- return password;
- }
- public void setCpassword(String cpassword) {
- this.cpassword = cpassword;
- }
- public String getCpassword() {
- return cpassword;
- }
- public void setEmail(String email) {
- this.email = email;
- }
- public String getEmail() {
- return email;
- }
- /**
- * Reset all properties to their default values.
- *
- * @param mapping
- * The mapping used to select this instance
- * @param request
- * The servlet request we are processing
- */
- public void reset(ActionMapping mapping, HttpServletRequest request) {
- setUsername(null);
- setPassword(null);
- setCpassword(null);
- setEmail(null);
- }
- /**
- * Validate the input data. If validation fails, then report the errors in
- * students.jsp, and specifically where <html:errors/> is located.
- *
- * @param mapping
- * The mapping used to select this instance
- * @param request
- * The servlet request we are processing
- */
- public ActionErrors validate(ActionMapping mapping,
- HttpServletRequest request) {
- System.err.println("in REGISTRATION form");
- ActionErrors errors = new ActionErrors();
- // System.err.println("NAME: "+username+" "+password+" "+confirmPassword);
- if ((username == null) || (username.length() < 1)){
- errors.add("firstMsgTag1", new ActionMessage("errors.required","Username"));
- System.err.println("leave form in error 1");
- return errors;
- }
- if ((password == null) || (password.length() < 1)){
- errors.add("lastMsgTag1", new ActionMessage("errors.required","Password"));
- System.err.println("leave form in error 2");
- return errors;
- }
- if ((cpassword == null) || (cpassword.length() < 1)){
- errors.add("lastMsgTag1", new ActionMessage("errors.required","Confirm Password"));
- System.err.println("leave form in error 3");
- return errors;
- }
- if (!password.equals(cpassword)){
- errors.add("lastMsgTag1", new ActionMessage("errors.required","Passwords Do Not Match"));
- System.err.println("leave form in error 4");
- return errors;
- }
- if ((email == null) || (email.length() < 1)){
- errors.add("lastMsgTag1", new ActionMessage("errors.required","Email"));
- System.err.println("leave form in error 5");
- return errors;
- }
- System.err.println("leave REGISTRATION form with no errors");
- return errors;
- }
- }
Add Comment
Please, Sign In to add comment