AddStudentActionForm
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package struts;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
/**
*
* @author Administrator
*/
public class AddStudentActionForm extends org.apache.struts.action.ActionForm {
private String fullName;
private String birthday;
private int mark;
public String getBirthday() {
return birthday;
}
public void setBirthday(String birthday) {
this.birthday = birthday;
}
public String getFullName() {
return fullName;
}
public void setFullName(String fullName) {
this.fullName = fullName;
}
public int getMark() {
return mark;
}
public void setMark(int mark) {
this.mark = mark;
}
/**
*
*/
public AddStudentActionForm() {
super();
// TODO Auto-generated constructor stub
}
public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getFullName() == null || getFullName().length() < 1) {
errors.add("invalidName", new ActionMessage("error.name.invalid"));
}
if (getMark()<0 || getMark()>100){
errors.add("invalidName", new ActionMessage("error.mark.invalid"));
}
return errors;
}
}
Bạn đang đọc truyện trên: truyentop.pro