1 package xpetstore.web.struts.action.cart; 2 3 import java.util.Collection ; 4 5 import javax.servlet.http.HttpServletRequest ; 6 import javax.servlet.http.HttpServletResponse ; 7 8 import org.apache.struts.action.ActionForm; 9 import org.apache.struts.action.ActionForward; 10 import org.apache.struts.action.ActionMapping; 11 12 import xpetstore.domain.customer.ejb.Customer; 13 14 import xpetstore.services.cart.ejb.Cart; 15 16 import xpetstore.web.struts.action.BaseAction; 17 18 19 32 public class CheckoutAction 33 extends BaseAction 34 { 35 37 40 protected ActionForward doExecute( ActionMapping mapping, 41 ActionForm form, 42 HttpServletRequest request, 43 HttpServletResponse response ) 44 throws Exception 45 { 46 String userId = ( String ) request.getSession( ).getAttribute( USERID_KEY ); 47 CartForm frm = ( CartForm ) form; 48 Cart cart = getCart( request ); 49 50 51 Customer cust = getPetstore( ).getCustomer( userId ); 52 frm.setCustomer( cust ); 53 54 55 Collection items = cart.getCartItems( ); 56 frm.setCartItems( items ); 57 58 59 frm.setTotal( cart.getTotal( ) ); 60 61 return mapping.findForward( SUCCESS ); 62 } 63 } 64 | Popular Tags |