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 ActionSupport

    java.lang.Object
      com.opensymphony.xwork2.ActionSupport

All Implemented Interfaces:
  Action, LocaleProvider, TextProvider, Validateable, ValidationAware, java.io.Serializable

    public class ActionSupport

extends java.lang.Object
implements Action, Validateable, ValidationAware, TextProvider, LocaleProvider, java.io.Serializable

Provides a default implementation for the most common actions. See the documentation for all the interfaces this class implements for more detailed information.

See Also:
  Serialized Form

Field Summary
`protected static Logger` | `LOG`

Fields inherited from interface com.opensymphony.xwork2.Action
`ERROR, INPUT, LOGIN, NONE, SUCCESS`

Constructor Summary
`ActionSupport()`

Method Summary
`void` | `addActionError(java.lang.String anErrorMessage)` Add an Action-level error message to this Action.
`void` | `addActionMessage(java.lang.String aMessage)` Add an Action-level message to this Action.
`void` | `addFieldError(java.lang.String fieldName, java.lang.String errorMessage)` Add an error message for a given field.
`void` | `clearActionErrors()` Clears action errors.
`void` | `clearErrors()` Clears all errors.
`void` | `clearErrorsAndMessages()` Clears all errors and messages.
`void` | `clearFieldErrors()` Clears field errors.
`void` | `clearMessages()` Clears messages.
`java.lang.Object` | `clone()`
`java.lang.String` | `doDefault()`
`java.lang.String` | `execute()` A default implementation that does nothing an returns "success".
`java.util.Collection<java.lang.String>` | `getActionErrors()` Get the Collection of Action-level error messages for this action.
`java.util.Collection<java.lang.String>` | `getActionMessages()` Get the Collection of Action-level messages for this action.
`java.util.Collection<java.lang.String>` | `getErrorMessages()` Deprecated. Use `getActionErrors()`.
`java.util.Map<java.lang.String,java.util.List<java.lang.String>>` | `getErrors()` Deprecated. Use `getFieldErrors()`.
`java.util.Map<java.lang.String,java.util.List<java.lang.String>>` | `getFieldErrors()` Get the field specific errors associated with this action.
`java.util.Locale` | `getLocale()` Gets the provided locale.
`java.lang.String` | `getText(java.lang.String aTextName)` Gets a message based on a message key, or null if no message is found.
`java.lang.String` | `getText(java.lang.String aTextName, java.util.List<?> args)` Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or null if no message is found.
`java.lang.String` | `getText(java.lang.String aTextName, java.lang.String defaultValue)` Gets a message based on a key, or, if the message is not found, a supplied default value is returned.
`java.lang.String` | `getText(java.lang.String key, java.lang.String[] args)` Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or null if no message is found.
`java.lang.String` | `getText(java.lang.String aTextName, java.lang.String defaultValue, java.util.List<?> args)` Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.
`java.lang.String` | `getText(java.lang.String key, java.lang.String defaultValue, java.util.List<?> args, ValueStack stack)` Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.
`java.lang.String` | `getText(java.lang.String aTextName, java.lang.String defaultValue, java.lang.String obj)` Gets a message based on a key using the supplied obj, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.
`java.lang.String` | `getText(java.lang.String key, java.lang.String defaultValue, java.lang.String[] args)` Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.
`java.lang.String` | `getText(java.lang.String key, java.lang.String defaultValue, java.lang.String[] args, ValueStack stack)` Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.
`java.util.ResourceBundle` | `getTexts()` Get the resource bundle associated with the implementing class (usually an action).
`java.util.ResourceBundle` | `getTexts(java.lang.String aBundleName)` Get the named bundle, such as "com/acme/Foo".
`boolean` | `hasActionErrors()` Check whether there are any Action-level error messages.
`boolean` | `hasActionMessages()` Checks whether there are any Action-level messages.
`boolean` | `hasErrors()` Checks whether there are any action errors or field errors.
`boolean` | `hasFieldErrors()` Check whether there are any field errors associated with this action.
`boolean` | `hasKey(java.lang.String key)` Checks if a message key exists.
`java.lang.String` | `input()`
`void` | `pause(java.lang.String result)` Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return the specified result, such as `Action.SUCCESS`, `Action.INPUT`, etc.
`void` | `setActionErrors(java.util.Collection<java.lang.String> errorMessages)` Set the Collection of Action-level String error messages.
`void` | `setActionMessages(java.util.Collection<java.lang.String> messages)` Set the Collection of Action-level String messages (not errors).
`void` | `setContainer(Container container)`
`void` | `setFieldErrors(java.util.Map<java.lang.String,java.util.List<java.lang.String>> errorMap)` Set the field error map of fieldname (String) to Collection of String error messages.
`void` | `validate()` A default implementation that validates nothing.

