SWF-468 - Add convenient "result" and "type" attributes to <evaluate-action>, as an alternative to the more verbose evaluation-result element.

This commit is contained in:
Jeremy Grelle
2008-02-05 20:38:06 +00:00
parent ab526797c9
commit 3a03641d15
2 changed files with 37 additions and 2 deletions

View File

@@ -155,6 +155,8 @@ public class XmlFlowBuilder extends AbstractFlowBuilder implements ResourceHolde
private static final String EVALUATION_RESULT_ELEMENT = "evaluation-result";
private static final String RESULT_ATTRIBUTE = "result";
private static final String DEFAULT_VALUE = "default";
private static final String VIEW_STATE_ELEMENT = "view-state";
@@ -835,6 +837,11 @@ public class XmlFlowBuilder extends AbstractFlowBuilder implements ResourceHolde
Element resultElement = DomUtils.getChildElementByTagName(element, EVALUATION_RESULT_ELEMENT);
if (resultElement != null) {
return parseActionResultExposer(resultElement);
} else if (element.hasAttribute(RESULT_ATTRIBUTE)) {
String resultExpressionString = element.getAttribute(RESULT_ATTRIBUTE);
Expression resultExpression = getExpressionParser().parseExpression(resultExpressionString,
new ParserContextImpl().eval(RequestContext.class));
return new ActionResultExposer(resultExpression, null, parseResultType(element));
} else {
return null;
}

View File

@@ -1065,7 +1065,8 @@ An attribute describing this bean action.
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The rule for how the evaluated expression result should be exposed to the flow.
The rule for how the evaluated expression result should be exposed to the flow. Use of this sub-element is deprecated in
favor of the newer "result" and "type" attributes and will be removed in a future release.
]]>
</xsd:documentation>
</xsd:annotation>
@@ -1079,6 +1080,25 @@ The expression to evaluate when this action is invoked.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="result" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
A fully resolvable expression such as #{flowScope.foo} or #{bean.bar} for exposing the result of the evaluation.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="type" type="xsd:string" use="optional">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The desired evaluation result type. Optional. If specified and the method return value is not of the
desired result type, a type conversion will be attempted.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="name" type="xsd:string">
<xsd:annotation>
@@ -1109,7 +1129,15 @@ An action with a name is often referred to as a "named action".
</xsd:complexType>
</xsd:element>
<xsd:element name="evaluation-result">
<xsd:element name="evaluation-result">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
This element is deprecated in favor of the newer "result" and "type" attributes on the <evaluate-action> and will
be removed in a future release.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="name" type="xsd:string" use="required">
<xsd:annotation>