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

## org.springframework.webflow.execution
Class AnnotatedAction

    java.lang.Object
      org.springframework.webflow.core.AnnotatedObject
          org.springframework.webflow.execution.AnnotatedAction

All Implemented Interfaces:
  Annotated, Action

    public class AnnotatedAction

extends AnnotatedObject
implements Action

An action proxy/decorator that stores arbitrary properties about a target `Action` implementation for use within a specific Action execution context, for example an `ActionState` definition, a `TransitionCriteria` definition, or in a test environment.

An annotated action is an action that wraps another action (referred to as the target action), setting up the target action's execution attributes before invoking `Action.execute(org.springframework.webflow.execution.RequestContext)`.

Author:
  Keith Donald, Erwin Vervaet

Field Summary
`static java.lang.String` | `METHOD_ATTRIBUTE` The action execution method attribute ("method").
`static java.lang.String` | `NAME_ATTRIBUTE` The action name attribute ("name").

Fields inherited from class org.springframework.webflow.core.AnnotatedObject
`CAPTION_PROPERTY, DESCRIPTION_PROPERTY`

Constructor Summary
`AnnotatedAction(Action targetAction)` Creates a new annotated action object for the specified action.

Method Summary
`Event` | `execute(RequestContext context)` Execute this action.
`java.lang.String` | `getMethod()` Returns the name of the action method to invoke when the target action is executed.
`java.lang.String` | `getName()` Returns the name of a named action, or `null` if the action is unnamed.
`Action` | `getTargetAction()` Returns the wrapped target action.
`boolean` | `isNamed()` Returns whether or not the wrapped target action is a named action.
`protected Event` | `postProcessResult(Event resultEvent)` Get the event id to be used as grounds for a transition in the containing state, based on given result returned from action execution.
`AnnotatedAction` | `putAttribute(java.lang.String attributeName, java.lang.Object attributeValue)` Set an attribute on this annotated object.
`void` | `setMethod(java.lang.String method)` Sets the name of the action method to invoke when the target action is executed.
`void` | `setName(java.lang.String name)` Sets the name of a named action.
`void` | `setTargetAction(Action targetAction)` Set the target action wrapped by this decorator.
`java.lang.String` | `toString()`

Methods inherited from class org.springframework.webflow.core.AnnotatedObject
`getAttributes, getCaption, getDescription, setCaption, setDescription`

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

Field Detail

### NAME_ATTRIBUTE

    public static final java.lang.String NAME_ATTRIBUTE

  The action name attribute ("name").

  The name attribute is often used as a qualifier for an action's result event, and is typically used to allow the flow to respond to a specific action's outcome within a larger action execution chain.

  See Also:
    Constant Field Values

### METHOD_ATTRIBUTE

    public static final java.lang.String METHOD_ATTRIBUTE

  The action execution method attribute ("method").

  The method property is a hint about what method should be invoked.

  See Also:
    Constant Field Values

Constructor Detail

### AnnotatedAction

    public AnnotatedAction(Action targetAction)

  Creates a new annotated action object for the specified action. No contextual properties are provided.

  Parameters:
    `targetAction` - the action

Method Detail

### getTargetAction

    public Action getTargetAction()

  Returns the wrapped target action.

  Returns:
    the action

### setTargetAction

    public void setTargetAction(Action targetAction)

  Set the target action wrapped by this decorator.

### getName

    public java.lang.String getName()

  Returns the name of a named action, or `null` if the action is unnamed. Used when mapping action result events to transitions.

  See Also:
    `isNamed()`, `postProcessResult(Event)`

### setName

    public void setName(java.lang.String name)

  Sets the name of a named action. This is optional and can be `null`.

  Parameters:
    `name` - the action name

### isNamed

    public boolean isNamed()

  Returns whether or not the wrapped target action is a named action.

  See Also:
    `getName()`, `setName(String)`

### getMethod

    public java.lang.String getMethod()

  Returns the name of the action method to invoke when the target action is executed.

### setMethod

    public void setMethod(java.lang.String method)

  Sets the name of the action method to invoke when the target action is executed.

  Parameters:
    `method` - the action method name

### putAttribute

    public AnnotatedAction putAttribute(java.lang.String attributeName,
                                        java.lang.Object attributeValue)

  Set an attribute on this annotated object.

  Parameters:
    `attributeName` - the name of the attribute to set
    `attributeValue` - the value of the attribute
  Returns:
    this object, to support call chaining

### execute

    public Event execute(RequestContext context)
                  throws java.lang.Exception

  Description copied from interface: `Action`
  Execute this action. Action execution will occur in the context of a request associated with an active flow execution.

  Action invocation is typically triggered in a production environment by a state within a flow carrying out the execution of a flow definition. The result of action execution, a logical outcome event, can be used as grounds for a transition out of the calling state.

  Note: The `RequestContext` argument to this method provides access to data about the active flow execution in the context of the currently executing thread. Among other things, this allows this action to access `data` set by other actions, as well as set its own attributes it wishes to expose in a given scope.

  Some notes about actions and their usage of the attribute scope types:

  - Attributes set in `request scope` exist for the life of the currently executing request only.
  - Attributes set in `flash scope` exist until the next external user event is signaled. That time includes the current request plus any redirect or additional refreshes to the next view.
  - Attributes set in `flow scope` exist for the life of the flow session and will be cleaned up automatically when the flow session ends.
  - Attributes set in `conversation scope` exist for the life of the entire flow execution representing a single logical "conversation" with a user.

  All attributes present in any scope are typically exposed in a model for access by a view when an "interactive" state type such as a view state is entered.

  Note: flow scope should generally not be used as a general purpose cache, but rather as a context for data needed locally by other states of the flow this action participates in. For example, it would be inappropriate to stuff large collections of objects (like those returned to support a search results view) into flow scope. Instead, put such result collections in request scope, and ensure you execute this action again each time you wish to view those results. 2nd level caches managed outside of SWF are more general cache solutions.

  Note: as flow scoped attributes are eligible for serialization they should be `Serializable`.

  Specified by:
    `execute` in interface `Action`
  Parameters:
    `context` - the action execution context, for accessing and setting data in a `scope type`, as well as obtaining other flow contextual information (e.g. request context attributes and flow execution context information)
  Returns:
    a logical result outcome, used as grounds for a transition in the calling flow (e.g. "success", "error", "yes", "no", * ...)
  Throws:
    `java.lang.Exception` - a exception occurred during action execution, either checked or unchecked; note, any recoverable exceptions should be caught within this method and an appropriate result outcome returned or be handled by the current state of the calling flow execution.

### postProcessResult

    protected Event postProcessResult(Event resultEvent)

  Get the event id to be used as grounds for a transition in the containing state, based on given result returned from action execution.

  If the wrapped action is named, the name will be used as a qualifier for the event (e.g. "myAction.success").

  Parameters:
    `resultEvent` - the action result event

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `java.lang.Object`

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