doc updates
This commit is contained in:
@@ -99,7 +99,6 @@
|
||||
<programlisting language="xml">
|
||||
<view-state id="enterBookingDetails">
|
||||
<transition on="submit" to="reviewBooking" />
|
||||
<transition on="cancel" to="bookingCancelled" />
|
||||
</view-state>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -133,7 +132,6 @@
|
||||
|
||||
<view-state id="enterBookingDetails">
|
||||
<transition on="submit" to="reviewBooking" />
|
||||
<transition on="cancel" to="bookingCancelled" />
|
||||
</view-state>
|
||||
|
||||
<view-state id="reviewBooking">
|
||||
@@ -259,7 +257,6 @@
|
||||
|
||||
<view-state id="enterBookingDetails">
|
||||
<transition on="submit" to="reviewBooking" />
|
||||
<transition on="cancel" to="bookingCancelled" />
|
||||
</view-state>
|
||||
|
||||
<view-state id="reviewBooking">
|
||||
@@ -349,7 +346,7 @@ public interface FlowOutcome {
|
||||
Output attributes are declared within end-states that represent specific flow outcomes.
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<end-state> id="bookingConfirmed";
|
||||
<end-state id="bookingConfirmed">
|
||||
<output name="bookingId" />
|
||||
</end-state>
|
||||
</programlisting>
|
||||
@@ -365,27 +362,154 @@ public interface FlowOutcome {
|
||||
<output name="confirmationNumber" value="booking.confirmationNumber" />
|
||||
</programlisting>
|
||||
</sect3>
|
||||
</sect2>
|
||||
</sect2>
|
||||
<sect2 id="checkpoint-input-output">
|
||||
<title>Checkpoint: input/output mapping</title>
|
||||
<para>
|
||||
Now review the sample booking flow with input/output mapping:
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<flow xmlns="http://www.springframework.org/schema/webflow"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
|
||||
|
||||
<input name="hotelId" />
|
||||
|
||||
<on-start>
|
||||
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)" result="flowScope.booking" />
|
||||
</on-start>
|
||||
|
||||
<view-state id="enterBookingDetails">
|
||||
<transition on="submit" to="reviewBooking" />
|
||||
</view-state>
|
||||
|
||||
<view-state id="reviewBooking">
|
||||
<transition on="confirm" to="bookingConfirmed" />
|
||||
<transition on="revise" to="enterBookingDetails" />
|
||||
<transition on="cancel" to="bookingCancelled" />
|
||||
</view-state>
|
||||
|
||||
<end-state id="bookingConfirmed" >
|
||||
<output name="bookingId" value="booking.id"/>
|
||||
</end-state>
|
||||
|
||||
<end-state id="bookingCancelled" />
|
||||
|
||||
</flow>
|
||||
</programlisting>
|
||||
</sect2>
|
||||
</sect1>
|
||||
<sect1 id="flow-variables">
|
||||
<title>Variables</title>
|
||||
<para>
|
||||
A flow may declare one or more instance variables.
|
||||
These variables are allocated when the flow starts.
|
||||
Any @Autowired transient references the variable holds are also rewired when the flow resumes.
|
||||
</para>
|
||||
<para>
|
||||
Use the <code>var</code> element to declare a flow variable:
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<var name="searchCriteria" class="com.mycompany.myapp.hotels.search.SearchCriteria"/>
|
||||
</programlisting>
|
||||
<para>
|
||||
Make sure your variable's class implements <code>java.io.Serializable</code>, as the instance state is saved between flow requests.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="calling-subflows">
|
||||
<title>Calling subflows</title>
|
||||
<para>
|
||||
A flow may call another flow as a subflow. The flow will wait until the subflow returns before responding to its outcome.
|
||||
A flow may call another flow as a subflow. The flow will wait until the subflow returns, then respond to the subflow outcome.
|
||||
</para>
|
||||
<sect2 id="subflow-state-element">
|
||||
<title>The subflow-state element</title>
|
||||
<para>
|
||||
Use the <code>subflow-state</code> element to call another flow:
|
||||
Use the <code>subflow-state</code> element to call another flow as a subflow:
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<subflow-state id="addGuest">
|
||||
<transition on="guestAdded" to="reviewBooking" >
|
||||
<evaluate expression="booking.guests.add(guest)"/>
|
||||
<subflow-state id="addGuest" subflow="createGuest">
|
||||
<transition on="guestCreated" to="reviewBooking">
|
||||
<evaluate expression="booking.guests.add(guest)"/>
|
||||
<transition />
|
||||
<transition on="cancel" to="reviewBooking" />
|
||||
<transition on="creationCancelled" to="reviewBooking" />
|
||||
</subfow-state>
|
||||
</programlisting>
|
||||
</programlisting>
|
||||
<para>
|
||||
The above example calls the <code>createGuest</code> flow, then waits for it to return.
|
||||
When the flow returns with a <code>guestCreated</code> outcome, the new guest is added to the booking's guest list.
|
||||
</para>
|
||||
<sect3 id="subflow-state-element-input">
|
||||
<title>Passing a subflow input</title>
|
||||
<para>
|
||||
Use the input element to pass input to the subflow:
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<subflow-state id="addGuest" subflow="createGuest">
|
||||
<input name="booking" />
|
||||
<transition to="reviewBooking" />
|
||||
</subfow-state>
|
||||
</programlisting>
|
||||
</sect3>
|
||||
<sect3 id="subflow-state-element-input">
|
||||
<title>Mapping subflow output</title>
|
||||
<para>
|
||||
Simply refer to a subflow output attribute by its name within a outcome transition:
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<transition on="guestCreated" to="reviewBooking">
|
||||
<evaluate expression="booking.guests.add(guest)"/>
|
||||
<transition />
|
||||
</programlisting>
|
||||
<para>
|
||||
In the above example, <code>guest</code> is the name of an output attribute returned by the <code>guestCreated</code> outcome.
|
||||
</para>
|
||||
</sect3>
|
||||
</sect2>
|
||||
<sect2 id="checkpoint-input-output">
|
||||
<title>Checkpoint: calling subflows</title>
|
||||
<para>
|
||||
Now review the sample booking flow calling a subflow:
|
||||
</para>
|
||||
<programlisting language="xml">
|
||||
<flow xmlns="http://www.springframework.org/schema/webflow"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/webflow
|
||||
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
|
||||
|
||||
<input name="hotelId" />
|
||||
|
||||
<on-start>
|
||||
<evaluate expression="bookingService.createBooking(hotelId, currentUser.name)" result="flowScope.booking" />
|
||||
</on-start>
|
||||
|
||||
<view-state id="enterBookingDetails">
|
||||
<transition on="submit" to="reviewBooking" />
|
||||
</view-state>
|
||||
|
||||
<view-state id="reviewBooking">
|
||||
<transition on="addGuest" to="addGuest" />
|
||||
<transition on="confirm" to="bookingConfirmed" />
|
||||
<transition on="revise" to="enterBookingDetails" />
|
||||
<transition on="cancel" to="bookingCancelled" />
|
||||
</view-state>
|
||||
|
||||
<subflow-state id="addGuest" subflow="createGuest">
|
||||
<transition on="guestCreated" to="reviewBooking">
|
||||
<evaluate expression="booking.guests.add(guest)"/>
|
||||
<transition />
|
||||
<transition on="creationCancelled" to="reviewBooking" />
|
||||
</subfow-state>
|
||||
|
||||
<end-state id="bookingConfirmed" >
|
||||
<output name="bookingId" value="booking.id"/>
|
||||
</end-state>
|
||||
|
||||
<end-state id="bookingCancelled" />
|
||||
|
||||
</flow>
|
||||
</programlisting>
|
||||
</sect2>
|
||||
</sect1>
|
||||
<sect1 id="simple-event-handlers">
|
||||
<title>Transitions without target states</title>
|
||||
|
||||
Reference in New Issue
Block a user