- 浏览: 2488151 次
- 性别:
- 来自: 成都
文章分类
最新评论
-
nation:
你好,在部署Mesos+Spark的运行环境时,出现一个现象, ...
Spark(4)Deal with Mesos -
sillycat:
AMAZON Relatedhttps://www.godad ...
AMAZON API Gateway(2)Client Side SSL with NGINX -
sillycat:
sudo usermod -aG docker ec2-use ...
Docker and VirtualBox(1)Set up Shared Disk for Virtual Box -
sillycat:
Every Half an Hour30 * * * * /u ...
Build Home NAS(3)Data Redundancy -
sillycat:
3 List the Cron Job I Have>c ...
Build Home NAS(3)Data Redundancy
Spring WebFlow(1)Introduce to web flow and Sample
1. Install the flow edit plugin in STS
Eclipse plugin URL http://springide.org/updatesite
I only install the webflow related plugins.
2. Spring Web Flow 2.0 Introduce
The goal for this tool is to deal with the data/states across multi requests.
Spring Web Flow 1.x is a standalone tool supported Spring Web MVC, struts, JSF and etc. But the latest 2.0 is only for Spring Web MVC.
Web Flow can be cooperate with Spring Security with 'secured'.
3. Take Add to Cart Case as example
add this to my pom.xml
<!-- spring snapshot -->
<repositories>
<repository>
<id>springsource-repository</id>
<name>Spring Maven Releases, Milestones, and Snapshots</name>
<url>http://repo.springsource.org/snapshot</url>
</repository>
</repositories>
And the dependency:
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
Create a Web Flow Definition file order.xml:
<view-state id="viewCart">
<transition on="submit" to="viewOrder" />
</view-state>
<view-state id="viewOrder">
<transition to="viewConfirmed" on="confirm"></transition>
</view-state>
<view-state id="viewConfirmed">
<transition to="returnToIndex" on="returnToIndex"></transition>
</view-state>
<end-state id="returnToIndex"></end-state>
There are 5 types of states in Web Flow.
Action State,
View State,
Subflow State,
Decision State,
End State.
4. What Spring Web Flow brings to us
There are 3 typical scope in web development.
Session,
Application.
Request.
Spring Web Flow brings us 2 more:
flow: create while flow creation, end in flow destroyment, we can visit the data via 'flowScope'
conversation: mostly same as flow, but when the flow call a subflow, we can visit the data in subflow.
We have flow and conversation, they are useful but that will make the server slow.
5. Configure the Spring Web Flow 2.0 Basic Configuration
FlowRegistry is the repository of the flows. Every xml file of flow will be stored in FlowRegistry as FlowDefinition with key of ID.
FlowExecutor
This is the bean which will execute the flow.
Which flow will be executed? This will be decided by the URL and the flow Id.
http://localhost:8080/easywebflow/shopping will identify the flow with id shopping.
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="classpath:flows/shopping.xml"
id="shopping" />
<webflow:flow-location path="classpath:flows/addToCart.xml"
id="addToCart" />
</webflow:flow-registry>
<webflow:flow-executor id="flowExecutor" />
Spring Web Flow and Spring Web MVC work together
Spring Web MVC Process
Client send requests -----> Servlet Container(Tomcat) ------> Our Web Application(easywebflow) ------> Application Servlet(spring servlet) -------> DispatcherServlet (Spring IOC HandlerMapping) ------> Controller ------>View
There should be a handler/controller in HandlerMapping to deal with flow requests.
FlowHandler and FlowController
FlowBuilder Services
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name = "flowExecutor" ref="flowExecutor" />
</bean>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
<property name="order" value="1"/>
</bean>
<webflow:flow-builder-services id="flowBuilderServices"
view-factory-creator="mvcViewFactoryCreator" />
<bean id="mvcViewFactoryCreator"
class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="velocityViewResolver" />
</bean>
Use Unified EL to Implement the Logic
When will the logic code will be execute?
1. client sumibt the request include _eventId paramter.
2. invoke the framework point
3. execute the <action-state> element
Request consist of _eventId Parameter
<transition on="submit">
<evaluate expression="validator.validate()" />
</transition>
once submit is clicked, we will call the object validator method validate().
Invoke the Framework Point
flow start <on-start>
state entry <on-entry>
view render <on-render>
state exit <on-exit>
flow end <on-end>
<view-state id="viewCart" view="viewCart">
<on-render>
<evaluate expression="productService.getProducts()" result="viewScope.products" />
</on-render>
</view-state>
And we can get the viewScope data in the JSP files.
Execute the <action-state> Element
<action-state id="addToCart">
<evaluate expression="cart.addItem(productService.getProduct(productId))" />
<transition to="productAdded" />
</action-state>
How to Save the Data
flowScope
<evaluate expression="productService.getProducts()" result="flowScope.products" />
viewScope
requestScope
conversationScope
Use Subflow to Add To Cart
<view-state id="viewCart" view="viewCart">
<on-render>
<evaluate expression="productService.getProducts()" result="viewScope.products"/>
</on-render>
<transition on="submit" to="viewOrderDecistion">
</transition>
<transition on="addToCart" to="addProductToCart" />
</view-state>
<subflow-state id="addProductToCart" subflow="addToCart">
<transition on="productAdded" to="viewCart">
</transition>
</subflow-state>
Global Transition
we can call global transition in every state.
<global-transitions>
<transition on="cancelShopping" to="returnToIndex" />
</global-transitions>
This is only a easy sample, use serviceBean in webflow.xml configuration file, use subflow.
references:
http://www.springsource.org/spring-web-flow
http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/index.html
http://www.ibm.com/developerworks/cn/education/java/j-spring-webflow/index.html
http://www.ibm.com/developerworks/cn/education/java/j-spring-webflow/section5.html
http://www.jpalace.org/docs/tutorials/spring/webflow_18.html
http://wutaoo.iteye.com/blog/415899
1. Install the flow edit plugin in STS
Eclipse plugin URL http://springide.org/updatesite
I only install the webflow related plugins.
2. Spring Web Flow 2.0 Introduce
The goal for this tool is to deal with the data/states across multi requests.
Spring Web Flow 1.x is a standalone tool supported Spring Web MVC, struts, JSF and etc. But the latest 2.0 is only for Spring Web MVC.
Web Flow can be cooperate with Spring Security with 'secured'.
3. Take Add to Cart Case as example
add this to my pom.xml
<!-- spring snapshot -->
<repositories>
<repository>
<id>springsource-repository</id>
<name>Spring Maven Releases, Milestones, and Snapshots</name>
<url>http://repo.springsource.org/snapshot</url>
</repository>
</repositories>
And the dependency:
<dependency>
<groupId>org.springframework.webflow</groupId>
<artifactId>spring-webflow</artifactId>
<version>2.3.1.RELEASE</version>
</dependency>
Create a Web Flow Definition file order.xml:
<view-state id="viewCart">
<transition on="submit" to="viewOrder" />
</view-state>
<view-state id="viewOrder">
<transition to="viewConfirmed" on="confirm"></transition>
</view-state>
<view-state id="viewConfirmed">
<transition to="returnToIndex" on="returnToIndex"></transition>
</view-state>
<end-state id="returnToIndex"></end-state>
There are 5 types of states in Web Flow.
Action State,
View State,
Subflow State,
Decision State,
End State.
4. What Spring Web Flow brings to us
There are 3 typical scope in web development.
Session,
Application.
Request.
Spring Web Flow brings us 2 more:
flow: create while flow creation, end in flow destroyment, we can visit the data via 'flowScope'
conversation: mostly same as flow, but when the flow call a subflow, we can visit the data in subflow.
We have flow and conversation, they are useful but that will make the server slow.
5. Configure the Spring Web Flow 2.0 Basic Configuration
FlowRegistry is the repository of the flows. Every xml file of flow will be stored in FlowRegistry as FlowDefinition with key of ID.
FlowExecutor
This is the bean which will execute the flow.
Which flow will be executed? This will be decided by the URL and the flow Id.
http://localhost:8080/easywebflow/shopping will identify the flow with id shopping.
<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices">
<webflow:flow-location path="classpath:flows/shopping.xml"
id="shopping" />
<webflow:flow-location path="classpath:flows/addToCart.xml"
id="addToCart" />
</webflow:flow-registry>
<webflow:flow-executor id="flowExecutor" />
Spring Web Flow and Spring Web MVC work together
Spring Web MVC Process
Client send requests -----> Servlet Container(Tomcat) ------> Our Web Application(easywebflow) ------> Application Servlet(spring servlet) -------> DispatcherServlet (Spring IOC HandlerMapping) ------> Controller ------>View
There should be a handler/controller in HandlerMapping to deal with flow requests.
FlowHandler and FlowController
FlowBuilder Services
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
<property name = "flowExecutor" ref="flowExecutor" />
</bean>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="flowRegistry" ref="flowRegistry" />
<property name="order" value="1"/>
</bean>
<webflow:flow-builder-services id="flowBuilderServices"
view-factory-creator="mvcViewFactoryCreator" />
<bean id="mvcViewFactoryCreator"
class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="velocityViewResolver" />
</bean>
Use Unified EL to Implement the Logic
When will the logic code will be execute?
1. client sumibt the request include _eventId paramter.
2. invoke the framework point
3. execute the <action-state> element
Request consist of _eventId Parameter
<transition on="submit">
<evaluate expression="validator.validate()" />
</transition>
once submit is clicked, we will call the object validator method validate().
Invoke the Framework Point
flow start <on-start>
state entry <on-entry>
view render <on-render>
state exit <on-exit>
flow end <on-end>
<view-state id="viewCart" view="viewCart">
<on-render>
<evaluate expression="productService.getProducts()" result="viewScope.products" />
</on-render>
</view-state>
And we can get the viewScope data in the JSP files.
Execute the <action-state> Element
<action-state id="addToCart">
<evaluate expression="cart.addItem(productService.getProduct(productId))" />
<transition to="productAdded" />
</action-state>
How to Save the Data
flowScope
<evaluate expression="productService.getProducts()" result="flowScope.products" />
viewScope
requestScope
conversationScope
Use Subflow to Add To Cart
<view-state id="viewCart" view="viewCart">
<on-render>
<evaluate expression="productService.getProducts()" result="viewScope.products"/>
</on-render>
<transition on="submit" to="viewOrderDecistion">
</transition>
<transition on="addToCart" to="addProductToCart" />
</view-state>
<subflow-state id="addProductToCart" subflow="addToCart">
<transition on="productAdded" to="viewCart">
</transition>
</subflow-state>
Global Transition
we can call global transition in every state.
<global-transitions>
<transition on="cancelShopping" to="returnToIndex" />
</global-transitions>
This is only a easy sample, use serviceBean in webflow.xml configuration file, use subflow.
references:
http://www.springsource.org/spring-web-flow
http://static.springsource.org/spring-webflow/docs/2.3.x/reference/html/index.html
http://www.ibm.com/developerworks/cn/education/java/j-spring-webflow/index.html
http://www.ibm.com/developerworks/cn/education/java/j-spring-webflow/section5.html
http://www.jpalace.org/docs/tutorials/spring/webflow_18.html
http://wutaoo.iteye.com/blog/415899
发表评论
-
Update Site will come soon
2021-06-02 04:10 1613I am still keep notes my tech n ... -
Portainer 2020(4)Deploy Nginx and Others
2020-03-20 12:06 381Portainer 2020(4)Deploy Nginx a ... -
Private Registry 2020(1)No auth in registry Nginx AUTH for UI
2020-03-18 00:56 378Private Registry 2020(1)No auth ... -
Docker Compose 2020(1)Installation and Basic
2020-03-15 08:10 329Docker Compose 2020(1)Installat ... -
VPN Server 2020(2)Docker on CentOS in Ubuntu
2020-03-02 08:04 403VPN Server 2020(2)Docker on Cen ... -
Nginx Deal with OPTIONS in HTTP Protocol
2020-02-15 01:33 302Nginx Deal with OPTIONS in HTTP ... -
PDF to HTML 2020(1)pdftohtml Linux tool or PDFBox
2020-01-29 07:37 347PDF to HTML 2020(1)pdftohtml Li ... -
Elasticsearch Cluster 2019(2)Kibana Issue or Upgrade
2020-01-12 03:25 600Elasticsearch Cluster 2019(2)Ki ... -
Spark Streaming 2020(1)Investigation
2020-01-08 07:19 231Spark Streaming 2020(1)Investig ... -
Hadoop Docker 2019 Version 3.2.1
2019-12-10 07:39 258Hadoop Docker 2019 Version 3.2. ... -
MongoDB 2019(3)Security and Auth
2019-11-16 06:48 204MongoDB 2019(3)Security and Aut ... -
MongoDB 2019(1)Install 4.2.1 Single and Cluster
2019-11-11 05:07 251MongoDB 2019(1) Follow this ht ... -
Monitor Tool 2019(1)Monit Installation and Usage
2019-10-17 08:22 286Monitor Tool 2019(1)Monit Insta ... -
Ansible 2019(1)Introduction and Installation on Ubuntu and CentOS
2019-10-12 06:15 272Ansible 2019(1)Introduction and ... -
Timezone and Time on All Servers and Docker Containers
2019-10-10 11:18 293Timezone and Time on All Server ... -
Kafka Cluster 2019(6) 3 Nodes Cluster on CentOS7
2019-10-05 23:28 240Kafka Cluster 2019(6) 3 Nodes C ... -
K8S Helm(1)Understand YAML and Kubectl Pod and Deployment
2019-10-01 01:21 289K8S Helm(1)Understand YAML and ... -
Rancher and k8s 2019(5)Private Registry
2019-09-27 03:25 325Rancher and k8s 2019(5)Private ... -
Jenkins 2019 Cluster(1)Version 2.194
2019-09-12 02:53 404Jenkins 2019 Cluster(1)Version ... -
Redis Cluster 2019(3)Redis Cluster on CentOS
2019-08-17 04:07 336Redis Cluster 2019(3)Redis Clus ...
相关推荐
教材introduce to java programming 9th英文版,pdf,欢迎下载
Introduce to Algorithms, A Creative Approach .英文版
Chapter 1, Introduction to Microservices, will introduce you to the microservices architecture, cloud environment, etc. You will learn the difference between a microservice based application and a ...
introduce to linux.html
NULL 博文链接:https://niyunjiu.iteye.com/blog/358624
目前为止找到的最详细的NS2说明文档 比官网的ns manual 还要详细
They also introduce you to the integration of front-end and back-end technologies by using JavaScript in your application development. The final part of this book describes how to approach real-...
In this book, we introduce you to Spring Cloud and help you master its features. You will learn to configure the Spring Cloud server and run the Eureka server to enable service registration and ...
包括 Introduce to Java Programming 8th的全部课后习题答案(偶数以及奇数习题),还包括课本讲述过程中的习题。欢迎下载。
龙书 9~15章 的代码,"" 需加 L"", d3dutility.cpp 文件中需加 winmm.lib
An easy guide to Node.js and MongoDB, which will quickly introduce you to the relevant concepts by taking you through the different steps involved in building a full-fledged web application. ...
Chapter 1 introduces you to why the microservices architecture is an important and relevant approach to building applications, especially cloud-based applications. Chapter 2 walks you through how to ...
EIB的控制网络及协议介绍,通过此文档可以理解EIB控制网络及布局,理解EIB协议设计的基本知识
Students learn to work with all major mobile and web platforms as this book's active learning approach asks students to type code in parallel as the apps are developed. Meaningful exercises further ...
Chapter 1 provides an introduction to Web engineering and discusses its differences and similarities to software engineering. Ten chapters are used to introduce concepts (e.g. cost estimation, ...
里面介绍了PD方案和在实际中应用说明,及遇到的问题,解决方法,里面有市场上主流IC的介绍,供各工程技术人员学习和参考。
and AngularJSReferences for any function you will need in your day-to-day web development, Who This Book Is For, This book is perfect for beginners but more advanced web developers will also benefit....
The book alternates between chapters that introduce reactive ideas (asynchronous programming with futures and actors, managing distributed state with CQRS) and practical examples that show you how to ...
Leverage your existing web based PHP skills to write all types...This book will introduce you to the tools, techniques and background necessary to program just about anything you can think of, using the ...
计算机系统概论 英文版 作者: [美] Yale N. Patt'Introduction to Computing Systems: From bits & gates ... To understand the computer, the authors introduce the LC-3 and provide the LC-3 Simulator to give st