📄 productaction.java
字号:
package com.set.system.struts.action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.set.appframe.data.GenericValueObject;
import com.set.appframe.data.SearchResult;
import com.set.appframe.exception.SystemException;
import com.set.appframe.web.MyBaseAction;
import com.set.home.business.ProductMgr;
import com.set.home.model.ProductVO;
import com.set.utils.StringUtils;
import com.set.utils.WebUtils;
public class ProductAction extends MyBaseAction {
private static final int INT_PAGESIZE = 10;
public ActionForward fastsearch(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) {
int totalPage = 0;
int intPageNo = 1;
String model=request.getParameter("model");
ProductVO values = new ProductVO(WebUtils.convertEnumeration(request, true));
values.setModel(model);
int tmpPageNo = 0;
String searchStr = request.getParameter("SearchFormValues");
totalPage = StringUtils.toInteger(values.getItemString("ctlTotalPage"),
0);
if (tmpPageNo > totalPage) {
tmpPageNo = totalPage;
}
String ActionID = values.getItemString("ACTIONID");
if (tmpPageNo > 0) {
intPageNo = tmpPageNo;
} else {
intPageNo = WebUtils.getpageNo(request, ActionID, totalPage);
}
SearchResult result = null;
try {
ProductMgr manager = (ProductMgr) getBean("ProductMgr");
result = manager.fastsearch(values, intPageNo, INT_PAGESIZE);
} catch (SystemException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("GVOLIST", result.getResultList());
int total = result.getCount();
if (total % INT_PAGESIZE == 0) {
totalPage = total / INT_PAGESIZE;
} else {
totalPage = total / INT_PAGESIZE + 1;
// 保存总的记录数
}
request.setAttribute("TotalRecords", new Integer(total));
// 保存总页数
request.setAttribute("TotalPage", new Integer(totalPage));
// 当前页数
request.setAttribute("PageNo", new Integer(intPageNo));
// 分页字符串
request.setAttribute("PagerString", WebUtils.getPagerString(totalPage,
intPageNo));
// 设定formValues,用来初始化前台的查询条件
request.setAttribute("FormValues", values);
return mapping.findForward("fastsearch");
}
public ActionForward highsearch(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) {
int totalPage = 0;
int intPageNo = 1;
ProductVO values = new ProductVO(WebUtils.convertEnumeration(request, true));
int tmpPageNo = 0;
String searchStr = request.getParameter("SearchFormValues");
totalPage = StringUtils.toInteger(values.getItemString("ctlTotalPage"),
0);
if (tmpPageNo > totalPage) {
tmpPageNo = totalPage;
}
String ActionID = values.getItemString("ACTIONID");
if (tmpPageNo > 0) {
intPageNo = tmpPageNo;
} else {
intPageNo = WebUtils.getpageNo(request, ActionID, totalPage);
}
SearchResult result = null;
try {
ProductMgr manager = (ProductMgr) getBean("ProductMgr");
result = manager.highsearch(values, intPageNo, INT_PAGESIZE);
} catch (SystemException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("GVOLIST", result.getResultList());
int total = result.getCount();
if (total % INT_PAGESIZE == 0) {
totalPage = total / INT_PAGESIZE;
} else {
totalPage = total / INT_PAGESIZE + 1;
// 保存总的记录数
}
request.setAttribute("TotalRecords", new Integer(total));
// 保存总页数
request.setAttribute("TotalPage", new Integer(totalPage));
// 当前页数
request.setAttribute("PageNo", new Integer(intPageNo));
// 分页字符串
request.setAttribute("PagerString", WebUtils.getPagerString(totalPage,
intPageNo));
// 设定formValues,用来初始化前台的查询条件
request.setAttribute("FormValues", values);
return mapping.findForward("highsearch");
}
public ActionForward searchAll(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) {
int totalPage = 0;
int intPageNo = 1;
ProductVO values = new ProductVO(WebUtils.convertEnumeration(request, true));
int tmpPageNo = 0;
String searchStr = request.getParameter("SearchFormValues");
totalPage = StringUtils.toInteger(values.getItemString("ctlTotalPage"),
0);
if (tmpPageNo > totalPage) {
tmpPageNo = totalPage;
}
String ActionID = values.getItemString("ACTIONID");
if (tmpPageNo > 0) {
intPageNo = tmpPageNo;
} else {
intPageNo = WebUtils.getpageNo(request, ActionID, totalPage);
}
SearchResult result = null;
try {
ProductMgr manager = (ProductMgr) getBean("ProductMgr");
result = manager.searchAll(values, intPageNo, INT_PAGESIZE);
} catch (SystemException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("GVOLIST", result.getResultList());
int total = result.getCount();
if (total % INT_PAGESIZE == 0) {
totalPage = total / INT_PAGESIZE;
} else {
totalPage = total / INT_PAGESIZE + 1;
// 保存总的记录数
}
request.setAttribute("TotalRecords", new Integer(total));
// 保存总页数
request.setAttribute("TotalPage", new Integer(totalPage));
// 当前页数
request.setAttribute("PageNo", new Integer(intPageNo));
// 分页字符串
request.setAttribute("PagerString", WebUtils.getPagerString(totalPage,
intPageNo));
// 设定formValues,用来初始化前台的查询条件
request.setAttribute("FormValues", values);
return mapping.findForward("searchAll");
}
public ActionForward view(ActionMapping mapping, ActionForm form,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response) {
String id=request.getParameter("productid");
GenericValueObject vo=new GenericValueObject();
try {
ProductMgr manager = (ProductMgr) getBean("ProductMgr");
vo=manager.get(id);
} catch (SystemException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
request.setAttribute("product", vo);
return mapping.findForward("view");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -