1 package org.springframework.samples.jpetstore.web.struts; 2 3 import javax.servlet.http.HttpServletRequest ; 4 import javax.servlet.http.HttpServletResponse ; 5 6 import org.apache.struts.action.ActionForm; 7 import org.apache.struts.action.ActionForward; 8 import org.apache.struts.action.ActionMapping; 9 10 public class ViewCartAction extends BaseAction { 11 12 public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 13 CartActionForm cartForm = (CartActionForm) form; 14 AccountActionForm acctForm = (AccountActionForm) request.getSession().getAttribute("accountForm"); 15 String page = request.getParameter("page"); 16 if (acctForm != null && acctForm.getAccount() != null) { 17 if ("next".equals(page)) { 18 acctForm.getMyList().nextPage(); 19 } 20 else if ("previous".equals(page)) { 21 acctForm.getMyList().previousPage(); 22 } 23 } 24 if ("nextCart".equals(page)) { 25 cartForm.getCart().getCartItemList().nextPage(); 26 } 27 else if ("previousCart".equals(page)) { 28 cartForm.getCart().getCartItemList().previousPage(); 29 } 30 return mapping.findForward("success"); 31 } 32 33 } 34 | Popular Tags |