FileDocCategorySizeDatePackage
ViewCategoryAction.javaAPI DocExample1799Thu Dec 04 08:19:26 GMT 2003org.springframework.samples.jpetstore.web.struts

ViewCategoryAction

public class ViewCategoryAction extends BaseAction

Fields Summary
Constructors Summary
Methods Summary
public org.apache.struts.action.ActionForwardexecute(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");