📄 linkmanaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package crm.web.action.cst;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import crm.biz.cst.CustomerBiz;
import crm.biz.cst.LinkmanBiz;
import crm.entity.cst.CustomerEntity;
import crm.web.form.cst.LinkmanForm;
/**
* MyEclipse Struts
* Creation date: 10-12-2008
*
* XDoclet definition:
* @struts.action path="/linkman" name="linkmanForm" parameter="flag" scope="request" validate="true"
*/
public class LinkmanAction extends DispatchAction {
private LinkmanBiz linkmanBiz=null;
private CustomerBiz customerBiz=null;
/**
* 在linkman.jsp页面点创建.执行create方法并跳转到 linkman_add.jsp页面
*/
public ActionForward create(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//获得客户的编号和客户的名字放到session里
request.getSession().setAttribute("custNo",request.getParameter("custNo"));
request.getSession().setAttribute("custName",request.getParameter("custName"));
return mapping.findForward("linkman_add");
}
/**
* 跳转到 linkman.jsp页面
*/
public ActionForward linkman(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HttpSession session=request.getSession();
//从session里得到客户的编号
String custNo=session.getAttribute("custNo").toString();
//根据客户的编号查找出客户的信息。放到session里
session.setAttribute("ce", customerBiz.findById(custNo));
// 根据客户的编号查询出其对应的所有联系人的信息。并放到list里
session.setAttribute("linkman", linkmanBiz.findAll(custNo));
return mapping.findForward("linkman");
}
/**
* 增加方法 在linkman_add.jsp 页面增加 成功跳转到linkman.jsp页面
*/
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LinkmanForm lf = (LinkmanForm) form; //form 封装表单里的数据
HttpSession session=request.getSession();
//从session里得到客户的编号
String custNo=session.getAttribute("custNo").toString();
//通过客户的编号查找客户的信息。返回客户的实体对象ce
CustomerEntity ce=customerBiz.findById(custNo);
//将客户的实体对象ce 放到方法setCstCustomer()里
lf.getEntity().setCstCustomer(ce);
lf.getEntity().setLkmCustName(session.getAttribute("custName").toString());
linkmanBiz.add(lf.getEntity());
return mapping.findForward("tolinkman");
}
/**
* 准备编辑方法
*
* 在linkman.jsp点击编辑 程序跳转到LinkmanAction类里的toEdit()方法
* 程序跳转到youzi/cust/linkman_edit.jsp 页面
*/
public ActionForward toEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//获取联系人的编号
String id=request.getParameter("id");
//将查询出来的联系人信息放到session里
request.getSession().setAttribute("lke", linkmanBiz.findByID(Long.parseLong(id)));
return mapping.findForward("linkman_edit");
}
/**
* 执行编辑方法 成功跳转到linkman.jsp页面
*/
public ActionForward doEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
LinkmanForm lf=(LinkmanForm)form;
HttpSession session=request.getSession();
//从session里得到客户的编号
String custNo=session.getAttribute("custNo").toString();
//通过客户的编号查找客户的信息。返回客户的实体对象ce
CustomerEntity ce=customerBiz.findById(custNo);
//将客户的实体对象ce 放到方法setCstCustomer()里
lf.getEntity().setCstCustomer(ce);
lf.getEntity().setLkmCustName(ce.getCustName());
linkmanBiz.update(lf.getEntity());
return mapping.findForward("tolinkman");
}
public ActionForward delete(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String id=request.getParameter("id");
linkmanBiz.delete(Integer.parseInt(id));
return mapping.findForward("tolinkman");
}
public void setLinkmanBiz(LinkmanBiz linkmanBiz) {
this.linkmanBiz = linkmanBiz;
}
public void setCustomerBiz(CustomerBiz customerBiz) {
this.customerBiz = customerBiz;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -