Is it possible to use if tag in <on-entry> state in spring webflow

Ramagiripratap K picture Ramagiripratap K · Dec 17, 2012 · Viewed 7.7k times · Source

I have written the flow as below in spring web-flow 2. But I get error as invalid content.

<on-entry>
<decision-state="check">
<if test="some condition" then="x state" else="y state"/>
</decision-state>
</on-entry>

<view-state id="x state">
<evaluate expression="...."/>
</view-state>

Is there any alternative to use if tag in on-entry state? Can we use decision-state in on-entry?

If the condition is true, I have to evaluate the method in <on-entry> state. Otherwise, it shouldn't evaluate in <on-entry> state.

Answer

rptmat57 picture rptmat57 · Dec 18, 2012

first, <on-entry> only makes sense inside a state.
second, you cannot define a state inside an <on-entry>

what you should do is just define your decision-state and webflow will automatically use it as the entry point.

<decision-state id="check">
    <if test="some condition" then="xState" else="yState"/>
</decision-state>

<view-state id="xState">
    <evaluate expression="...."/>
</view-state>

<view-state id="yState">
    <evaluate expression="...."/>
</view-state>

let's look at this flow, the entry point is obviously check, which is your decision-state because both x state and y state are called by it.

so you flow chart is

             x state
          /
check
          \
             y state

because there is no other way. and I guess this is the behaviour you want

[EDIT] here is an example with 2 action-states:

<decision-state id="check">
    <if test="some condition" then="xState" else="yState"/>
</decision-state>

<action-state id="xState">
    <evaluate expression="expr1"/>
    <transition on="success" to="zState"/>
</action-state>

<action-state id="ySate">
    <evaluate expression="expr2"/>
    <transition on="success" to="zState"/>
</action-state>

<view-state id="zState">
</view-state>


              x action-state
          / (evaluate expr1) \
check                           view-state
          \                           /
              y action-state
            (evaluate expr2)