webwork.action
Class ActionContext

java.lang.Object
  extended bywebwork.action.ActionContext

public class ActionContext
extends java.lang.Object

Handles the context of each invoked action while providing an abstraction layer for both servlet and non servlet based applications.

Information is associated with the action's thread so it can be accessed from anywhere by calling a static method.

The context is initially set by the dispatcher.

Version:
$Revision: 1.12 $
Author:
Rickard Öberg (rickard@middleware-company.com), Matt Baldree (matt@smallleap.com), Maurice C. Parker (maurice@vineyardenterprise.com)
See Also:
ServletDispatcher, ClientServletDispatcher

Field Summary
static java.lang.String ACTION_NAME
           
static java.lang.String APPLICATION
           
static java.lang.String LOCALE
           
static java.lang.String PARAMETERS
           
static java.lang.String PRINCIPAL
           
static java.lang.String SESSION
           
static java.lang.String SINGLE_VALUE_PARAMETERS
           
 
Constructor Summary
ActionContext()
           
 
Method Summary
 java.lang.Object get(java.lang.Object key)
          Returns a value that is stored in the current ActionContext buy doing a lookup using the value's key.
static java.util.Map getApplication()
          Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.
 java.util.Map getApplicationImpl()
           
static ActionContext getContext()
          Returns the ActionContext specific to the current thread.
static java.util.Locale getLocale()
          Returns the Locale of the current request in a servlet environment or the default Locale in other environments.
 java.util.Locale getLocaleImpl()
           
static MultiPartRequestWrapper getMultiPartRequest()
          Return multipart request for HttpServletRequest.
 MultiPartRequestWrapper getMultiPartRequestImpl()
           
static java.lang.String getName()
          Returns the name of the current Action.
 java.lang.String getNameImpl()
           
static java.util.Map getParameters()
          Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of parameters otherwise.
 java.util.Map getParametersImpl()
           
static java.security.Principal getPrincipal()
          Returns the current user's security Principal.
 java.security.Principal getPrincipalImpl()
           
static javax.servlet.http.HttpServletRequest getRequest()
          Returns the HttpServletRequest object when in a servlet environment.
 javax.servlet.http.HttpServletRequest getRequestImpl()
           
static javax.servlet.http.HttpServletResponse getResponse()
          Returns the HttpServletResponse when in a servlet environment.
 javax.servlet.http.HttpServletResponse getResponseImpl()
           
static javax.servlet.ServletContext getServletContext()
          Returns the ServletContext when in a servlet environment.
 javax.servlet.ServletContext getServletContextImpl()
           
static java.util.Map getSession()
          Returns the HttpSession when in a servlet environment or a generic session map otherwise.
 java.util.Map getSessionImpl()
           
static java.util.Map getSingleValueParameters()
          Get the current ActionContext parameters.
 java.util.Map getSingleValueParametersImpl()
           
 java.util.Map getTable()
           
static ValueStack getValueStack()
          Returns the ValueStack specific to the current thread.
 ValueStack getValueStackImpl()
           
 void put(java.lang.Object key, java.lang.Object value)
          Stores a value in the current ActionContext.
static void setApplication(java.util.Map application)
          Set an application level Map.
 void setApplicationImpl(java.util.Map application)
           
static void setContext(ActionContext aContext)
           
static void setLocale(java.util.Locale locale)
          Set the current locale.
 void setLocaleImpl(java.util.Locale locale)
           
static void setName(java.lang.String name)
          Stores the name of the current Action in the ActionContext.
 void setNameImpl(java.lang.String name)
           
static void setParameters(java.util.Map parameters)
          Set a Map of parameters.
 void setParametersImpl(java.util.Map parameters)
           
static void setPrincipal(java.security.Principal principal)
          Set the current user's security Principal.
 void setPrincipalImpl(java.security.Principal principal)
           
static void setRequest(javax.servlet.http.HttpServletRequest request)
          Set the HttpServletRequest.
 void setRequestImpl(javax.servlet.http.HttpServletRequest request)
           
static void setResponse(javax.servlet.http.HttpServletResponse response)
          Set the HttpServletResponse.
 void setResponseImpl(javax.servlet.http.HttpServletResponse response)
           
static void setServletContext(javax.servlet.ServletContext context)
          Set the ServletContext.
 void setServletContextImpl(javax.servlet.ServletContext context)
           
static void setSession(java.util.Map session)
          Set a session Map.
 void setSessionImpl(java.util.Map session)
           
static void setSingleValueParameters(java.util.Map parameters)
          Set a Map of single value parameters.
 void setSingleValueParametersImpl(java.util.Map parameters)
           
 void setTable(java.util.Map lookup)
           
static void setValueStack(ValueStack valueStack)
          Set the ValueStack.
 void setValueStackImpl(ValueStack valueStack)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTION_NAME

public static final java.lang.String ACTION_NAME
See Also:
Constant Field Values

SESSION

public static final java.lang.String SESSION
See Also:
Constant Field Values

APPLICATION

public static final java.lang.String APPLICATION
See Also:
Constant Field Values

PARAMETERS

public static final java.lang.String PARAMETERS
See Also:
Constant Field Values

SINGLE_VALUE_PARAMETERS

public static final java.lang.String SINGLE_VALUE_PARAMETERS
See Also:
Constant Field Values

LOCALE

public static final java.lang.String LOCALE
See Also:
Constant Field Values

PRINCIPAL

public static final java.lang.String PRINCIPAL
See Also:
Constant Field Values
Constructor Detail

ActionContext

public ActionContext()
Method Detail

setContext

public static void setContext(ActionContext aContext)

