diff --git a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowExercise.jsp b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowExercise.jsp index d0fb9437..55ded729 100644 --- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowExercise.jsp +++ b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowExercise.jsp @@ -9,9 +9,201 @@ Creating Your First Web Flow
+ Flow definitions are typically authored in XML documents. + A flow is typically packaged in its own directory inside /WEB-INF, and co-located with its dependent resources such as page templates and message resources. + For example, the tutorial flow you are using right now lives in the /WEB-INF/tutorial directory along with its JSP page templates. +
++ XML is a good format for expressing structure. + Since a flow definition primarily captures the navigation structure between your pages, XML is a good fit. + XML is not an appropriate for general programming. + This is why your flows should invoke actions written in Java or Groovy to carry out application behaviors. +
++ <html> + <head> + <title>Hello world!</title> + </head> + <h1> + Hello world! + </h1> + </html> ++
+ <transition on="submit" to="page2" /> ++ Then define your page2 view-state: +
+ <view-state id="page2"> + </view-state> ++ And the corresponding page2.jsp: +
+ <html> + <head> + <title>Hello world!</title> + </head> + <h1> + This is page 2! + </h1> + </html> ++ Finally, create a button on your start.jsp that raises the submit event to trigger the state transition: +
+ <form method="post"> + <input type="submit" name="_eventId_submit" value="Submit" /> + </form> ++ Click the button and you should be taken to page 2. +
+ Web flow excels at implementing dynamic navigation logic that takes a user through different paths based on what they enter or who they are. +
++ <%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %> + <html> + <head> + <title>Hello world!</title> + </head> + <h1> + Hello world! + </h1> + <form:form method="post" modelAttribute="helloWorldForm" > + <form:checkbox path="selected" /> + <input type="submit" name="_eventId_submit" value="Submit" /> + </form:form> + </html> ++
+ package org.springframework.webflow.samples.helloworld;
+
+ import java.io.Serializable;
+
+ public class HelloworldForm implements Serializable {
+ private boolean selected = true;
+
+ public boolean isSelected() {
+ return selected;
+ }
+
+ public void setSelected(boolean selected) {
+ this.selected = selected;
+ }
+ }
+
+ + <var name="helloWorldForm" class="org.springframework.webflow.samples.helloworld.HelloWorldForm" /> ++ Then update your start view-state to use this variable as its data model, enabling automatic model binding and validation: +
+ <view-state id="start" model="helloWorldForm"> ... ++
+ Refresh your flow and the checkbox should render checked since the default value for HelloWorldForm.selected is true. + Uncheck the box and submit and go back in your browser and the unchecked status should be preserved. +
++ <view-state id="start"> + <transition on="submit" to="isSelected" /> + </view-state> + + <decision-state id="isSelected"> + <if test="helloWorldForm.selected" then="page2" else="page3" /> + </decision-state> + + ... + + <view-state id="page3"> + </view-state> + ++ Click the button with the checkbox selected and you should be taken to page2. + Click the button with the checkbox de-selected and you should be taken to page3 (you'll need to create a JSP or you'll get a 404). +
+
+ <input type="submit" name="_eventId_finish" value="Finish" /> ++ In your start view-state, declare the finish transition: +
+ <transition on="finish" to="finished" /> ++ And finally define the end-state: +
+ <end-state id="finished" view="externalRedirect:welcome" /> ++ Click the Finish button and you should be taken back to the application welcome screen. +
diff --git a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowProjectOverview.jsp b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowProjectOverview.jsp index a5cd7015..f4d450f6 100644 --- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowProjectOverview.jsp +++ b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowProjectOverview.jsp @@ -29,7 +29,7 @@ The framework also cares for managing conversational state and preventing duplic
Spring Web Flow builds on the Spring Framework project, which includes the Spring MVC web framework. Concretely, Spring Web Flow plugs into Spring MVC as a Controller technology. -Then, a typical Spring-powered web application is implemented using a mix of annotated Spring MVC @Controllers and web flows. +A typical Spring-powered web application is implemented using a mix of annotated Spring MVC @Controllers and web flows. In general, use @Controllers for implementing simple, single-request user interactions, and web flows for stateful, multi-step user interactions.
diff --git a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowSetup.jsp b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowSetup.jsp index cb359d2e..0320ba9a 100644 --- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowSetup.jsp +++ b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowSetup.jsp @@ -1,6 +1,6 @@ <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> <%@ page session="false" %> - +