Methods inherited from class java.lang.Object
`equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### LOG

    protected static Logger LOG

Constructor Detail

### ActionSupport

    public ActionSupport()

Method Detail

### setActionErrors

    public void setActionErrors(java.util.Collection<java.lang.String> errorMessages)

  Description copied from interface: `ValidationAware`
  Set the Collection of Action-level String error messages.

  Specified by:
    `setActionErrors` in interface `ValidationAware`
  Parameters:
    `errorMessages` - Collection of String error messages

### getActionErrors

    public java.util.Collection<java.lang.String> getActionErrors()

  Description copied from interface: `ValidationAware`
  Get the Collection of Action-level error messages for this action. Error messages should not be added directly here, as implementations are free to return a new Collection or an Unmodifiable Collection.

  Specified by:
    `getActionErrors` in interface `ValidationAware`
  Returns:
    Collection of String error messages

### setActionMessages

    public void setActionMessages(java.util.Collection<java.lang.String> messages)

  Description copied from interface: `ValidationAware`
  Set the Collection of Action-level String messages (not errors).

  Specified by:
    `setActionMessages` in interface `ValidationAware`
  Parameters:
    `messages` - Collection of String messages (not errors).

### getActionMessages

    public java.util.Collection<java.lang.String> getActionMessages()

  Description copied from interface: `ValidationAware`
  Get the Collection of Action-level messages for this action. Messages should not be added directly here, as implementations are free to return a new Collection or an Unmodifiable Collection.

  Specified by:
    `getActionMessages` in interface `ValidationAware`
  Returns:
    Collection of String messages

### getErrorMessages

    @Deprecated
    public java.util.Collection<java.lang.String> getErrorMessages()

  Deprecated. Use `getActionErrors()`.

### getErrors

    @Deprecated
    public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getErrors()

  Deprecated. Use `getFieldErrors()`.

### setFieldErrors

    public void setFieldErrors(java.util.Map<java.lang.String,java.util.List<java.lang.String>> errorMap)

  Description copied from interface: `ValidationAware`
  Set the field error map of fieldname (String) to Collection of String error messages.

  Specified by:
    `setFieldErrors` in interface `ValidationAware`
  Parameters:
    `errorMap` - field error map

### getFieldErrors

    public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getFieldErrors()

  Description copied from interface: `ValidationAware`
  Get the field specific errors associated with this action. Error messages should not be added directly here, as implementations are free to return a new Collection or an Unmodifiable Collection.

  Specified by:
    `getFieldErrors` in interface `ValidationAware`
  Returns:
    Map with errors mapped from fieldname (String) to Collection of String error messages

### getLocale

    public java.util.Locale getLocale()

  Description copied from interface: `LocaleProvider`
  Gets the provided locale.

  Specified by:
    `getLocale` in interface `LocaleProvider`
  Returns:
    the locale.

### hasKey

    public boolean hasKey(java.lang.String key)

  Description copied from interface: `TextProvider`
  Checks if a message key exists.

  Specified by:
    `hasKey` in interface `TextProvider`
  Parameters:
    `key` - message key to check for
  Returns:
    boolean true if key exists, false otherwise.

### getText

    public java.lang.String getText(java.lang.String aTextName)

  Description copied from interface: `TextProvider`
  Gets a message based on a message key, or null if no message is found.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `aTextName` - the resource bundle key that is to be searched for
  Returns:
    the message as found in the resource bundle, or null if none is found.

### getText

    public java.lang.String getText(java.lang.String aTextName,
                                    java.lang.String defaultValue)

  Description copied from interface: `TextProvider`
  Gets a message based on a key, or, if the message is not found, a supplied default value is returned.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `aTextName` - the resource bundle key that is to be searched for
    `defaultValue` - the default value which will be returned if no message is found
  Returns:
    the message as found in the resource bundle, or defaultValue if none is found

### getText

    public java.lang.String getText(java.lang.String aTextName,
                                    java.lang.String defaultValue,
                                    java.lang.String obj)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied obj, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `aTextName` - the resource bundle key that is to be searched for
    `defaultValue` - the default value which will be returned if no message is found
    `obj` - obj to be used in a `MessageFormat` message
  Returns:
    the message as found in the resource bundle, or defaultValue if none is found

### getText

    public java.lang.String getText(java.lang.String aTextName,
                                    java.util.List<?> args)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or null if no message is found.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `aTextName` - the resource bundle key that is to be searched for
    `args` - a list args to be used in a `MessageFormat` message
  Returns:
    the message as found in the resource bundle, or null if none is found.

### getText

    public java.lang.String getText(java.lang.String key,
                                    java.lang.String[] args)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or null if no message is found.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `key` - the resource bundle key that is to be searched for
    `args` - an array args to be used in a `MessageFormat` message
  Returns:
    the message as found in the resource bundle, or null if none is found.

### getText

    public java.lang.String getText(java.lang.String aTextName,
                                    java.lang.String defaultValue,
                                    java.util.List<?> args)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `aTextName` - the resource bundle key that is to be searched for
    `defaultValue` - the default value which will be returned if no message is found
    `args` - a list args to be used in a `MessageFormat` message
  Returns:
    the message as found in the resource bundle, or defaultValue if none is found

### getText

    public java.lang.String getText(java.lang.String key,
                                    java.lang.String defaultValue,
                                    java.lang.String[] args)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `key` - the resource bundle key that is to be searched for
    `defaultValue` - the default value which will be returned if no message is found
    `args` - an array args to be used in a `MessageFormat` message
  Returns:
    the message as found in the resource bundle, or defaultValue if none is found

### getText

    public java.lang.String getText(java.lang.String key,
                                    java.lang.String defaultValue,
                                    java.util.List<?> args,
                                    ValueStack stack)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned. Instead of using the value stack in the ActionContext this version of the getText() method uses the provided value stack.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `key` - the resource bundle key that is to be searched for
    `defaultValue` - the default value which will be returned if no message is found
    `args` - a list args to be used in a `MessageFormat` message
    `stack` - the value stack to use for finding the text
  Returns:
    the message as found in the resource bundle, or defaultValue if none is found

### getText

    public java.lang.String getText(java.lang.String key,
                                    java.lang.String defaultValue,
                                    java.lang.String[] args,
                                    ValueStack stack)

  Description copied from interface: `TextProvider`
  Gets a message based on a key using the supplied args, as defined in `MessageFormat`, or, if the message is not found, a supplied default value is returned. Instead of using the value stack in the ActionContext this version of the getText() method uses the provided value stack.

  Specified by:
    `getText` in interface `TextProvider`
  Parameters:
    `key` - the resource bundle key that is to be searched for
    `defaultValue` - the default value which will be returned if no message is found
    `args` - an array args to be used in a `MessageFormat` message
    `stack` - the value stack to use for finding the text
  Returns:
    the message as found in the resource bundle, or defaultValue if none is found

### getTexts

    public java.util.ResourceBundle getTexts()

  Description copied from interface: `TextProvider`
  Get the resource bundle associated with the implementing class (usually an action).

  Specified by:
    `getTexts` in interface `TextProvider`
  Returns:
    the bundle

### getTexts

    public java.util.ResourceBundle getTexts(java.lang.String aBundleName)

  Description copied from interface: `TextProvider`
  Get the named bundle, such as "com/acme/Foo".

  Specified by:
    `getTexts` in interface `TextProvider`
  Parameters:
    `aBundleName` - the name of the resource bundle, such as `"com/acme/Foo"`.
  Returns:
    the bundle

### addActionError

    public void addActionError(java.lang.String anErrorMessage)

  Description copied from interface: `ValidationAware`
  Add an Action-level error message to this Action.

  Specified by:
    `addActionError` in interface `ValidationAware`
  Parameters:
    `anErrorMessage` - the error message

### addActionMessage

    public void addActionMessage(java.lang.String aMessage)

  Description copied from interface: `ValidationAware`
  Add an Action-level message to this Action.

  Specified by:
    `addActionMessage` in interface `ValidationAware`
  Parameters:
    `aMessage` - the message

### addFieldError

    public void addFieldError(java.lang.String fieldName,
                              java.lang.String errorMessage)

  Description copied from interface: `ValidationAware`
  Add an error message for a given field.

  Specified by:
    `addFieldError` in interface `ValidationAware`
  Parameters:
    `fieldName` - name of field
    `errorMessage` - the error message

### input

    public java.lang.String input()
                           throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### doDefault

    public java.lang.String doDefault()
                               throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### execute

    public java.lang.String execute()
                             throws java.lang.Exception

  A default implementation that does nothing an returns "success".

  Subclasses should override this method to provide their business logic.

  See also `Action.execute()`.

  Specified by:
    `execute` in interface `Action`
  Returns:
    returns `Action.SUCCESS`
  Throws:
    `java.lang.Exception` - can be thrown by subclasses.

### hasActionErrors

    public boolean hasActionErrors()

  Description copied from interface: `ValidationAware`
  Check whether there are any Action-level error messages.

  Specified by:
    `hasActionErrors` in interface `ValidationAware`
  Returns:
    true if any Action-level error messages have been registered

### hasActionMessages

    public boolean hasActionMessages()

  Description copied from interface: `ValidationAware`
  Checks whether there are any Action-level messages.

  Specified by:
    `hasActionMessages` in interface `ValidationAware`
  Returns:
    true if any Action-level messages have been registered

### hasErrors

    public boolean hasErrors()

  Description copied from interface: `ValidationAware`
  Checks whether there are any action errors or field errors.

  Note: that this does not have the same meaning as in WW 1.x.

  Specified by:
    `hasErrors` in interface `ValidationAware`
  Returns:
    `(hasActionErrors() || hasFieldErrors())`

### hasFieldErrors

    public boolean hasFieldErrors()

  Description copied from interface: `ValidationAware`
  Check whether there are any field errors associated with this action.

  Specified by:
    `hasFieldErrors` in interface `ValidationAware`
  Returns:
    whether there are any field errors

### clearFieldErrors

    public void clearFieldErrors()

  Clears field errors. Useful for Continuations and other situations where you might want to clear parts of the state on the same action.

### clearActionErrors

    public void clearActionErrors()

  Clears action errors. Useful for Continuations and other situations where you might want to clear parts of the state on the same action.

### clearMessages

    public void clearMessages()

  Clears messages. Useful for Continuations and other situations where you might want to clear parts of the state on the same action.

### clearErrors

    public void clearErrors()

  Clears all errors. Useful for Continuations and other situations where you might want to clear parts of the state on the same action.

### clearErrorsAndMessages

    public void clearErrorsAndMessages()

  Clears all errors and messages. Useful for Continuations and other situations where you might want to clear parts of the state on the same action.

### validate

    public void validate()

  A default implementation that validates nothing. Subclasses should override this method to provide validations.

  Specified by:
    `validate` in interface `Validateable`

### clone

    public java.lang.Object clone()
                           throws java.lang.CloneNotSupportedException

  Overrides:
    `clone` in class `java.lang.Object`
  Throws:
    `java.lang.CloneNotSupportedException`

### pause

    public void pause(java.lang.String result)

  Stops the action invocation immediately (by throwing a PauseException) and causes the action invocation to return the specified result, such as `Action.SUCCESS`, `Action.INPUT`, etc.

  The next time this action is invoked (and using the same continuation ID), the method will resume immediately after where this method was called, with the entire call stack in the execute method restored.

  Note: this method can only be called within the `execute()` method.

  Parameters:
    `result` - the result to return - the same type of return value in the `execute()` method.

### setContainer

    public void setContainer(Container container)

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-2011 Apache Software Foundation. All Rights Reserved.