getContext

public static ActionContext getContext()
Returns the ActionContext specific to the current thread.

Returns:
ActionContext for the current thread

getTable

public java.util.Map getTable()

setTable

public void setTable(java.util.Map lookup)

put

public void put(java.lang.Object key,
                java.lang.Object value)
Stores a value in the current ActionContext. The value can be looked up using the key.

Parameters:
key - The key of the value.
value - The value to be stored.

get

public java.lang.Object get(java.lang.Object key)
Returns a value that is stored in the current ActionContext buy doing a lookup using the value's key.

Parameters:
key - The key used to find the value.
Returns:
The value that was found using the key.

getName

public static java.lang.String getName()
Returns the name of the current Action.

Returns:
The current Action name.

getNameImpl

public java.lang.String getNameImpl()

setName

public static void setName(java.lang.String name)
Stores the name of the current Action in the ActionContext.

Parameters:
name - The name of the current action.

setNameImpl

public void setNameImpl(java.lang.String name)

getLocale

public static java.util.Locale getLocale()
Returns the Locale of the current request in a servlet environment or the default Locale in other environments.

Returns:
current locale

getLocaleImpl

public java.util.Locale getLocaleImpl()

setLocale

public static void setLocale(java.util.Locale locale)
Set the current locale.

Parameters:
locale - current locale

setLocaleImpl

public void setLocaleImpl(java.util.Locale locale)

getSession

public static java.util.Map getSession()
Returns the HttpSession when in a servlet environment or a generic session map otherwise.

Returns:
a map of HttpSession or a generic session map

getSessionImpl

public java.util.Map getSessionImpl()

setSession

public static void setSession(java.util.Map session)
Set a session Map.


setSessionImpl

public void setSessionImpl(java.util.Map session)

getApplication

public static java.util.Map getApplication()
Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.

Returns:
Map of ServletContext or generic application level Map

getApplicationImpl

public java.util.Map getApplicationImpl()

setApplication

public static void setApplication(java.util.Map application)
Set an application level Map.


setApplicationImpl

public void setApplicationImpl(java.util.Map application)

getParameters

public static java.util.Map getParameters()
Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of parameters otherwise.

Returns:
Map of HttpServletRequest parameters, generic Map of parameters, or multipart Map.

getParametersImpl

public java.util.Map getParametersImpl()

setParameters

public static void setParameters(java.util.Map parameters)
Set a Map of parameters.

Parameters:
parameters - The parameters for the current action context.

setParametersImpl

public void setParametersImpl(java.util.Map parameters)

getSingleValueParameters

public static java.util.Map getSingleValueParameters()
Get the current ActionContext parameters. Each Map entry is a String.

Returns:
The parameters for the current action context.

getSingleValueParametersImpl

public java.util.Map getSingleValueParametersImpl()

setSingleValueParameters

public static void setSingleValueParameters(java.util.Map parameters)
Set a Map of single value parameters.

Parameters:
parameters - for the current action context.

setSingleValueParametersImpl

public void setSingleValueParametersImpl(java.util.Map parameters)

getPrincipal

public static java.security.Principal getPrincipal()
Returns the current user's security Principal.

Returns:
the current user's security Principal

getPrincipalImpl

public java.security.Principal getPrincipalImpl()

setPrincipal

public static void setPrincipal(java.security.Principal principal)
Set the current user's security Principal.

Parameters:
principal - the current user's security Principal

setPrincipalImpl

public void setPrincipalImpl(java.security.Principal principal)

getMultiPartRequest

public static MultiPartRequestWrapper getMultiPartRequest()
Return multipart request for HttpServletRequest.

Returns:
MultiPartRequestWrapper

getMultiPartRequestImpl

public MultiPartRequestWrapper getMultiPartRequestImpl()

getRequest

public static javax.servlet.http.HttpServletRequest getRequest()
Returns the HttpServletRequest object when in a servlet environment.

Returns:
HttpServletRequest in a servlet environment or null otherwise

getRequestImpl

public javax.servlet.http.HttpServletRequest getRequestImpl()

setRequest

public static void setRequest(javax.servlet.http.HttpServletRequest request)
Set the HttpServletRequest.


setRequestImpl

public void setRequestImpl(javax.servlet.http.HttpServletRequest request)

getResponse

public static javax.servlet.http.HttpServletResponse getResponse()
Returns the HttpServletResponse when in a servlet environment.

Returns:
HttpServletResponse or null

getResponseImpl

public javax.servlet.http.HttpServletResponse getResponseImpl()

setResponse

public static void setResponse(javax.servlet.http.HttpServletResponse response)
Set the HttpServletResponse.


setResponseImpl

public void setResponseImpl(javax.servlet.http.HttpServletResponse response)

getServletContext

public static javax.servlet.ServletContext getServletContext()
Returns the ServletContext when in a servlet environment.

Returns:
ServletContext or null.

getServletContextImpl

public javax.servlet.ServletContext getServletContextImpl()

setServletContext

public static void setServletContext(javax.servlet.ServletContext context)
Set the ServletContext.


setServletContextImpl

public void setServletContextImpl(javax.servlet.ServletContext context)

getValueStack

public static ValueStack getValueStack()
Returns the ValueStack specific to the current thread.

Returns:
ActionContext for the current thread

getValueStackImpl

public ValueStack getValueStackImpl()

setValueStack

public static void setValueStack(ValueStack valueStack)
Set the ValueStack.

Parameters:
valueStack -

setValueStackImpl

public void setValueStackImpl(ValueStack valueStack)


Copyright © 2001-2003 WebWork All Rights Reserved.