Hi,
In action form can we use org.apache.struts.validator.validatorForm and validate method. I have attached my code
ActionForm
--------------
package classes.newuser;
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 NewUserForm extends org.apache.struts.validator.ValidatorForm {
private static final long serialVersionUID = 1L;
private String firstname=null;
private String lastname=null;
private String gender=null;
private String dateofbirth=null;
private String emailid=null;
private String username=null;
private String password=null;
private String confirmpassword=null;
public String getConfirmpassword() {
return confirmpassword;
}
public String getDateofbirth() {
return dateofbirth;
}
public String getEmailid() {
return emailid;
}
public String getFirstname() {
return firstname;
}
public String getGender() {
return gender;
}
public String getLastname() {
return lastname;
}
public String getPassword() {
return password;
}
public String getUsername() {
return username;
}
public void setConfirmpassword(String confirmpassword) {
this.confirmpassword = confirmpassword;
}
public void setDateofbirth(String dateofbirth) {
this.dateofbirth = dateofbirth;
}
public void setEmailid(String emailid) {
this.emailid = emailid;
}
public void setFirstname(String firstname) {
this.firstname = firstname;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setLastname(String lastname) {
this.lastname = lastname;
}
public void setPassword(String password) {
this.password = password;
}
public void setUsername(String username) {
this.username = username;
}
public void reset(ActionMapping mapping,HttpServletRequest request){
this.firstname=null;
this.lastname=null;
this.gender=null;
this.dateofbirth=null;
this.emailid=null;
this.username=null;
this.password=null;
this.confirmpassword=null;
}
public ActionErrors validate(ActionMapping mapping,HttpServletRequest request){
ActionErrors errors=new ActionErrors();
NewUserAction act= new NewUserAction();
ActionForm form=null;
//Boolean flag= act.
errors.add("emailid", new ActionMessage("NewUserForm.emailid.alreadyexists"));
return errors;
}
}
can any one help me