我正在使用spring 创建简单的流,它有9-10页,每个页面只有2-3个字段,或者复选框或者无线电按钮。流很简单,我只使用了一个支持bean的表单,它每次用户单击next按钮时都会得到更新。每个页面都有两个按钮--第一个是' next‘按钮,点击它提交表单,更新表单bean并继续到下一个页面,第二个按钮是'back’按钮,它路由到上一个视图阶段。两个按钮都工作正常。现在突然出现了一个新的要求,它说'back‘按钮的行为应该类似于'next’按钮。因此,如果用户在页面上输入某些内容并单击“后退”按钮,那么数据应该保存在form-bean中,并且它应该路由到以前的stage.Could,请告诉我是否可以使用spring吗?
更新:(基于给出的答案)
所以请原谅我的天真,我对春流是陌生的。我更新的问题是-我是否需要手动提交表单,或者在spring中是否有自动捕捉back按钮上的表单的选项/规定?bind="true“不起作用,下面是spring.xml中的代码(显然,我的格式化bean是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代码
<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>发布于 2014-09-30 17:13:15
您也可以提交“后退”按钮上的表单,并导航到上一页,并将所有数据保存在flowscope变量中。这样,您的数据将被保存在流范围内,即使是后退按钮。
https://stackoverflow.com/questions/26119586
复制相似问题