FileDocCategorySizeDatePackage
BaseAction.javaAPI DocJBoss 4.2.14115Fri Jul 13 20:56:06 BST 2007xpetstore.web.struts.action

BaseAction

public abstract class BaseAction extends org.apache.struts.action.Action
author
Herve Tchepannou

Fields Summary
public static final String
BUNDLE_NAME
public static final String
CART_KEY
public static final String
ERROR
public static final String
MESSAGE_KEY
public static final String
SUCCESS
public static final String
USERID_KEY
public static final String
USERNAME_KEY
protected Log
_log
Constructors Summary
Methods Summary
protected voidclearSession(javax.servlet.http.HttpServletRequest request)


    //~ Methods ----------------------------------------------------------------

         
         
    
        HttpSession session = request.getSession(  );

        session.removeAttribute( USERID_KEY );
        session.removeAttribute( USERNAME_KEY );

        Cart cart = getCart( false, request );

        if ( cart != null )
        {
            session.removeAttribute( CART_KEY );
            cart.remove(  );
        }
    
protected abstract org.apache.struts.action.ActionForwarddoExecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

public org.apache.struts.action.ActionForwardexecute(org.apache.struts.action.ActionMapping mapping, org.apache.struts.action.ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)

see
org.apache.struts.action.Action#execute(ActionMapping, ActionForm, HttpServletRequest, HttpServletResponse)

        _log.info( "execute()" );

        return doExecute( mapping, form, request, response );
    
public xpetstore.services.cart.ejb.CartgetCart(boolean create, javax.servlet.http.HttpServletRequest request)

        HttpSession session = request.getSession(  );
        Cart   cart = ( Cart ) session.getAttribute( CART_KEY );
        if ( ( cart == null ) && create )
        {
            cart = (Cart)new InitialContext().lookup("ejb/Cart");
            session.setAttribute( CART_KEY, cart );
        }

        return cart;
    
public xpetstore.services.cart.ejb.CartgetCart(javax.servlet.http.HttpServletRequest request)

        return getCart( true, request );
    
public xpetstore.services.petstore.ejb.PetstoregetPetstore()

        return (Petstore)new InitialContext().lookup("ejb/Petstore");
    
public java.lang.StringgetString(java.lang.String key)

        try
        {
            return ResourceBundle.getBundle( BUNDLE_NAME ).getString( key );
        }
        catch ( Exception e )
        {
            return "???" + key + "???";
        }
    
protected voidinitSession(xpetstore.domain.customer.ejb.Customer customer, javax.servlet.http.HttpServletRequest request)

        HttpSession session = request.getSession(  );
        session.setAttribute( USERID_KEY, customer.getUserId(  ) );
        session.setAttribute( USERNAME_KEY, customer.getFirstname(  ) + " " + customer.getLastname(  ) );