📄 customeraction.java
字号:
package org.jb.y272.team0.web.action;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.jb.common.web.action.BaseAction;
import org.jb.y272.team0.biz.CustomerBiz;
import org.jb.y272.team0.biz.DictBiz;
import org.jb.y272.team0.biz.UserBiz;
import org.jb.y272.team0.entity.CstCustomer;
import org.jb.y272.team0.web.form.CustomerForm;
/**
* 用户表 Action Bean
* @author hailong.liu
*/
public class CustomerAction extends BaseAction {
/**
* 转到 查询页面
*/
public ActionForward toList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
CustomerForm myForm = (CustomerForm)form;
this.customerBiz.search(myForm.getItem(), myForm.getPageResult());
String type = "地区";
List dicts = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, dicts);
type = "客户等级";
List levels = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, levels);
return mapping.findForward("list");
}
/**
* 转到 新建页面
*/
public ActionForward toAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
CustomerForm myForm = (CustomerForm)form;
myForm.setItem(new CstCustomer());
return mapping.findForward("add");
}
/**
* 执行 新建操作
*/
public ActionForward doAdd(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
CustomerForm myForm = (CustomerForm)form;
this.customerBiz.add(myForm.getItem());
response.sendRedirect("customer.do?o=toList");
return null;
}
/**
* 转到 编辑页面
*/
public ActionForward toEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
CustomerForm myForm = (CustomerForm)form;
String id = request.getParameter("id");
CstCustomer item = this.customerBiz.get(id);
myForm.setItem(item);
List roles = super.getUsersOptions(this.getServlet().getServletConfig().getServletContext(), this.userBiz);
request.setAttribute("USERS_OPTIONS", roles);
String type = "地区";
List dicts = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, dicts);
type = "客户等级";
List levels = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, levels);
return mapping.findForward("edit");
}
/**
* 执行 编辑操作
*/
public ActionForward doEdit(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
CustomerForm myForm = (CustomerForm)form;
this.customerBiz.update(myForm.getItem());
response.sendRedirect("customer.do?o=toList");
return null;
}
/**
* 执行 删除操作
*/
public ActionForward doDel(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
String id = request.getParameter("id");
this.customerBiz.del(id);
response.sendRedirect("customer.do?o=toList");
return null;
}
/**
* 转到 明细页面
*/
public ActionForward doDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception{
CustomerForm myForm = (CustomerForm)form;
String id = request.getParameter("id");
CstCustomer item = this.customerBiz.get(id);
myForm.setItem(item);
return mapping.findForward("detail");
}
/* 注入Biz方法 */
private CustomerBiz customerBiz = null;
public void setCustomerBiz(CustomerBiz customerBiz){
this.customerBiz = customerBiz;
}
private DictBiz dictBiz = null;
public void setDictBiz(DictBiz dictBiz){
this.dictBiz = dictBiz;
}
private UserBiz userBiz = null;
public void setUserBiz(UserBiz userBiz){
this.userBiz = userBiz;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -