FileDocCategorySizeDatePackage
BaseAction.javaAPI DocJBoss 4.2.15281Fri Jul 13 20:55:42 BST 2007xpetstore.web.webwork.action

BaseAction

public abstract class BaseAction extends webwork.action.ActionSupport implements webwork.action.ApplicationAware, webwork.action.SessionAware, webwork.action.LocaleAware
author
Herve Tchepannou

Fields Summary
public static final String
BUNDLE_NAME
public static final String
CART_KEY
public static final String
USERID_KEY
public static final String
USERNAME_KEY
protected Map
_application
private cirrus.hibernate.Session
_hibernateSession
protected Locale
_locale
protected Log
_log
protected String
_redirectUri
protected Map
_session
Constructors Summary
Methods Summary
protected voidcheckLength(java.lang.String key, java.lang.String msg, java.lang.String value, int length)


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

        
                                 
                                 
                                     
    
        if ( ( value == null ) || ( value.length(  ) < length ) )
        {
            addError( key, getText( msg ) );
        }
    
protected voidcheckNotEmpty(java.lang.String key, java.lang.String msg, java.lang.String value)

        if ( ( value == null ) || ( value.length(  ) == 0 ) )
        {
            addError( key, getText( msg ) );
        }
    
protected voidclearSession()

        _session.remove( USERID_KEY );
        _session.remove( USERNAME_KEY );
        _session.remove( CART_KEY );
    
public java.lang.Stringexecute()

see
webwork.action.Action#execute()

        _log.info( "execute()" );
        return super.execute(  );
    
public java.util.MapgetCart()
Returns the shoppping cart. The cart is a java.util.Map containing the quantities of the items of the shopping cart indexed by their itemId

return
Map

        Map cart = ( Map ) _session.get( CART_KEY );

        if ( cart == null )
        {
            cart = new HashMap(  );
            _session.put( CART_KEY, cart );
        }

        return cart;
    
public cirrus.hibernate.SessiongetHibernateSession()

        if ( _hibernateSession == null )
        {
            SessionFactory factory = ( SessionFactory ) _application.get( ActionServlet.SESSION_FACTORY_KEY );
            _hibernateSession = factory.openSession(  );
        }

        if ( !_hibernateSession.isOpen(  ) )
        {
            _hibernateSession.reconnect(  );
        }

        return _hibernateSession;
    
public java.util.LocalegetLocale()

see
webwork.action.ActionSupport#getLocale()

        return _locale;
    
public java.lang.StringgetRedirectUri()

return
String

        return _redirectUri;
    
public java.lang.StringgetText(java.lang.String key)

see
webwork.action.ActionSupport#getText(java.lang.String)

        try
        {
            return getTexts(  ).getString( key );
        }
        catch ( MissingResourceException m )
        {
            return "???" + key + "???";
        }
    
public java.util.ResourceBundlegetTexts()

see
webwork.action.ActionSupport#getTexts()

        return ResourceBundle.getBundle( BUNDLE_NAME, getLocale(  ) );
    
public java.lang.StringgetUserId()

        return ( String ) _session.get( USERID_KEY );
    
protected voidinitSession(xpetstore.domain.Customer customer)

        _session.put( USERID_KEY, customer.getUserId(  ) );
        _session.put( USERNAME_KEY, customer.getFirstname(  ) + " " + customer.getLastname(  ) );

        /* TODO set the locale */
    
public voidsetApplication(java.util.Map application)

see
webwork.action.ApplicationAware#setApplication(java.util.Map)

        _application = application;
    
public voidsetLocale(java.util.Locale locale)

see
webwork.action.LocaleAware#setLocale(java.util.Locale)

        _locale = locale;
    
public voidsetRedirectUri(java.lang.String nextUri)
Sets the nextUri.

param
nextUri The nextUri to set

        _redirectUri = nextUri;
    
public voidsetSession(java.util.Map session)

see
webwork.action.SessionAware#setSession(java.util.Map)

        _session = session;