سؤال

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.

هل كانت مفيدة؟

المحلول

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)    

نصائح أخرى

yes use lambda if condition x = y ? "true result" : "false result"

    <view-state id="viewId">
        <on-entry>
            <evaluate expression="flowScope.varx == x ? Bean.dosomethingX() : Bean.somethingY()" result="flowScope.varResult" />
        </on-entry>
    </view-state>

or on start

        <on-start>
            <evaluate expression="flowScope.varx == x ? Bean.somethingX(): Bean.somethingY() " result="flowScope.varResult" />
        </on-start>
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top