SlideShare a Scribd company logo
1 of 23
Download to read offline
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

What's hot

Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...Zhe Li
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPCPrakash Divy
 
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...StreamNative
 
Apache spark-the-definitive-guide-excerpts-r1
Apache spark-the-definitive-guide-excerpts-r1Apache spark-the-definitive-guide-excerpts-r1
Apache spark-the-definitive-guide-excerpts-r1AjayRawat971036
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSam Brannen
 
Clean architectures with fast api pycones
Clean architectures with fast api   pyconesClean architectures with fast api   pycones
Clean architectures with fast api pyconesAlvaro Del Castillo
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring SessionDavid Gómez García
 
Cloud computing for Teachers and Students
Cloud computing for Teachers and StudentsCloud computing for Teachers and Students
Cloud computing for Teachers and StudentsMukesh Tekwani
 
Introduction to Structured Streaming
Introduction to Structured StreamingIntroduction to Structured Streaming
Introduction to Structured StreamingKnoldus Inc.
 
Spark Summit EU 2015: SparkUI visualization: a lens into your application
Spark Summit EU 2015: SparkUI visualization: a lens into your applicationSpark Summit EU 2015: SparkUI visualization: a lens into your application
Spark Summit EU 2015: SparkUI visualization: a lens into your applicationDatabricks
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxNexThoughts Technologies
 
Historical development of cloud computing
Historical development of cloud computingHistorical development of cloud computing
Historical development of cloud computinggaurav jain
 
CS8791 Cloud Computing - Question Bank
CS8791 Cloud Computing - Question BankCS8791 Cloud Computing - Question Bank
CS8791 Cloud Computing - Question Bankpkaviya
 

What's hot (20)

Virtual box
Virtual boxVirtual box
Virtual box
 
Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...Introduction to Django REST Framework, an easy way to build REST framework in...
Introduction to Django REST Framework, an easy way to build REST framework in...
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPC
 
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
Blue-green deploys with Pulsar & Envoy in an event-driven microservice ecosys...
 
Apache spark
Apache sparkApache spark
Apache spark
 
Apache spark-the-definitive-guide-excerpts-r1
Apache spark-the-definitive-guide-excerpts-r1Apache spark-the-definitive-guide-excerpts-r1
Apache spark-the-definitive-guide-excerpts-r1
 
Soap vs rest
Soap vs restSoap vs rest
Soap vs rest
 
Spring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. RESTSpring Web Services: SOAP vs. REST
Spring Web Services: SOAP vs. REST
 
Clean architectures with fast api pycones
Clean architectures with fast api   pyconesClean architectures with fast api   pycones
Clean architectures with fast api pycones
 
Managing user's data with Spring Session
Managing user's data with Spring SessionManaging user's data with Spring Session
Managing user's data with Spring Session
 
Autoscaling on Kubernetes
Autoscaling on KubernetesAutoscaling on Kubernetes
Autoscaling on Kubernetes
 
Cloud computing for Teachers and Students
Cloud computing for Teachers and StudentsCloud computing for Teachers and Students
Cloud computing for Teachers and Students
 
Restful web services ppt
Restful web services pptRestful web services ppt
Restful web services ppt
 
Introduction to Structured Streaming
Introduction to Structured StreamingIntroduction to Structured Streaming
Introduction to Structured Streaming
 
Java Class Loader
Java Class LoaderJava Class Loader
Java Class Loader
 
Spark Summit EU 2015: SparkUI visualization: a lens into your application
Spark Summit EU 2015: SparkUI visualization: a lens into your applicationSpark Summit EU 2015: SparkUI visualization: a lens into your application
Spark Summit EU 2015: SparkUI visualization: a lens into your application
 
Microservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & ReduxMicroservice Architecture using Spring Boot with React & Redux
Microservice Architecture using Spring Boot with React & Redux
 
Historical development of cloud computing
Historical development of cloud computingHistorical development of cloud computing
Historical development of cloud computing
 
CS8791 Cloud Computing - Question Bank
CS8791 Cloud Computing - Question BankCS8791 Cloud Computing - Question Bank
CS8791 Cloud Computing - Question Bank
 
Introduction to gRPC
Introduction to gRPCIntroduction to gRPC
Introduction to gRPC
 

Viewers also liked (17)

Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
RESTEasy
RESTEasyRESTEasy
RESTEasy
 
JFree chart
JFree chartJFree chart
JFree chart
 
Hamcrest
HamcrestHamcrest
Hamcrest
 
Grails with swagger
Grails with swaggerGrails with swagger
Grails with swagger
 
Introduction to gradle
Introduction to gradleIntroduction to gradle
Introduction to gradle
 
Introduction to es6
Introduction to es6Introduction to es6
Introduction to es6
 
Jsoup
JsoupJsoup
Jsoup
 
Jmh
JmhJmh
Jmh
 
Introduction to thymeleaf
Introduction to thymeleafIntroduction to thymeleaf
Introduction to thymeleaf
 
Progressive Web-App (PWA)
Progressive Web-App (PWA)Progressive Web-App (PWA)
Progressive Web-App (PWA)
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Actors model in gpars
Actors model in gparsActors model in gpars
Actors model in gpars
 
Cosmos DB Service
Cosmos DB ServiceCosmos DB Service
Cosmos DB Service
 
Unit test-using-spock in Grails
Unit test-using-spock in GrailsUnit test-using-spock in Grails
Unit test-using-spock in Grails
 
Apache tika
Apache tikaApache tika
Apache tika
 
Vertx
VertxVertx
Vertx
 

Similar to Spring Web Flow

Spring Web Flow Grail's Plugin
Spring Web Flow Grail's PluginSpring Web Flow Grail's Plugin
Spring Web Flow Grail's PluginC-DAC
 
Spring Web Flow. A little flow of happiness.
Spring Web Flow. A little flow of happiness.Spring Web Flow. A little flow of happiness.
Spring Web Flow. A little flow of happiness.Alex Tumanoff
 
Silicon Valley Code Camp - JSF Controller for Reusability
Silicon Valley Code Camp - JSF Controller for ReusabilitySilicon Valley Code Camp - JSF Controller for Reusability
Silicon Valley Code Camp - JSF Controller for Reusabilityjcruizjdev
 
Introduction to Srping Web Flow
Introduction to Srping Web Flow Introduction to Srping Web Flow
Introduction to Srping Web Flow Emad Omara
 
Web flowpresentation
Web flowpresentationWeb flowpresentation
Web flowpresentationRoman Brovko
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in detailsAyesha Khan
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Ayesha Khan
 
Spring Web Webflow
Spring Web WebflowSpring Web Webflow
Spring Web WebflowEmprovise
 
Asp.net life cycle in depth
Asp.net life cycle in depthAsp.net life cycle in depth
Asp.net life cycle in depthsonia merchant
 
[@NaukriEngineering] Flux Architecture
[@NaukriEngineering] Flux Architecture[@NaukriEngineering] Flux Architecture
[@NaukriEngineering] Flux ArchitectureNaukri.com
 
Unidirectional Data Flow Architecture (Redux) in Swift
Unidirectional Data Flow Architecture (Redux) in SwiftUnidirectional Data Flow Architecture (Redux) in Swift
Unidirectional Data Flow Architecture (Redux) in SwiftSeyhun AKYUREK
 
Oracle ADF Task Flows for Beginners
Oracle ADF Task Flows for BeginnersOracle ADF Task Flows for Beginners
Oracle ADF Task Flows for BeginnersDataNext Solutions
 
Transaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in JavaTransaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in JavaErsen Öztoprak
 
Flux - An open sourced Workflow orchestrator from Flipkart
Flux - An open sourced Workflow orchestrator from FlipkartFlux - An open sourced Workflow orchestrator from Flipkart
Flux - An open sourced Workflow orchestrator from FlipkartShyam Kumar Akirala
 
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...Flink Forward
 
Sessionizing Uber Trips in Realtime - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime  - Flink Forward '18, BerlinSessionizing Uber Trips in Realtime  - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime - Flink Forward '18, BerlinAmey Chaugule
 

Similar to Spring Web Flow (20)

Spring Web Flow Grail's Plugin
Spring Web Flow Grail's PluginSpring Web Flow Grail's Plugin
Spring Web Flow Grail's Plugin
 
Spring Web Flow. A little flow of happiness.
Spring Web Flow. A little flow of happiness.Spring Web Flow. A little flow of happiness.
Spring Web Flow. A little flow of happiness.
 
Silicon Valley Code Camp - JSF Controller for Reusability
Silicon Valley Code Camp - JSF Controller for ReusabilitySilicon Valley Code Camp - JSF Controller for Reusability
Silicon Valley Code Camp - JSF Controller for Reusability
 
Introduction to Srping Web Flow
Introduction to Srping Web Flow Introduction to Srping Web Flow
Introduction to Srping Web Flow
 
Web flowpresentation
Web flowpresentationWeb flowpresentation
Web flowpresentation
 
Asp dot net lifecycle in details
Asp dot net lifecycle in detailsAsp dot net lifecycle in details
Asp dot net lifecycle in details
 
Why ASP.NET Development is Important?
Why ASP.NET Development is Important?Why ASP.NET Development is Important?
Why ASP.NET Development is Important?
 
Windows Workflow Foundation
Windows Workflow FoundationWindows Workflow Foundation
Windows Workflow Foundation
 
Spring Web Webflow
Spring Web WebflowSpring Web Webflow
Spring Web Webflow
 
Asp.net life cycle in depth
Asp.net life cycle in depthAsp.net life cycle in depth
Asp.net life cycle in depth
 
Grails services
Grails servicesGrails services
Grails services
 
Discrete event-simulation
Discrete event-simulationDiscrete event-simulation
Discrete event-simulation
 
[@NaukriEngineering] Flux Architecture
[@NaukriEngineering] Flux Architecture[@NaukriEngineering] Flux Architecture
[@NaukriEngineering] Flux Architecture
 
Unidirectional Data Flow Architecture (Redux) in Swift
Unidirectional Data Flow Architecture (Redux) in SwiftUnidirectional Data Flow Architecture (Redux) in Swift
Unidirectional Data Flow Architecture (Redux) in Swift
 
Asp.net control
Asp.net controlAsp.net control
Asp.net control
 
Oracle ADF Task Flows for Beginners
Oracle ADF Task Flows for BeginnersOracle ADF Task Flows for Beginners
Oracle ADF Task Flows for Beginners
 
Transaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in JavaTransaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in Java
 
Flux - An open sourced Workflow orchestrator from Flipkart
Flux - An open sourced Workflow orchestrator from FlipkartFlux - An open sourced Workflow orchestrator from Flipkart
Flux - An open sourced Workflow orchestrator from Flipkart
 
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
Flink Forward Berlin 2018: Amey Chaugule - "Threading Needles in a Haystack: ...
 
Sessionizing Uber Trips in Realtime - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime  - Flink Forward '18, BerlinSessionizing Uber Trips in Realtime  - Flink Forward '18, Berlin
Sessionizing Uber Trips in Realtime - Flink Forward '18, Berlin
 

More from NexThoughts Technologies (20)

Alexa skill
Alexa skillAlexa skill
Alexa skill
 
GraalVM
GraalVMGraalVM
GraalVM
 
Docker & kubernetes
Docker & kubernetesDocker & kubernetes
Docker & kubernetes
 
Apache commons
Apache commonsApache commons
Apache commons
 
HazelCast
HazelCastHazelCast
HazelCast
 
MySQL Pro
MySQL ProMySQL Pro
MySQL Pro
 
Swagger
SwaggerSwagger
Swagger
 
Solid Principles
Solid PrinciplesSolid Principles
Solid Principles
 
Arango DB
Arango DBArango DB
Arango DB
 
Jython
JythonJython
Jython
 
Introduction to TypeScript
Introduction to TypeScriptIntroduction to TypeScript
Introduction to TypeScript
 
Smart Contract samples
Smart Contract samplesSmart Contract samples
Smart Contract samples
 
My Doc of geth
My Doc of gethMy Doc of geth
My Doc of geth
 
Geth important commands
Geth important commandsGeth important commands
Geth important commands
 
Ethereum genesis
Ethereum genesisEthereum genesis
Ethereum genesis
 
Ethereum
EthereumEthereum
Ethereum
 
Springboot Microservices
Springboot MicroservicesSpringboot Microservices
Springboot Microservices
 
An Introduction to Redux
An Introduction to ReduxAn Introduction to Redux
An Introduction to Redux
 
Google authentication
Google authenticationGoogle authentication
Google authentication
 
Java 9 Features
Java 9 FeaturesJava 9 Features
Java 9 Features
 

Recently uploaded

A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityIES VE
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessWSO2
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfROWELL MARQUINA
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Jeffrey Haguewood
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - AvrilIvanti
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxfnnc6jmgwh
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Mark Simos
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentMahmoud Rabie
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesBernd Ruecker
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesKari Kakkonen
 

Recently uploaded (20)

A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Decarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a realityDecarbonising Buildings: Making a net-zero built environment a reality
Decarbonising Buildings: Making a net-zero built environment a reality
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
Accelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with PlatformlessAccelerating Enterprise Software Engineering with Platformless
Accelerating Enterprise Software Engineering with Platformless
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 
QMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdfQMMS Lesson 2 - Using MS Excel Formula.pdf
QMMS Lesson 2 - Using MS Excel Formula.pdf
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
Email Marketing Automation for Bonterra Impact Management (fka Social Solutio...
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Français Patch Tuesday - Avril
Français Patch Tuesday - AvrilFrançais Patch Tuesday - Avril
Français Patch Tuesday - Avril
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptxGenerative AI - Gitex v1Generative AI - Gitex v1.pptx
Generative AI - Gitex v1Generative AI - Gitex v1.pptx
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
Tampa BSides - The No BS SOC (slides from April 6, 2024 talk)
 
Digital Tools & AI in Career Development
Digital Tools & AI in Career DevelopmentDigital Tools & AI in Career Development
Digital Tools & AI in Career Development
 
QCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architecturesQCon London: Mastering long-running processes in modern architectures
QCon London: Mastering long-running processes in modern architectures
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
Testing tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examplesTesting tools and AI - ideas what to try with some tool examples
Testing tools and AI - ideas what to try with some tool examples
 

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 !!