Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.opensymphony.xwork2
Class ActionContext

    java.lang.Object
      com.opensymphony.xwork2.ActionContext

All Implemented Interfaces:
  Serializable

    public class ActionContext

extends Object
implements Serializable

The ActionContext is the context in which an `Action` is executed. Each context is basically a container of objects an action needs for execution like the session, parameters, locale, etc.

The ActionContext is thread local which means that values stored in the ActionContext are unique per thread. See the `ThreadLocal` class for more information. The benefit of this is you don't need to worry about a user specific action context, you just get it:

`ActionContext context = ActionContext.getContext();`

Finally, because of the thread local usage you don't need to worry about making your actions thread safe.

Author:
  Patrick Lightbody, Bill Lynch (docs)
See Also:
  Serialized Form

Field Summary
`static String` | `ACTION_INVOCATION` Constant for the action's `invocation` context.
`static String` | `ACTION_NAME` Constant for the name of the action being executed.
`static String` | `APPLICATION` Constant for the action's application context.
`static String` | `CONTAINER` Constant for the container
`static String` | `CONVERSION_ERRORS` Constant for the map of type conversion errors.
`static String` | `LOCALE` Constant for the action's locale.
`static String` | `PARAMETERS` Constant for the action's parameters.
`static String` | `SESSION` Constant for the action's session.
`static String` | `TYPE_CONVERTER` Constant for the action's type converter.
`static String` | `VALUE_STACK` Constant for the `OGNL value stack`.

Constructor Summary
`ActionContext(Map<String,Object> context)` Creates a new ActionContext initialized with another context.

Method Summary
`Object` | `get(String key)` Returns a value that is stored in the current ActionContext by doing a lookup using the value's key.
`ActionInvocation` | `getActionInvocation()` Gets the action invocation (the execution state).
`Map<String,Object>` | `getApplication()` Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.
`Container` | `getContainer()` Sets the container for this request
`static ActionContext` | `getContext()` Returns the ActionContext specific to the current thread.
`Map<String,Object>` | `getContextMap()` Gets the context map.
`Map<String,Object>` | `getConversionErrors()` Gets the map of conversion errors which occurred when executing the action.
`
`<T> T`
` | `getInstance(Class<T> type)`
`Locale` | `getLocale()` Gets the Locale of the current action.
`String` | `getName()` Gets the name of the current Action.
`Map<String,Object>` | `getParameters()` Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of parameters otherwise.
`Map<String,Object>` | `getSession()` Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise.
`ValueStack` | `getValueStack()` Gets the OGNL value stack.
`void` | `put(String key, Object value)` Stores a value in the current ActionContext.
`void` | `setActionInvocation(ActionInvocation actionInvocation)` Sets the action invocation (the execution state).
`void` | `setApplication(Map<String,Object> application)` Sets the action's application context.
`void` | `setContainer(Container cont)` Gets the container for this request
`static void` | `setContext(ActionContext context)` Sets the action context for the current thread.
`void` | `setContextMap(Map<String,Object> contextMap)` Sets the action's context map.
`void` | `setConversionErrors(Map<String,Object> conversionErrors)` Sets conversion errors which occurred when executing the action.
`void` | `setLocale(Locale locale)` Sets the Locale for the current action.
`void` | `setName(String name)` Sets the name of the current Action in the ActionContext.
`void` | `setParameters(Map<String,Object> parameters)` Sets the action parameters.
`void` | `setSession(Map<String,Object> session)` Sets a map of action session values.
`void` | `setValueStack(ValueStack stack)` Sets the OGNL value stack.

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 String ACTION_NAME

  Constant for the name of the action being executed.

  See Also:
    Constant Field Values

### VALUE_STACK

    public static final String VALUE_STACK

  Constant for the `OGNL value stack`.

  See Also:
    Constant Field Values

### SESSION

    public static final String SESSION

  Constant for the action's session.

  See Also:
    Constant Field Values

### APPLICATION

    public static final String APPLICATION

  Constant for the action's application context.

  See Also:
    Constant Field Values

### PARAMETERS

    public static final String PARAMETERS

  Constant for the action's parameters.

  See Also:
    Constant Field Values

### LOCALE

    public static final String LOCALE

  Constant for the action's locale.

  See Also:
    Constant Field Values

### TYPE_CONVERTER

    public static final String TYPE_CONVERTER

  Constant for the action's type converter.

  See Also:
    Constant Field Values

