问题
I am using Spring Web Flow 2 and am having a basic problem getting my transitions to appropriately fire. I have done a lot of searching on the internet and have been unable to find an in-depth explanation of how transitions are triggered from the view side. I have two states: enterBookingDetails and reviewBooking. EnterBookingDetails is working fine - the page is loading and on submit event, reviewBooking is loaded. My problem is, I can't get any of the transitions from reviewBooking to work. Here is what I have:
booking-flow.xml:
<var name="bookingForm" class="com.mypackage.CarBookingForm"/>
<view-state id="enterBookingDetails" model="bookingForm">
<transition on="submit" to="reviewBooking" />
</view-state>
<view-state id="reviewBooking" model="bookingForm">
<transition on="confirm" to="bookingConfirmed" />
<transition on="revise" to="enterBookingDetails" />
<transition on="cancel" to="bookingCancelled" />
</view-state>
<end-state id="bookingConfirmed" />
<end-state id="bookingCancelled" />
enterBookingDetails.jsp (excerpt):
<form:form modelAttribute="bookingForm">
Pickup: <form:input path="pickUpLocation"/><br />
Dropoff: <form:input path="dropOffLocation"/><br />
<input type="submit" name="_eventId_submit" value="Confirm"/>
<input type="submit" name="_eventId_other" value="Other"/>
</form:form>
reviewBooking.jsp (excerpt):
Pickup Loc: ${bookingForm.pickUpLocation}<br />
Dropoff Loc: ${bookingForm.dropOffLocation}<br />
<form>
<input type="submit" name="_eventId_confirm" value="Confirm" />
<input type="submit" name="_eventId_revise" value="Revise" />
<button type="submit" name="_eventId_cancel">Cancel</button>
<input type="hidden" name="_flowExecutionKey" value="${flowExecutionKey}" />
</form>
When any of the buttons are clicked on "reviewBooking", the user is taken back to "enterBookingDetails" with none of the form data populated. Thanks in advance for your help.
回答1:
OK, I figured out the problem. All of the transitions were actually firing. The issue was that the two problematic transitions went to end states, and I didn't realize that by default those were ending the flow and then redirecting back to the first page.
来源:https://stackoverflow.com/questions/11227837/spring-web-flow-transitions-not-triggered