protected org.apache.struts.action.ActionForward | doExecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
try
{
System.out.println("!!CreateOrderAction.doExecute");
OrderForm frm = ( OrderForm ) form;
String userId = ( String ) request.getSession( ).getAttribute( USERID_KEY );
Petstore petstore = getPetstore( );
/* Proceed the order */
HashMap items = new HashMap( );
for ( int i = 0, len = frm.getItemId( ).length; i < len; i++ )
{
items.put( frm.getItemId( )[ i ], new Integer( frm.getQuantity( )[ i ] ) );
}
Integer orderUId = petstore.createOrder( userId, new Date( ), items );
frm.getOrder( ).setOrderUId( orderUId );
/* Invalidating the current cart */
Cart cart = getCart( false, request );
if ( cart != null )
{
request.getSession( ).removeAttribute( CART_KEY );
cart.remove( );
}
return mapping.findForward( SUCCESS );
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
|