Spring Webflow - Best practice for generalized decision state

164 Views Asked by At

During the flow I am checking if the session is expired or not using a decision state, if yes then it should redirect to error page and if not, the flow should continue.

now currently I want two different transitions to call decision state, so I am creating two decision states for each one of them.

<transition on="A" to="checkA"/>
<transition on="B" to="checkB"/>

<decision-state id="checkA">
    <if test="error?" then="error" else="doA"/>
</decision-state>

<decision-state id="checkB">
    <if test="error?" then="error" else="doB"/>
</decision-state>

so, is there any other way in which I can make one single generalized decision state which can check for the error, if yes, then go to error state else continue with the transition that its supposed to continue with.

Thank you in advance,

1

There are 1 best solutions below

0
dbreaux On

With the caveat above, that I don't think this will actually work for your described case of checking for expired session, the flow XML file can use #{} template expressions like this:

<transition on="A" to="checkCondition">
    <set name="flowScope.nextState" value="doA"/>
</transition>
<transition on="B" to="checkCondition">
    <set name="flowScope.nextState" value="doB"/>
</transition>

<decision-state id="checkCondition">
    <if test="error?" then="error" else="#{flowScope.nextState}"/>
</decision-state>