Map model = new HashMap();
String categoryId = request.getParameter("categoryId");
if (categoryId != null) {
PagedListHolder productList = new PagedListHolder(this.petStore.getProductListByCategory(categoryId));
productList.setPageSize(4);
Category category = this.petStore.getCategory(categoryId);
request.getSession().setAttribute("ViewProductAction_productList", productList);
request.getSession().setAttribute("ViewProductAction_category", category);
model.put("productList", productList);
model.put("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();
}
model.put("productList", productList);
model.put("category", category);
}
return new ModelAndView("Category", model);