Saturday, September 22, 2012

Subflow sample code for spring web flow 2.3.1.RELEASE

 The outer flow's path:
       src/main/webapp/WEB-INF/flows/outer/outer-flow.xml

 The inner flow's path:
       src/main/webapp/WEB-INF/flows/inner/inner-flow.xml


Inside outer flow:


    <subflow-state id="current-step" subflow="inner">
        <input name="actionrequest" value="100" type="java.lang.String"/>
        <transition on="submit" to="next-step"/>
    </subflow-state>


Inside inner flow:

    <input name="actionrequest"/>
    <view-state id="select-customer" >
        <transition on="submit" to="submit"/>
    </view-state>

    <end-state id="submit" commit="true" />

decision-state sample for spring web flow 2.3.1.RELEASE

Flow definition:

    <decision -state="-state" id="customerselectionRequired">
        <if
test="xBean.conditionCheck(flowRequestContext)"                                 then="nextStep1"
                else="nextStep2">
   
     </if>    
    </decision> 

    <view-state id="nextStep1"> 

    <view-state id="nextStep2"> 

      
xBean is a JSF bean and we send "flowRequestContext" to the bean to have access to the flow details, inside "conditionCheck" method.

here is the body of  "conditionCheck":


    public boolean customerSelectionRequired(RequestContext code){
        code.getActiveFlow().getId(); // The name of the flow!

        /*
         * implementation
         */
    }