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

ViewProductController

public class ViewProductController 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 productId = request.getParameter("productId");
		if (productId != null) {
			PagedListHolder itemList = new PagedListHolder(this.petStore.getItemListByProduct(productId));
			itemList.setPageSize(4);
			Product product = this.petStore.getProduct(productId);
			request.getSession().setAttribute("ViewProductAction_itemList", itemList);
			request.getSession().setAttribute("ViewProductAction_product", product);
			model.put("itemList", itemList);
			model.put("product", product);
		}
		else {
			PagedListHolder itemList = (PagedListHolder) request.getSession().getAttribute("ViewProductAction_itemList");
			Product product = (Product) request.getSession().getAttribute("ViewProductAction_product");
			String page = request.getParameter("page");
			if ("next".equals(page)) {
				itemList.nextPage();
			}
			else if ("previous".equals(page)) {
				itemList.previousPage();
			}
			model.put("itemList", itemList);
			model.put("product", product);
		}
		return new ModelAndView("Product", model);
	
public voidsetPetStore(org.springframework.samples.jpetstore.domain.logic.PetStoreFacade petStore)

		this.petStore = petStore;