📄 adddeptformbean.java
字号:
package myBean;
import java.sql.Date;
import java.util.ArrayList;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import basic.*;
public class AddDeptFormBean extends ActionForm {
private long id;
private String dept;
//private Student student;
//private Computer computer;
//private String call;
//private ArrayList list;
public long getId() {
return this.id;
}
/**
* @param id
*/
public void setId(long id) {
this.id= id;
}
/* public Computer getComputer() {
return computer;
}
public void setComputer(Computer computer) {
this.computer = computer;
}
*/
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (isMissing(getDept())) {
errors.add("deptMissing",
new ActionMessage("value.required",
"dept"));
} else if (!isInt(getDept())) {
errors.add("deptNotInt",
new ActionMessage("value.int",
"dept",
getDept()));
}
return(errors);
}
private boolean isMissing(String value) {
return((value == null) || (value.trim().equals("")));
}
private boolean isInt(String potentialInt) {
boolean isInt = true;
try {
int x = Integer.parseInt(potentialInt);
} catch(NumberFormatException nfe) {
isInt = false;
}
return(isInt);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -