Reputation: 23178
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
Upvotes: 0
Views: 1995
Reputation: 23178
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
Upvotes: 1
Reputation: 26769
You need to do a couple of things:
Place an object into the flow scope (or add an extra field on an existing object like your Form) to give a fixed binding path to to the object you want to edit. If you don't do this, you can't take advantage of Spring's databinding.
Write a method on your FormAction to place this object into your list, and set this method to run on the transition followed when you submit the current page. This method can clean up the flowscope-level resources used in (1) as required.
Edit The Webflow documentation has good examples of how to execute actions on transitions. For Webflow version 2 check out Executing view transitions and Executing actions. For version 1, see Flow definition.
Upvotes: 1