Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: A bit about 'dynamic' results.

...

(lightbulb) For more about results, see Result Types.

Dynamic Results

A result may not be known until execution time. Consider the implementation of a state-machine-based execution flow; the next state might depend on any combination of form input elements, session attributes, user roles, moon phase, etc. In other words, determining the next action, input page, etc. may not be known at configuration time.

Result values may be retrieved from its corresponding Action implementation by using EL expressions that access the Action's properties, just like the Struts 2 tag libraries. So given the following Action fragment:

Code Block
java
java
titleFragmentAction implementation fragment

private String nextAction;

public String getNextAction() {
    return nextAction;
}

you might define a result like this:

Code Block
xml
xml
titleFragmentAction configuration fragment

<action name="fragment" class="FragmentAction">
  <result name="next" type="redirect-action">${nextAction}</result>
</action>

If a FragmentAction method returns "next" the actual value of that result will be whatever is in FragmentAction's nextAction property. So nextAction may be computed based on whatever state information necessary then passed at runtime to "next"'s redirect-action.

See Parameters in configuration results for an expanded discussion.