1
votes

I'm trying to pass a parameter to an evaluate tag in a Spring WebFlow

<action-state id="activateOption">
    <evaluate expression="someService.call()" result="flowScope.serviceResult" result-type="java.lang.String">
        **<attribute name="x" value="flowScope.serviceInput"/>**
    </evaluate>
    <transition on="0" to="Stop_View"/>
</action-state>

In the SomeService bean, when I get retrieve the x parameter like this:

RequestContextHolder.getRequestContext().getAttributes().get("x") 

it returns the String "flowScope.serviceInput" instead of the value of the flowScope.serviceInput which I've set previously in the flow, in another state.

I can pass reference values on on-entry like this:

<action-state id="some action">
    <on-entry>
        <set name="flowScope.someName" value="flowScope.someOtherParam + ' anything!!'" type="java.lang.String"/>
</on-entry>

Why can't I do it when setting an attribute to an evaluate?

Workarounds would not work because we're trying to generate flows this way.

Thanks!

1
Can you elaborate on this "it returns the String "flowScope.serviceInput" instead of the value of that expression." What are you expecting evaluate to perform in your scenario?Prasad
@Prasad I need .getAttributes().get("x") to return the value of the flowScope.serviceInput variable, which I've set previously in another state of the flow, not the String "flowScope.serviceInput"Ionut Bilica

1 Answers

1
votes

If I understand your question correctly, then you can get value of flowScope.serviceInput by:

    RequestContextHolder.getRequestContext().getFlowScope().get("serviceInput")

In Set expression, value is evaluated against requestContext scoped variable-value pairs.

In evaluate expression also, expression is evaluated(not the attribute value) in requestContext. So there will not be a lookup for attribute value in requestContext scoped variable-value pairs but it is captured as specified in flow definition. This is the reason, you get value as "flowScope.serviceInput" for evaluate attribute but for set the value contained in it.

But you can try using EL to get it as:

    <attribute name="x" value="#{flowScope.serviceInput}"/> 
    for SWF version > 2.1 

or with

    <attribute name="x" value="${flowScope.serviceInput}"/> 
    for SWF version < 2.1 where ever you are setting this attribute value.