Search code examples
springspring-webflow

How to send parameters SubFlow in Spring WebFlow


I have main Route flow:

<view-state id="addRoute" model="route">

...
    <transition on="editBlock" to="editBlock" validate="false" bind="true">
       ...
    </transition>

</view-state>

<subflow-state id="editBlock" subflow="block">

</subflow-state>

By clicking on editBlock button I want to go over to Block Flow and edit Block.

I want to make it as Subflow.

Block Flow:

<on-start>
    <set name="flowScope.id" value="requestParameters.id"/>
    <evaluate expression="new java.util.ArrayList()" result="flowScope.attributes"/>
    <evaluate expression="new java.util.ArrayList()" result="flowScope.visibility"/>
    <set name="flowScope.folderId" value="requestParameters.folderId"/>
    <set name="flowScope.path" value="requestParameters.path"/>
    <evaluate expression="folderBean.treeAsMap" result="flowScope.tree" />
</on-start>

How to send parameters from the main Flow into Subflow? I need to provide 3 params:

id, folderId and path as stated above.


Solution

  • in your Block FLow, you can put:

    <input name="id"/>
    <input name="folderId"/>
    <input name="path"/>
    

    and then in your Route Flow you can use it this way:

    <subflow-state id="editBlock" subflow="block">
        <input name="id" value="flowScope.id"/>
        <input name="folderId" value="flowScope.folderId"/>
        <input name="path" value="flowScope.path"/>
    </subflow-state>
    

    also, if you call your Block Flow with parameters id=123&folderId=456&path=path then these parameters will be automatically mapped to the inputs with the same name which are set in the flowScope. So you won't need these set elements in you <on-start> anymore.

    also FYI you can use <input name="visibility" type="java.util.ArrayList"/> and <input name="tree" value="folderBean.treeAsMap"/> and get rid of your <on-start> completely.