FileDocCategorySizeDatePackage
ViewCategoryController.javaAPI DocExample2000Thu Dec 04 08:19:26 GMT 2003org.springframework.samples.jpetstore.web.spring

ViewCategoryController

public class ViewCategoryController extends Object implements org.springframework.web.servlet.mvc.Controller
author
Juergen Hoeller
since
30.11.2003

Fields Summary
private org.springframework.samples.jpetstore.domain.logic.PetStoreFacade
petStore
Constructors Summary
Methods Summary
public org.springframework.web.servlet.ModelAndViewhandleRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

		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);
	
public voidsetPetStore(org.springframework.samples.jpetstore.domain.logic.PetStoreFacade petStore)

		this.petStore = petStore;