Search code examples
javaspringspring-webflow

When using Spring Web Flow 1, how do I add an object to a list in a bean?


I have a a web flow where I need to capture data on one of the screens.

This data is stored in an object which will be held in a list in the bean.

On submitting the page I want to be able to create an object, and add it to the list in the bean.

Is this possible?

Thanks


Solution

  • In the end I managed to get it working with the following flows.

    I created a helper bean to hold a function for adding to the list held in the form bean.

    <view-state id="page2" view="page2">
        <transition on="save" to="addToList">
            <action bean="form" method="bindAndValidate"/>
        </transition>
        <transition on="back" to="page1">
            <action bean="formAction" method="bindAndValidate"/>
        </transition>
        <transition on="next" to="page3">
            <action bean="formAction" method="bindAndValidate"/>
        </transition>
        </view-state>
    
        <action-state id="addToList">
            <bean-action bean="helperbean" method="addToList">
                <method-arguments>
                    <argument expression="conversationScope.form"/>
            </method-arguments>
            </bean-action>
            <transition on="success" to="page2"/>
        </action-state>
    

    It then displays the original page again