?? customeraction.java
字號(hào):
?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;
/**
* 用戶(hù)表 Action Bean
* @author hailong.liu
*/
public class CustomerAction extends BaseAction {
/**
* 轉(zhuǎn)到 查詢(xún)頁(yè)面
*/
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 = "地區(qū)";
List dicts = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, dicts);
type = "客戶(hù)等級(jí)";
List levels = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, levels);
return mapping.findForward("list");
}
/**
* 轉(zhuǎn)到 新建頁(yè)面
*/
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");
}
/**
* 執(zhí)行 新建操作
*/
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;
}
/**
* 轉(zhuǎn)到 編輯頁(yè)面
*/
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 = "地區(qū)";
List dicts = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, dicts);
type = "客戶(hù)等級(jí)";
List levels = super.getDictsOptions(this.getServlet().getServletConfig().getServletContext(), this.dictBiz,type);
request.setAttribute("DICTS_OPTIONS_"+type, levels);
return mapping.findForward("edit");
}
/**
* 執(zhí)行 編輯操作
*/
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;
}
/**
* 執(zhí)行 刪除操作
*/
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;
}
/**
* 轉(zhuǎn)到 明細(xì)頁(yè)面
*/
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;
}
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -