SlideShare a Scribd company logo
Spring Web Flow
A little flow of happiness.
Presented by – Vikrant
Agenda
 Why Web – Flow ?
 Spring Web-Flow (Basic Introduction)
 Spring Web-Flow Grails Plugin
 Demo
Introduction
Spring Web Flow builds on Spring MVC and allows
implementing the "flows" of a web application. A flow
encapsulates a sequence of steps that guide a user through the
execution of some business task. It spans multiple HTTP
requests, has state, deals with transactional data, is reusable.
Stateful web applications with controlled navigation such as checking
in for a flight, applying for a loan, shopping cart checkout and many
more.
These scenarios have in common is one or more of the following traits:
● There is a clear start and an end point.
● The user must go through a set of screens in a specific order.
● The changes are not finalized until the last step.
● Once complete it shouldn't be possible to repeat a transaction accidentally
Disadvantages of MVC
 Visualizing the flow is very difficult
 Mixed navigation and view
 Overall navigation rules complexity
 All-in-one navigation storage
 Lack of state control/navigation customization
Use Case
Request Diagram
Basic Components
● Flow – A flow defined as a complete life-span of all States transitions.
● States - Within a flow stuff happens. Either the application performs some logic, the
user answers a question or fills out a form, or a decision is made to determine the next
step to take. The points in the flow where these things happen are known as states.
Five different kinds of state: View, Active, Decision, Subflow, and End.
● Transitions - A view state, action state, or subflow state may have any number of
transitions that direct them to other states.
● Flow Data - As a flow progresses, data is either collected, created, or otherwise
manipulated. Depending on the scope of the data, it may be carried around for periods of
time to be processed or evaluated within the flow
● Events – Events are responsible for transition in between states.
Types of State
View States : A view state displays information to a user or obtains user input
using a form. (e.g. JSP.,jsf, gsp etc)
Action States : Action states are where actions are perfomed by the spring beans.
The action state transitions to another state. The action states generally have an
evaluate property that describes what needs to be done.
Decision States: A decision state has two transitions depending on whether the
decision evaluates to true or false.
Subflow States :It may be advantageous to call another flow from one flow to
complete some steps. Passing inputs and expecting outputs.
End States : The end state signifies the end of flow. If the end state is part of a root
flow then the execution is ended. However, if its part of a sub flow then the root flow
is resumed.
Note :­ Once a flow has ended it can only be resumed from the start state, in this case 
showCart, and not from any other state.
Grails Flow Scopes
Grails flows have five different scopes you can utilize:
● request - Stores an object for the scope of the current request
● flash - Stores the object for the current and next request only
● flow - Stores objects for the scope of the flow, removing them when the flow
reaches an end state
● conversation - Stores objects for the scope of the conversation including the
root flow and nested subflows
● session - Stores objects in the user's session
Events
Exception Handling
● Transition on exception
on(Exception).to('error')
● Custom exception handler
on(MyCustomException).to('error')
Dependencies for Spring/Grails
Spring Maven/Gradle Dependencies
Maven POM
<dependencies>
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.4.4.RELEASE</version>
</dependency>
</dependencies>
Gradle
dependencies {
compile 'org.springframework.webflow:spring-webflow:2.4.4.RELEASE'
}
Grails Plugin Installation
plugins{
....
compile ":webflow:2.1.0"
.....
}
Grails Web Flow Plugin
How to define a flow...
class BookController {
def shoppingCartFlow ={ // add flow to action in Controller
state {
}
…
state {
}
...
}
}
Here, Shopping Cart will be considered as a action and will work like a flow.
Note - Views are stored within a directory that matches the name of the flow:
grails-app/views/book/shoppingCart.
URL - localhost:8080/applicationName/book/shoppingCart
Grails Web Flow Plugin
How to define a state...
def shoppingCartFlow ={
showCart {
on("checkout").to "enterPersonalDetails"
on("continueShopping").to "displayCatalogue"
}
…
displayCatalogue {
redirect(controller: "catalogue", action: "show")
}
displayInvoice()
}
Here, “showCart” and “displayCatelog” will be considered as a state
URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
Grails Web Flow Plugin
Action State ...
enterPersonalDetails {
on("submit") {
def p = new Person(params)
flow.person = p
if (!p.validate()) return error()
}.to "enterShipping"
on("return").to "showCart"
}
Here, action{....} state used to perform some action when it enters into the
ShippingNeeded State
URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
enterPersonalDetails {
action { //action State defined and used to
perform stuffs
}
on("submit") .to "enterShipping"
on("return").to "showCart"
}
Grails Web Flow Plugin
Decision State ...
shippingNeeded {
action { //action State defined and used to perform stuffs
if (params.shippingRequired) yes()
else no()
}
on("yes").to "enterShipping"
on("no").to "enterPayment"
}
Here, action{....} state used to perform some action when it enters into the
ShippingNeeded State
URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
Grails Web Flow Plugin
Sub-Flow State ...
def extendedSearchFlow = {
startExtendedSearch {
on("findMore").to "searchMore"
on("searchAgain").to "noResults"
}
searchMore {
Action {
.........
........
}
on("success").to "moreResults"
on("error").to "noResults"
}
moreResults()
noResults()
}
Here, extendedSearchFlow state used as sub-state
extendedSearch {
// Extended search subflow
subflow(controller: "searchExtensions",
action: "extendedSearch")
on("moreResults").to
"displayMoreResults"
on("noResults").to
"displayNoMoreResults"
}
displayMoreResults()
displayNoMoreResults()
Grails Web Flow Plugin
Transition ...
def shoppingCartFlow ={
showCart {
on("checkout").to "enterPersonalDetails" // Transition from one flow to another
on("continueShopping").to "displayCatalogue"
}
…
displayCatalogue {
redirect(controller: "catalogue", action: "show")
}
displayInvoice()
}
Here, On().to() used to transition from one state to another defined in sequence.
URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
Grails Web Flow Plugin
Take a special care...
● Once a flow has ended it can only be resumed from the start state
● Throughout the flow life-cycle each html/grails control name should be unique.
● Maintain JSessionId is maintained throughout the flow execution.
● Spring Security is checked only before entering into a flow not in between the states
of executing flow
● When placing objects in flash, flow or conversation scope they must implement
java.io.Serializable or an exception will be thrown
● built-in error() and success() methods.
● Any Exception class in-heirarchy or CustomException Handler Class used to handle
Exceptions
References
1. https://dzone.com/refcardz/spring-web-flow
2. http://projects.spring.io/spring-webflow/
3. https://grails-plugins.github.io/grails-webflow-plugin/guide/
4. https://grails.org/plugin/webflow
Questions ?
Take a look aside practically
Demo !!
Thank You !!

More Related Content

PPTX
Spring Web Webflow
PPTX
Visitor Pattern
PDF
facebook architecture for 600M users
PDF
OASIS TOSCA: Cloud Portability and Lifecycle Management
PDF
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
PDF
Spring MVC
PPTX
Session And Cookies In Servlets - Java
Spring Web Webflow
Visitor Pattern
facebook architecture for 600M users
OASIS TOSCA: Cloud Portability and Lifecycle Management
Angular Directives | Angular 2 Custom Directives | Angular Tutorial | Angular...
Spring MVC
Session And Cookies In Servlets - Java

What's hot (20)

PDF
Spring 2.0 技術手冊第七章 - Spring Web MVC 框架
PDF
Istio : Service Mesh
PDF
Servlet vs Reactive Stacks in 5 Use Cases
PPTX
Kubernetes fundamentals
PPTX
ADP - Chapter 2 Exploring the java Servlet Technology
PDF
Servlet Filter
PPTX
Spring 3.x - Spring MVC - Advanced topics
PPT
Listeners and filters in servlet
PPT
Presentation Spring, Spring MVC
PDF
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
PDF
An overview of the Kubernetes architecture
ODP
Dependency Injection in Spring in 10min
PDF
Spring Framework - Spring Security
PDF
PPTX
FIWARE: Managing Context Information at large scale
PDF
The automation challenge: Kubernetes Operators vs Helm Charts
PDF
Vue.js for beginners
PPTX
REST Easy with Django-Rest-Framework
PDF
Module: Welcome to Web 3.0
ODP
Introduction To RabbitMQ
Spring 2.0 技術手冊第七章 - Spring Web MVC 框架
Istio : Service Mesh
Servlet vs Reactive Stacks in 5 Use Cases
Kubernetes fundamentals
ADP - Chapter 2 Exploring the java Servlet Technology
Servlet Filter
Spring 3.x - Spring MVC - Advanced topics
Listeners and filters in servlet
Presentation Spring, Spring MVC
[네이버오픈소스세미나] Pinpoint를 이용해서 서버리스 플랫폼 Apache Openwhisk 트레이싱하기 - 오승현
An overview of the Kubernetes architecture
Dependency Injection in Spring in 10min
Spring Framework - Spring Security
FIWARE: Managing Context Information at large scale
The automation challenge: Kubernetes Operators vs Helm Charts
Vue.js for beginners
REST Easy with Django-Rest-Framework
Module: Welcome to Web 3.0
Introduction To RabbitMQ
Ad

Viewers also liked (16)

PDF
Reactive java - Reactive Programming + RxJava
PPTX
PPTX
Grails with swagger
PDF
Introduction to gradle
PPTX
Introduction to es6
PDF
Introduction to thymeleaf
PPTX
Progressive Web-App (PWA)
PDF
Java 8 features
PPTX
Actors model in gpars
PDF
Cosmos DB Service
PDF
Unit test-using-spock in Grails
PPTX
Reactive java - Reactive Programming + RxJava
Grails with swagger
Introduction to gradle
Introduction to es6
Introduction to thymeleaf
Progressive Web-App (PWA)
Java 8 features
Actors model in gpars
Cosmos DB Service
Unit test-using-spock in Grails
Ad

Similar to Spring Web Flow (20)

ODP
Spring Web Flow Grail's Plugin
PDF
Web flowpresentation
PDF
GR8Conf 2011: Grails Webflow
PPTX
Spring Web Flow. A little flow of happiness.
PPTX
Introduction to Srping Web Flow
PPTX
Spring Web flow. A little flow of happiness
PPT
Silicon Valley Code Camp - JSF Controller for Reusability
PDF
Spring webflow-reference
PDF
Spring Framework - Web Flow
PPT
Grails Introduction - IJTC 2007
PPTX
The flow developmodel in web application ment
PPTX
Talkin bout Flow - Meighan Brodkey WIT Devs
PPTX
Flow Presentation vFINAL
PDF
JahiaOne - MVC in Jahia 7 Using Spring Web Flow
PPT
Project Description Of Incident Management System Developed by PRS (CRIS) , N...
PPTX
J2EE Patterns
PPTX
Salesforce Flows Architecture Best Practices
PPTX
Understanding flows and subflows in mule
PDF
Spring tutorial
PDF
Struts2
Spring Web Flow Grail's Plugin
Web flowpresentation
GR8Conf 2011: Grails Webflow
Spring Web Flow. A little flow of happiness.
Introduction to Srping Web Flow
Spring Web flow. A little flow of happiness
Silicon Valley Code Camp - JSF Controller for Reusability
Spring webflow-reference
Spring Framework - Web Flow
Grails Introduction - IJTC 2007
The flow developmodel in web application ment
Talkin bout Flow - Meighan Brodkey WIT Devs
Flow Presentation vFINAL
JahiaOne - MVC in Jahia 7 Using Spring Web Flow
Project Description Of Incident Management System Developed by PRS (CRIS) , N...
J2EE Patterns
Salesforce Flows Architecture Best Practices
Understanding flows and subflows in mule
Spring tutorial
Struts2

More from NexThoughts Technologies (20)

PDF
PDF
Docker & kubernetes
PDF
Apache commons
PDF
Microservice Architecture using Spring Boot with React & Redux
PDF
Solid Principles
PDF
Introduction to TypeScript
PDF
Smart Contract samples
PDF
My Doc of geth
PDF
Geth important commands
PDF
Ethereum genesis
PPTX
Springboot Microservices
PDF
An Introduction to Redux
PPTX
Google authentication
Docker & kubernetes
Apache commons
Microservice Architecture using Spring Boot with React & Redux
Solid Principles
Introduction to TypeScript
Smart Contract samples
My Doc of geth
Geth important commands
Ethereum genesis
Springboot Microservices
An Introduction to Redux
Google authentication

Recently uploaded (20)

PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Unlocking AI with Model Context Protocol (MCP)
PPT
Teaching material agriculture food technology
PPTX
MYSQL Presentation for SQL database connectivity
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
KodekX | Application Modernization Development
PDF
Advanced IT Governance
PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
GamePlan Trading System Review: Professional Trader's Honest Take
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Empathic Computing: Creating Shared Understanding
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PDF
Modernizing your data center with Dell and AMD
PDF
cuic standard and advanced reporting.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Unlocking AI with Model Context Protocol (MCP)
Teaching material agriculture food technology
MYSQL Presentation for SQL database connectivity
The Rise and Fall of 3GPP – Time for a Sabbatical?
KodekX | Application Modernization Development
Advanced IT Governance
Chapter 3 Spatial Domain Image Processing.pdf
GamePlan Trading System Review: Professional Trader's Honest Take
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Spectral efficient network and resource selection model in 5G networks
[발표본] 너의 과제는 클라우드에 있어_KTDS_김동현_20250524.pdf
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Diabetes mellitus diagnosis method based random forest with bat algorithm
Empathic Computing: Creating Shared Understanding
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
Modernizing your data center with Dell and AMD
cuic standard and advanced reporting.pdf
The AUB Centre for AI in Media Proposal.docx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025

