public org.apache.struts.action.ActionForward | execute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
String categoryId = request.getParameter("categoryId");
if (categoryId != null) {
PagedListHolder productList = new PagedListHolder(getPetStore().getProductListByCategory(categoryId));
productList.setPageSize(4);
Category category = getPetStore().getCategory(categoryId);
request.getSession().setAttribute("ViewProductAction_productList", productList);
request.getSession().setAttribute("ViewProductAction_category", category);
request.setAttribute("productList", productList);
request.setAttribute("category", category);
}
else {
PagedListHolder productList = (PagedListHolder) request.getSession().getAttribute("ViewProductAction_productList");
Category category = (Category) request.getSession().getAttribute("ViewProductAction_category");
String page = request.getParameter("page");
if ("next".equals(page)) {
productList.nextPage();
} else if ("previous".equals(page)) {
productList.previousPage();
}
request.setAttribute("productList", productList);
request.setAttribute("category", category);
}
return mapping.findForward("success");
|