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 import org.springframework.samples.jpetstore.domain.Account; 11 12 public class NewOrderFormAction extends SecureBaseAction { 13 14 protected ActionForward doExecute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { 15 AccountActionForm acctForm = (AccountActionForm) request.getSession().getAttribute("accountForm"); 16 CartActionForm cartForm = (CartActionForm) request.getSession().getAttribute("cartForm"); 17 if (cartForm != null) { 18 OrderActionForm orderForm = (OrderActionForm) form; 19 Account account = getPetStore().getAccount(acctForm.getAccount().getUsername()); 21 orderForm.getOrder().initOrder(account, cartForm.getCart()); 22 return mapping.findForward("success"); 23 } 24 else { 25 request.setAttribute("message", "An order could not be created because a cart could not be found."); 26 return mapping.findForward("failure"); 27 } 28 } 29 30 } | Popular Tags |