Spring Web Flow

  • 2. Agenda  Why Web – Flow ?  Spring Web-Flow (Basic Introduction)  Spring Web-Flow Grails Plugin  Demo
  • 3. Introduction Spring Web Flow builds on Spring MVC and allows implementing the "flows" of a web application. A flow encapsulates a sequence of steps that guide a user through the execution of some business task. It spans multiple HTTP requests, has state, deals with transactional data, is reusable. Stateful web applications with controlled navigation such as checking in for a flight, applying for a loan, shopping cart checkout and many more. These scenarios have in common is one or more of the following traits: ● There is a clear start and an end point. ● The user must go through a set of screens in a specific order. ● The changes are not finalized until the last step. ● Once complete it shouldn't be possible to repeat a transaction accidentally
  • 4. Disadvantages of MVC  Visualizing the flow is very difficult  Mixed navigation and view  Overall navigation rules complexity  All-in-one navigation storage  Lack of state control/navigation customization
  • 7. Basic Components ● Flow – A flow defined as a complete life-span of all States transitions. ● States - Within a flow stuff happens. Either the application performs some logic, the user answers a question or fills out a form, or a decision is made to determine the next step to take. The points in the flow where these things happen are known as states. Five different kinds of state: View, Active, Decision, Subflow, and End. ● Transitions - A view state, action state, or subflow state may have any number of transitions that direct them to other states. ● Flow Data - As a flow progresses, data is either collected, created, or otherwise manipulated. Depending on the scope of the data, it may be carried around for periods of time to be processed or evaluated within the flow ● Events – Events are responsible for transition in between states.
  • 8. Types of State View States : A view state displays information to a user or obtains user input using a form. (e.g. JSP.,jsf, gsp etc) Action States : Action states are where actions are perfomed by the spring beans. The action state transitions to another state. The action states generally have an evaluate property that describes what needs to be done. Decision States: A decision state has two transitions depending on whether the decision evaluates to true or false. Subflow States :It may be advantageous to call another flow from one flow to complete some steps. Passing inputs and expecting outputs. End States : The end state signifies the end of flow. If the end state is part of a root flow then the execution is ended. However, if its part of a sub flow then the root flow is resumed. Note :­ Once a flow has ended it can only be resumed from the start state, in this case  showCart, and not from any other state.
  • 9. Grails Flow Scopes Grails flows have five different scopes you can utilize: ● request - Stores an object for the scope of the current request ● flash - Stores the object for the current and next request only ● flow - Stores objects for the scope of the flow, removing them when the flow reaches an end state ● conversation - Stores objects for the scope of the conversation including the root flow and nested subflows ● session - Stores objects in the user's session
  • 11. Exception Handling ● Transition on exception on(Exception).to('error') ● Custom exception handler on(MyCustomException).to('error')
  • 12. Dependencies for Spring/Grails Spring Maven/Gradle Dependencies Maven POM <dependencies> <dependency> <groupId>org.springframework.webflow</groupId> <artifactId>spring-webflow</artifactId> <version>2.4.4.RELEASE</version> </dependency> </dependencies> Gradle dependencies { compile 'org.springframework.webflow:spring-webflow:2.4.4.RELEASE' } Grails Plugin Installation plugins{ .... compile ":webflow:2.1.0" ..... }
  • 13. Grails Web Flow Plugin How to define a flow... class BookController { def shoppingCartFlow ={ // add flow to action in Controller state { } … state { } ... } } Here, Shopping Cart will be considered as a action and will work like a flow. Note - Views are stored within a directory that matches the name of the flow: grails-app/views/book/shoppingCart. URL - localhost:8080/applicationName/book/shoppingCart
  • 14. Grails Web Flow Plugin How to define a state... def shoppingCartFlow ={ showCart { on("checkout").to "enterPersonalDetails" on("continueShopping").to "displayCatalogue" } … displayCatalogue { redirect(controller: "catalogue", action: "show") } displayInvoice() } Here, “showCart” and “displayCatelog” will be considered as a state URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
  • 15. Grails Web Flow Plugin Action State ... enterPersonalDetails { on("submit") { def p = new Person(params) flow.person = p if (!p.validate()) return error() }.to "enterShipping" on("return").to "showCart" } Here, action{....} state used to perform some action when it enters into the ShippingNeeded State URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14 enterPersonalDetails { action { //action State defined and used to perform stuffs } on("submit") .to "enterShipping" on("return").to "showCart" }
  • 16. Grails Web Flow Plugin Decision State ... shippingNeeded { action { //action State defined and used to perform stuffs if (params.shippingRequired) yes() else no() } on("yes").to "enterShipping" on("no").to "enterPayment" } Here, action{....} state used to perform some action when it enters into the ShippingNeeded State URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
  • 17. Grails Web Flow Plugin Sub-Flow State ... def extendedSearchFlow = { startExtendedSearch { on("findMore").to "searchMore" on("searchAgain").to "noResults" } searchMore { Action { ......... ........ } on("success").to "moreResults" on("error").to "noResults" } moreResults() noResults() } Here, extendedSearchFlow state used as sub-state extendedSearch { // Extended search subflow subflow(controller: "searchExtensions", action: "extendedSearch") on("moreResults").to "displayMoreResults" on("noResults").to "displayNoMoreResults" } displayMoreResults() displayNoMoreResults()
  • 18. Grails Web Flow Plugin Transition ... def shoppingCartFlow ={ showCart { on("checkout").to "enterPersonalDetails" // Transition from one flow to another on("continueShopping").to "displayCatalogue" } … displayCatalogue { redirect(controller: "catalogue", action: "show") } displayInvoice() } Here, On().to() used to transition from one state to another defined in sequence. URL - localhost:8080/applicationName/book/shoppingCart?execution=e3s14
  • 19. Grails Web Flow Plugin Take a special care... ● Once a flow has ended it can only be resumed from the start state ● Throughout the flow life-cycle each html/grails control name should be unique. ● Maintain JSessionId is maintained throughout the flow execution. ● Spring Security is checked only before entering into a flow not in between the states of executing flow ● When placing objects in flash, flow or conversation scope they must implement java.io.Serializable or an exception will be thrown ● built-in error() and success() methods. ● Any Exception class in-heirarchy or CustomException Handler Class used to handle Exceptions
  • 20. References 1. https://dzone.com/refcardz/spring-web-flow 2. http://projects.spring.io/spring-webflow/ 3. https://grails-plugins.github.io/grails-webflow-plugin/guide/ 4. https://grails.org/plugin/webflow
  • 22. Take a look aside practically Demo !!