Spring Web Flow View Navigation
In Spring web flow, normal practice is to display a view when a state change occurs; this is exactly what happens in the first view-state tag encountered in Listing 3. The view displayed is the itemlist.jsp page. In itemlist.jsp, the important display code is the table definition shown in Listing 5.
Listing 5 The table definition.
<table border="1" width="300px"> <c:forEach var="item" items="${list}"> <tr><td>${item}</td></tr> </c:forEach> </table>
The c:forEach loop in Listing 5 displays the current contents of the item list. Following the table definition in Listing 4 is the communication back to Spring web flow, which in this case occurs when you enter some text and click the Add New Item button (see Listing 6).
Listing 6 State transition driven by JSP.
<tr> <td class="buttonBar"> <!-- Tell webflow what event happened --> <input type="submit" name="_eventId_add" value="Add New Item"> </td> </tr>
Clearly, some mechanism is required to ensure that user actions made against JSP pages get reflected back to the flow definitions. In Listing 6, the JSP control returns "_eventId_add", which serves to effect the next state transition.