📄 adteachereditaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.yourcompany.struts.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.ActionMessage;
import allBeans.Teachers;
import allDAOFactory.ITeacherDAO;
import com.yourcompany.struts.form.AdteachereditForm;
/**
* MyEclipse Struts
* Creation date: 07-23-2008
*
* XDoclet definition:
* @struts.action path="/adteacheredit" name="adteachereditForm" input="/Administrators/adteacheredit.jsp" scope="request" validate="true"
*/
public class AdteachereditAction extends Action {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
AdteachereditForm adteachereditForm = (AdteachereditForm) form;// TODO Auto-generated method stub
String th_id=adteachereditForm.getTh_id();
String th_name=adteachereditForm.getTh_name();
String th_sex=adteachereditForm.getTh_sex();
String th_profession=adteachereditForm.getTh_profession();
String th_study=adteachereditForm.getTh_study();
String th_phone=adteachereditForm.getTh_phone();
String th_email=adteachereditForm.getTh_email();
String th_memo=adteachereditForm.getTh_memo();
ActionErrors errors=new ActionErrors();
ITeacherDAO thdao=new ITeacherDAO();
Teachers teacher=new Teachers();
boolean b_error=false;
if(th_id==null || th_id.equals(""))
{
errors.add("th_id",new ActionMessage("adteacher.th_id.wrong"));
b_error=true;
}
if(th_name==null || th_name.equals(""))
{
errors.add("th_name",new ActionMessage("adteacher.th_name.wrong"));
b_error=true;
}
if(th_sex==null || th_sex.equals(""))
{
errors.add("th_sex",new ActionMessage("adteacher.th_sex.wrong"));
b_error=true;
}
teacher=thdao.thget(th_id);
if(teacher==null)
{
errors.add("adteacheristhid",new ActionMessage("adteacher.isthid.wrong"));
b_error=true;
}
if(!b_error)
{
teacher.setThName(th_name);
teacher.setThSex(th_sex);
teacher.setThEmail(th_email);
teacher.setThMemo(th_memo);
teacher.setThPhone(th_phone);
teacher.setThProfession(th_profession);
teacher.setThStudy(th_study);
thdao.thupdate(teacher);
List list=thdao.thget();
request.setAttribute("thlist", list);
return mapping.findForward("toadteacher");
}
else
{
this.saveErrors(request, errors);
request.setAttribute("th_id", th_id);
return mapping.getInputForward();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -