0
votes

I'm creating simple flow using spring webflow which has 9-10 pages, each page has just 2-3 fields either checkboxes or radiobuttons. Flow is simple and i've used just one form backing bean which gets updated each time user clicks on next button. Every page has two buttons first one is 'next' button which when clicked submits the form, updates form bean and proceed to next page, second button is 'back' button which routes to the previous view-stage. Both buttons are working fine. Now all of sudden one new requirement has come-up which says 'back' button should behave similar to 'next' button. So if user enters something on the page and clicks on back button then data should be saved in form-bean and it should route to previous stage.Could you please tell me if its possible with spring-webflow?

UPDATES: (based on the answers given)

So please forgive my naivety, i'm new to spring-webflow. My updated question is - do i need to submit the form manually or is there a option/provision in spring webflow which automatically captures the form on back button? bind="true" does not work, below is code from spring-flow.xml (as is clear my formbacking bean is zFormBean):

<view-state id="page1" view="page1.jsp" model="zFormBean">
  <transition on="next" to="page2" history="invalidate" />
</view-state>

<view-state id="page2" view="page2.jsp" model="zFormBean">
  <transition on="next" to="page3"/>
  <transition on="back" bind="true" to="page1" />//->This line does not retain modify data
</view-state>

<action-state id="page3">
  <transition to="GoToPrimary" />
</action-state>

<end-state id="GoToPrimary"></end-state>

JSP Code

<liferay-portlet:actionURL var="nextURL">
    <liferay-portlet:param name="execution" value="${flowExecutionKey}"></liferay-portlet:param>
    <liferay-portlet:param name="_eventId" value="next"></liferay-portlet:param>
</liferay-portlet:actionURL>

<liferay-portlet:actionURL var="backURL">
    <liferay-portlet:param name="execution" value="${flowExecutionKey}"></liferay-portlet:param>
    <liferay-portlet:param name="_eventId" value="back"></liferay-portlet:param>
</liferay-portlet:actionURL>


<aui:form id="zFormBean" name="zFormBean"   method="post" action="<%= nextURL %>" autocomplete="off">

Middle name: <aui:input type="text" name="middleName" />
<aui:field-wrapper name="gender">
  <aui:input inlineLabel="right" name="gender" type="radio" value="male" label="male" />
  <aui:input inlineLabel="right" name="gender" type="radio" value="female" label="female"  />
</aui:field-wrapper>

<aui:button type="submit" name="next" value="next" label="Next" title="Next"/>
<aui:button type="button" name="Back" onClick="${backURL}"/>

</body>
</aui:form>
1
If your form used in binding to each page is in flowscope, then in transition of 'back' include bind="true", it(form) should hold the user selected values for that page.Prasad
bind=true does not work. Please see the question I've updated it with the code for flow.xmluser3367569

1 Answers

0
votes

You can submit the form on Back button also and navigate to previous page, and hold all the data in flowscope variable. In this way, your data will be hold in flowscope even for back button.