### ACTION_INVOCATION

    public static final String ACTION_INVOCATION

  Constant for the action's `invocation` context.

  See Also:
    Constant Field Values

### CONVERSION_ERRORS

    public static final String CONVERSION_ERRORS

  Constant for the map of type conversion errors.

  See Also:
    Constant Field Values

### CONTAINER

    public static final String CONTAINER

  Constant for the container

  See Also:
    Constant Field Values

Constructor Detail

### ActionContext

    public ActionContext(Map<String,Object> context)

  Creates a new ActionContext initialized with another context.

  Parameters:
    `context` - a context map.

Method Detail

### setActionInvocation

    public void setActionInvocation(ActionInvocation actionInvocation)

  Sets the action invocation (the execution state).

  Parameters:
    `actionInvocation` - the action execution state.

### getActionInvocation

    public ActionInvocation getActionInvocation()

  Gets the action invocation (the execution state).

  Returns:
    the action invocation (the execution state).

### setApplication

    public void setApplication(Map<String,Object> application)

  Sets the action's application context.

  Parameters:
    `application` - the action's application context.

### getApplication

    public Map<String,Object> getApplication()

  Returns a Map of the ServletContext when in a servlet environment or a generic application level Map otherwise.

  Returns:
    a Map of ServletContext or generic application level Map

### setContext

    public static void setContext(ActionContext context)

  Sets the action context for the current thread.

  Parameters:
    `context` - the action context.

### getContext

    public static ActionContext getContext()

  Returns the ActionContext specific to the current thread.

  Returns:
    the ActionContext for the current thread, is never `null`.

### setContextMap

    public void setContextMap(Map<String,Object> contextMap)

  Sets the action's context map.

  Parameters:
    `contextMap` - the context map.

### getContextMap

    public Map<String,Object> getContextMap()

  Gets the context map.

  Returns:
    the context map.

### setConversionErrors

    public void setConversionErrors(Map<String,Object> conversionErrors)

  Sets conversion errors which occurred when executing the action.

  Parameters:
    `conversionErrors` - a Map of errors which occurred when executing the action.

### getConversionErrors

    public Map<String,Object> getConversionErrors()

  Gets the map of conversion errors which occurred when executing the action.

  Returns:
    the map of conversion errors which occurred when executing the action or an empty map if there were no errors.

### setLocale

    public void setLocale(Locale locale)

  Sets the Locale for the current action.

  Parameters:
    `locale` - the Locale for the current action.

### getLocale

    public Locale getLocale()

  Gets the Locale of the current action. If no locale was ever specified the platform's `default locale` is used.

  Returns:
    the Locale of the current action.

### setName

    public void setName(String name)

  Sets the name of the current Action in the ActionContext.

  Parameters:
    `name` - the name of the current action.

### getName

    public String getName()

  Gets the name of the current Action.

  Returns:
    the name of the current action.

### setParameters

    public void setParameters(Map<String,Object> parameters)

  Sets the action parameters.

  Parameters:
    `parameters` - the parameters for the current action.

### getParameters

    public Map<String,Object> getParameters()

  Returns a Map of the HttpServletRequest parameters when in a servlet environment or a generic Map of parameters otherwise.

  Returns:
    a Map of HttpServletRequest parameters or a multipart map when in a servlet environment, or a generic Map of parameters otherwise.

### setSession

    public void setSession(Map<String,Object> session)

  Sets a map of action session values.

  Parameters:
    `session` - the session values.

### getSession

    public Map<String,Object> getSession()

  Gets the Map of HttpSession values when in a servlet environment or a generic session map otherwise.

  Returns:
    the Map of HttpSession values when in a servlet environment or a generic session map otherwise.

### setValueStack

    public void setValueStack(ValueStack stack)

  Sets the OGNL value stack.

  Parameters:
    `stack` - the OGNL value stack.

### getValueStack

    public ValueStack getValueStack()

  Gets the OGNL value stack.

  Returns:
    the OGNL value stack.

### setContainer

    public void setContainer(Container cont)

  Gets the container for this request

  Parameters:
    `cont` - The container

### getContainer

    public Container getContainer()

  Sets the container for this request

  Returns:
    The container

### getInstance

    public <T> T getInstance(Class<T> type)

### get

    public Object get(String key)

  Returns a value that is stored in the current ActionContext by 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 or `null` if the key was not found.

### put

    public void put(String key,
                    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.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000–2018 Apache Software Foundation. All rights reserved.