Spring webflow - transition
I am newbie to Spring web flow. Just started with simple 2 screen project
along thymeleaf. I could get on to the first flow but unable to move to
second screen. If I click on OrderAward I keep coming to first screen. I
see that JSESSIONID is same in two requests. Not able to figure out the
issue.
Here are the files I have configured(referred from hotel booking Spring
web flow example)
webflow-config.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:webflow="http://www.springframework.org/schema/webflow-config"
xsi:schemaLocation="
_http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
_http://www.springframework.org/schema/webflow-config
_http://www.springframework.org/schema/webflow-config/spring-webflow-config-2.3.xsd">
<!-- Executes flows: the entry point into the Spring Web Flow system -->
<webflow:flow-executor id="flowExecutor">
<webflow:flow-execution-listeners>
<webflow:listener ref="securityFlowExecutionListener" />
</webflow:flow-execution-listeners>
</webflow:flow-executor>
<!-- The registry of executable flow definitions -->
<webflow:flow-registry id="flowRegistry"
flow-builder-services="flowBuilderServices" base-path="/WEB-INF">
<webflow:flow-location-pattern value="/**/*-flow.xml" />
</webflow:flow-registry>
<!-- Plugs in a custom creator for Web Flow views -->
<webflow:flow-builder-services id="flowBuilderServices"
view-factory-creator="mvcViewFactoryCreator"
development="true" validator="validator" />
<!-- Configures Web Flow to use Tiles to create views for rendering;
Tiles allows for applying consistent layouts to your views -->
<bean id="mvcViewFactoryCreator"
class="org.springframework.webflow.mvc.builder.MvcViewFactoryCreator">
<property name="viewResolvers" ref="tilesViewResolver"/>
<property name="useSpringBeanBinding" value="true" />
</bean>
<!-- Installs a listener to apply Spring Security authorities -->
<bean id="securityFlowExecutionListener"
class="org.springframework.webflow.security.SecurityFlowExecutionListener"
/>
<!-- Bootstraps JSR-303 validation and exposes it through Spring's
Validator interface -->
<bean id="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean"/>
</beans>
award-flow.xml is
<?xml version="1.0" encoding="UTF-8"?>
<flow xmlns="http://www.springframework.org/schema/webflow"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/webflow
http://www.springframework.org/schema/webflow/spring-webflow-2.0.xsd">
<secured attributes="ROLE_USER" />
<input name="awardId" type="java.lang.String" />
<on-start>
<evaluate expression="awardService.findById(awardId)"
result="flowScope.award" />
</on-start>
<view-state id="order" model="award">
<on-render>
<render fragments="body" />
</on-render>
<transition on="order" to="orderAward"/>
</view-state>
<end-state id="orderAward">
<output name="confirmed" value="'Your order is confirmed.'"/>
</end-state>
<end-state id="cancel" />
</flow>
order.html is
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:th="http://www.thymeleaf.org"
xmlns:tiles="http://www.thymeleaf.org"
xmlns:sec="http://www.thymeleaf.org"
lang="en">
<head>
<meta charset="utf-8" />
<title>Exchange Loyalty Points</title>
</head>
<body>
<form action="#" th:object="${award}" method="get"
th:action="${flowExecutionUrl}">
<span th:text="${award}"></span>
<p>
<button type="submit" id="orderAward" name="_eventId_order"
value="orderAward">OrderAward</button>
<input type="hidden" name="flowExecutionKey"
th:value="${flowExecutionKey}"/>
<button type="submit" name="_eventId_cancel" >Cancel</button>
</p>
</form>
</body>
</html>
No comments:
Post a Comment