📄 papertypeaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package web.action;
import java.util.Collection;
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.apache.struts.actions.DispatchAction;
import po.Opapertype;
import web.breakpage.Page;
import business.IAdmService;
import business.IUtilService;
/**
* MyEclipse Struts
* Creation date: 01-18-2008
*
* XDoclet definition:
* @struts.action parameter="method" validate="true"
*/
public class PaperTypeAction extends DispatchAction
{
private IAdmService admService;
private IUtilService utilService;
public IUtilService getUtilService()
{
return utilService;
}
public void setUtilService(IUtilService utilService)
{
this.utilService = utilService;
}
public IAdmService getAdmService()
{
return admService;
}
public void setAdmService(IAdmService admService)
{
this.admService = admService;
}
public ActionForward listPaperType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String hql = "select count(*) as count from Opapertype a";
String hql2= "from Opapertype o order by o.id asc";
String pages = request.getParameter("pages");
int num = 0;
if(null != pages)
{
num = Integer.valueOf(pages);
}
else
{
num = 15;
}
// 根据总行数来创建Page对象
Page p = utilService.getPage(request, hql,num);
int count = p.getTotalRows();
//通过page对象可以得到从哪一条数据库的记录开始查询,查询多少条
Collection clInfos = utilService.findAll(p.getStartRow(),p.getPageSize(),hql2);
request.setAttribute("page",p);
request.setAttribute("list",clInfos);
request.setAttribute("count", count);
request.setAttribute("num", num);
return mapping.findForward("papertype_list");
}
public ActionForward delPaperType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String id = request.getParameter("id");
String[] typeid = utilService.getID(id);
for(int i = 0; i<typeid.length; i++)
{
admService.delPaperType(Long.parseLong(typeid[i]));
}
request.setAttribute("ptype_del_js", "ptype_del_js");
return mapping.findForward("admin_warn");
}
public ActionForward addPaperType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String name = request.getParameter("name").trim();
Opapertype ptype = new Opapertype();
ptype.setName(name);
if(admService.judgeTypeContain(name))
{
admService.addPaperType(ptype);
request.setAttribute("ptype_add_js", "ptype_add_js");
return mapping.findForward("admin_warn");
}
else
{
request.setAttribute("ptype_add_fail_js", "ptype_add_fail_js");
return mapping.findForward("admin_warn");
}
}
public ActionForward updataPaperType_1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String typeid = request.getParameter("typeid");
String name = request.getParameter("name");
Opapertype ptype = admService.findPaperType(Long.parseLong(typeid));
ptype.setName(name);
if(admService.judgeTypeContain(name))
{
admService.updataPaperType(ptype);
request.setAttribute("ptype_updata_js", "ptype_updata_js");
return mapping.findForward("admin_warn");
}
else
{
request.setAttribute("ptype_add_fail_js", "ptype_add_fail_js");
return mapping.findForward("admin_warn");
}
}
public ActionForward updataPaperType(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
{
String typeid = request.getParameter("typeid");
Opapertype ptype = admService.findPaperType(Long.parseLong(typeid));
request.setAttribute("ptype", ptype);
return mapping.findForward("papertype_updata");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -