- Getting Started with Spring Web Flow: Creating Your First Web Flow
- " type="text/css" />
- " type="text/css" />
- " type="text/css" />
- " type="text/css" />
- ">
- ">
- ">
-
-
-"/>
-
- Creating Your First Web Flow
-
-
-
Create your project
-
-
-
-
- Download the Eclipse IDE for Spring Developers, called the SpringSource Tool Suite (STS).
- After downloading completes, extract the archive to your directory of choice.
-
-
- Open STS and access File -> New -> Other... -> SpringSource Tool Suite -> Template Project.
- Select "Web Flow Project" and enter helloworld for your project name.
- Select the Embedded Apache Tomcat as your project's targeted server runtime.
- Finish the new project wizard.
-
-
- Next, right-click on your project in your Package Explorer view, and select Run On Server.
- You should see your application's welcome page appear in the embedded web browser.
- Alternatively, you can access your application in an external browser such as Firefox at http://localhost:8080/helloworld
-
-
-
-
-
-
TODO
-
-
-
-
-
-
Create your first helloworld flow
-
-
- Create a new directory for your flow inside /src/main/webapp/WEB-INF; name the directory helloworld.
- Right-click on the directory and access New -> Spring Web Flow Definition.
- Enter the filename helloworld-flow.xml and finish.
- The flow definition will be generated for you with an initial view-state named start.
-
-
- Go ahead and create a start.jsp in your flow directory and paste in the following:
-
- From the Servers view, restart your server, then startup your flow by accessing http://localhost:8080/getting-started-with-spring-webflow/app/helloworld.
- You should see your Hello world! message display.
- Note you only have to restart your server when you add new flows to the system. When you change flows, changes will be refreshed automatically.
-
-
-
-
-
Add a page navigation rule
-
-
- Next, try transitioning your flow from one state to another to implement a navigation rule. In your helloworld flow, add the following transition to your start view-state:
-
- Click the button and you should be taken to page 2.
-
-
-
-
-
Add a dynamic page navigation rule
-
- Web flow excels at implementing dynamic navigation logic that takes a user through different paths based on what they enter or who they are.
-
-
-
- Try implementing a dynamic navigation rule by first adding a bound checkbox to your start.jsp.
- Do this by replacing its contents with the following snippet:
-
- Refresh your flow and the checkbox should render checked since the default value for the HelloWorldForm selected property is true.
- Uncheck the box and submit and go back in your browser and the unchecked status should be preserved.
-
-
-
- Now insert a decision state that says if the checkbox is selected goto page2, else goto a new page3:
-
- Click the Submit 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).
-
-
-
-
-
Finish your helloworld flow
-
-
- Finish up your helloworld flow by adding another button on the start.jsp that ends the flow:
-
- Click the Finish button and you should be taken back to the application welcome screen.
-
-
-
-
-
Visualize the flow
-
-
- In your IDE, navigate to your helloworld-flow.xml in the Spring Explorer view, or within the Spring Elements node of the Project Explorer view.
- Right-click on the file and select Open Graphical Editor. Your graph should look similar to the visualization below:
-
-
-
\ No newline at end of file
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
deleted file mode 100644
index f3477c60..00000000
--- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowProjectOverview.jsp
+++ /dev/null
@@ -1,62 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ page session="false" %>
-
-
- Getting Started with Spring Web Flow: Overview of the Spring Web Flow Project
- " type="text/css" />
- " type="text/css" />
- ">
- ">
- ">
-
-
-"/>
-
- Overview of the Spring Web Flow Project
-
-
-
- What is Spring Web Flow?
-
-
- Spring Web Flow is a framework for implementing stateful web controllers.
- It is a Spring Project and part of Spring's open-source Web Stack.
-
-
-
-
- When do I use Web Flow?
-
-
- Use Spring Web Flow when you need to implement a flow that guides your users through a series of screens to complete a business goal.
- Web Flow provides a high-level flow definition language for authoring flows that define screen navigation rules.
- The framework also cares for managing conversational state and preventing duplicate transactions.
-
-
-
-
- How does Web Flow relate to other Spring projects?
-
-
- 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.
- 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.
-
-
- A number of other Spring projects also integrate with Spring Web Flow.
- The Spring Faces project uses Spring Web Flow as the controller framework to support implementing Spring-powered web applications that use JavaServerFaces (JSF) as the view technology.
- Spring Web Flow also provides integration with Spring Security for securing web flows.
-
-
- How Spring Web Flow fits into Spring's layered, a-la-carte "Web Stack" is illustrated below:
- " />
-
-
-
\ No newline at end of file
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
deleted file mode 100644
index f9ff0708..00000000
--- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowSetup.jsp
+++ /dev/null
@@ -1,271 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ page session="false" %>
-
-
- Getting Started with Spring Web Flow: Setting up Web Flow in a Spring Web Application
- " type="text/css" />
- " type="text/css" />
- " type="text/css" />
- " type="text/css" />
- ">
- ">
- ">
-
-
-"/>
-
- Setting up Web Flow in a Spring Web Application
-
-
-This step covers the one-time configuration required to setup Web Flow up in a Spring web application.
-If you prefer to go right to implementing your first flow, you can skip this step.
-
-
-In general, we recommend using a pre-configured project template like the one this tutorial uses as a starting point for your new projects.
-When you do that, you will not have to configure Spring yourself--you simply implement your @Controllers and web flows and off you go.
-This step does provides useful background information on setting up your own Web Flow project template, and understanding how things work behind the scenes.
-
-
-
- What does the configuration of a typical Spring web application look like?
-
-
- The configuration of every Spring web application starts in web.xml.
- There, a Spring MVC DispatcherServlet is defined to process all requests into the application.
- The DispatcherServlet itself is configured using a Spring container.
- It is responsible for routing web requests to the proper application controllers, such as your Spring MVC @Controllers and web flows.
- A typical DispatcherServlet declaration is shown below:
-
-
-
- <!-- The front controller of this Spring MVC application, responsible for handling all application requests -->
- <servlet>
- <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
- <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
- <init-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>
- /WEB-INF/spring/*.xml
- </param-value>
- </init-param>
- <load-on-startup>1</load-on-startup>
- </servlet>
-
- <!-- Map all /app requests to the DispatcherServlet for handling -->
- <servlet-mapping>
- <servlet-name>Spring MVC Dispatcher Servlet</servlet-name>
- <url-pattern>/app/*</url-pattern>
- </servlet-mapping>
-
-
-
- This DispatcherServlet is configured to process requests into /app/*.
- The servlet's configuration is defined in the .xml files in /WEB-INF/spring.
-
-
-
-
- How are Spring configuration files typically organized?
-
-
- Inside /WEB-INF/spring, we generally recommend defining a configuration file for your application logic,
- and separate configuration files for framework infrastructure. For example:
-
- The example above shows the configuration for a Spring web application spread across three files.
- The app-config.xml file configures your components that carry out application-specific controller, business, and data access logic.
- The mvc-config.xml file configures the Spring MVC framework infrastructure, including the properties of the DispatcherServlet.
- The webflow-config.xml file configures the Spring Web Flow infrastructure.
-
-
- We also generally recommend using annotations to configure your application components, and externalized XML to configure infrastructure.
- This is illustrated in app-config.xml by use of the component-scan directive to scan your classpath for application components to deploy:
-
-
-
- <!-- Scans within the base package of the application for @Components to configure as beans -->
- <context:component-scan base-package="org.springframework.webflow.samples.gettingstarted" />
-
-
-
- With this technique, your Spring configuration is setup once and you generally never have to update your configuration files again as new components are added to your application.
-
-
-
-
- How do I plug-in Spring Web Flow?
-
-
- In webflow-config.xml, first define a flow-registry to register the flows you have defined in your application:
-
-
-
- <!-- Registers the web flows that can be executed -->
- <webflow:flow-registry id="flowRegistry" base-path="/WEB-INF/">
- <webflow:flow-location-pattern value="**/*-flow.xml" />
- </webflow:flow-registry>
-
-
-
- The example above scans /WEB-INF looking for -flow.xml files and registers them.
-
-
- Then, define a flow-executor that uses this registry to execute your flows:
-
-
-
- <!-- Configures the engine that executes web flows in this application -->
- <webflow:flow-executor id="flowExecutor" flow-registry="flowRegistry" />
-
-
-
- Finally, in mvc-config.xml plug in adapters to hook the flow-executor into the Spring MVC DispatcherServlet request processing pipeline:
-
-
-
- <!-- Maps requests to flows in the flowRegistry -->
- <bean id="flowMappings" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
- <property name="order" value="0" />
- <property name="flowRegistry" ref="flowRegistry" />
- </bean>
-
- <!-- Enables Spring Web Flow as a Spring MVC request handler -->
- <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
- <property name="flowExecutor" ref="flowExecutor" />
- </bean>
-
-
-
- We also recommend you turn on development mode while developing so you never have to redeploy your application to test changes:
-
- How do Spring MVC @Controllers and Web Flows co-exist in the same application?
-
-
- A typical Spring web application consists of a mix of stateless MVC @Controllers and stateful web flows, which are two distinct types of handlers.
- When a web request comes in for a resource, the DispatcherServlet figures out which handler should be invoked.
- This is done by consulting an ordered chain of HandlerMapping objects configured in your mvc-config.xml.
- Generally, the first HandlerMapping consulted is the FlowHandlerMapping, which determines if the requested resource should be handled by a web flow.
- If no flow handler is found, the next HandlerMapping in the chain is queried.
- This is generally the DefaultAnnotationHandlerMapping, which consults explicit @RequestMapping rules defined inside annotated Spring MVC Controllers.
-
-
- Setting up the HandlerMapping chain is a one-time configuration step, and makes it easy to plug in different types of handlers and mapping strategies.
- A typical HandlerMapping chain for Spring web applications looks like:
-
-
-
- <!-- Maps requests to flows in the flowRegistry; for example, a request for resource /hotels/booking maps to a flow with id "hotels/booking"
- If no flow is found with that id, Spring MVC proceeds to the next HandlerMapping (order=1 below). -->
- <bean id="flowMappings" class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
- <property name="order" value="0" />
- <property name="flowRegistry" ref="flowRegistry" />
- </bean>
-
- <!-- Maps requests to @Controllers based on @RequestMapping("path") annotation values
- If no annotation-based path mapping is found, Spring MVC proceeds to the next HandlerMapping (order=2 below). -->
- <bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
- <property name="order" value="1" />
- </bean>
-
-
-
- Once a request has been mapped to a handler object such as a @Controller of web flow, the DispatcherServlet uses the HandlerAdapter registered for that kind of handler to invoke it.
- This decouples the DispatcherServlet from specific handler implementations, which allows Spring MVC to support different controller technologies in an extensible manner.
- As a one-time configuration step, a typical Spring web application registers HandlerAdapters that know how to invoke @Controllers and web flows when they are mapped:
-
-
-
- <!-- Enables annotated @Controllers; responsible for invoking an annotated POJO @Controller when one is mapped. -->
- <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" />
-
- <!-- Enables web flows; responsible for calling the Spring Web Flow system to execute a flow when one is mapped. -->
- <bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
- <property name="flowExecutor" ref="flowExecutor" />
- </bean>
-
-
-
- To illustrate a typical DispatcherServlet pipeline, the following graphic illustrates the sequence of events that happen in this application when the /tutorial resource is requested, which is handled by the web flow you are interacting with right now:
- " />
-
-
- In this scenario, the FlowHandlerMapping returned the tutorial flow which was then invoked by the FlowHandlerAdapter.
-
-
- The following graphic shows the sequence in this application when the /welcome resource is requested, which is handled by the annotated WelcomeController:
- " />
-
-
- In this scenario, the FlowHandlerMapping returned null because the /welcome resource was not mapped to a web flow.
- The DefaultAnnotationHandlerMapping was then queried and returned the WelcomeController, which was invoked by the AnnotationMethodHandlerAdapter.
-
-
- The main point to understand here is there is one-time configuration that enables full customization of the DispatcherServlet processing pipeline.
- Once this configuration is established, you simply create new controllers and web flows, and they get picked up and hooked into the pipeline automatically.
- No other configuration is required.
-
-
-
-
- How are flows authored?
-
-
- 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.
-
-
-
-
- Why XML?
-
-
- 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 appropriate for general programming.
- This is why your flows should invoke actions written in Java or Groovy to carry out application behaviors.
-
-
-
-
\ No newline at end of file
diff --git a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowWhatsNext.jsp b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowWhatsNext.jsp
deleted file mode 100644
index 5ae21c6b..00000000
--- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/tutorial/webflowWhatsNext.jsp
+++ /dev/null
@@ -1,106 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ page session="false" %>
-
-
- Getting Started with Spring Web Flow: Where To Go From Here
- " type="text/css" />
- " type="text/css" />
- ">
- ">
- ">
-
-
-"/>
-
- Where To Go with From Here
-
-
- Spring Web Flow is an extremely powerful and easy to use controller framework. This tutorial has just scratched the surface of what you can do with the technology.
- Checkout these additional resources as you continue your Spring Web Flow journey.
-
-
- Reference Manual
-
-
- The Spring Web Flow reference manual is the definitive guide to the Spring Web Flow feature set.
- Use it as an up-to-date flow definition language reference, as well as for documentation on the various configuration options.
-
-
- Samples
-
-
- Additional samples are available showing Web Flow applied for various use cases.
- These samples illustrate additional features such as Hibernate, Security, Ajax, JSF, and Portlet integration.
- A natural next step from this tutorial is to walk-through these sample applications, supplementing with reference manual documentation as you go.
-
-
- In addition, this getting-started sample provides a solid template for a new Spring web project that uses Web Flow.
-
-
- Training
-
-
- SpringSource offers a comprehensive training course on developing rich web applications with Spring that covers Spring Web Flow in depth.
- This training also prepares you to become a SpringSource Certified Web Specialist.
-
-
- Community
-
-
- Spring Web Flow has an vibrant community forum at http://forum.springsource.org.
- There you can interact with community members and discuss ways to enhance and improve the project.
- We also encourage community members to submit tickets when they discover bugs, have ideas for enhancements, or wish to contribute patches or documentation.
- Web Flow, like all Spring projects, depends you the community to be successful!
-
-
- Enterprise Support
-
-
- SpringSource provides 24x7 support on the Spring projects, including Spring Web Flow, as part of SpringSource Enterprise.
- This subscription also includes licenses for the SpringSource Tool Suite IDE and SpringSource Application Management Suite.
-
-
- Related Projects
-
-
- There are a number of exciting Spring projects that either build on Spring Web Flow or have grown out of the project. Be sure to check out:
-
-
-
-
Spring Faces
-
- If JSF is the right choice for your team, Spring Faces uses Web Flow to make working with JSF more pleasant and more productive.
-
-
-
-
Spring JavaScript
-
- If you have Ajax requirements, Spring JavaScript helps you integrate the Dojo Toolkit into your application and provides a simple API for writing unobtrusive JavaScript and implementing common Ajax scenarios.
- You can use it inside and outside of a Web Flow environment.
-
-
-
-
Spring Security
-
- Spring Security is a comprehensive and portable Java security framework, and Web Flow provides native support for securing flows with this technology.
-
-
-
-
Spring BlazeDS Integration
-
- The Spring BlazeDS Integration project makes it easy to connect a Flex client to a Spring-powered server using Adobe's BlazeDS and LiveCycle DS technologies.
-
-
-
-
-We sincerely hope you enjoyed this tutorial. We wish you great success and lots of fun getting results with Spring Web Flow on your development projects!
-
-
-Keith Donald
-Spring Web Flow project lead
-
-
-
\ No newline at end of file
diff --git a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/web.xml b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/web.xml
deleted file mode 100644
index bbb23a4b..00000000
--- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/web.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- Spring MVC Dispatcher Servlet
- org.springframework.web.servlet.DispatcherServlet
-
- contextConfigLocation
-
- /WEB-INF/spring/*.xml
-
-
- 1
-
-
-
-
- Spring MVC Dispatcher Servlet
- /app/*
-
-
-
-
- Resources Servlet
- org.springframework.js.resource.ResourceServlet
- 0
-
-
-
-
- Resources Servlet
- /resources/*
-
-
-
\ No newline at end of file
diff --git a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/welcome.jsp b/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/welcome.jsp
deleted file mode 100644
index 4ab81849..00000000
--- a/spring-webflow-samples/getting-started-with-spring-webflow/src/main/webapp/WEB-INF/welcome.jsp
+++ /dev/null
@@ -1,25 +0,0 @@
-<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
-<%@ page session="false" %>
-
-
- Getting Started with Spring Web Flow
- " type="text/css" />
-
-
-"/>
-
- Congratulations! You're running Spring!
-
-
Welcome to the Getting Started with Spring Web Flow tutorial
-
- This tutorial provides a guide to getting up and running with Spring Web Flow in 10 minutes.
- The tutorial itself is implemented as a web flow.
- Step 1 of the tutorial will provide a brief overview of the Spring Web Flow project.
- Future steps will guide you through the basics of integrating Web Flow into your own Spring-powered web application.
- Enjoy!
-