0

I'm making simple order-flow via Spring Web Flow, also i have Spring MVC on my project. I've been doing everything according to guides, but my web-app doesn't react to my flow at all. Spring Web Flow Config:

     @Configuration
     @ComponentScan(basePackages = "config")
     public class WebFlowConfig extends AbstractFlowConfiguration {
@Bean
public FlowBuilderServices flowBuilderServices() {
    return getFlowBuilderServicesBuilder()
            .setViewFactoryCreator(mvcViewFactoryCreator())
            .setDevelopmentMode(true).build();
}

@Bean
public MvcViewFactoryCreator mvcViewFactoryCreator() {
    MvcViewFactoryCreator factoryCreator = new MvcViewFactoryCreator();
    factoryCreator.setViewResolvers(

    Collections.singletonList(this.webMvcConfig.resourceViewResolver()));
    factoryCreator.setUseSpringBeanBinding(true);
    return factoryCreator;
}
@Autowired
private DispatcherConfig webMvcConfig;

@Bean
public FlowDefinitionRegistry flowRegistry() {
   FlowDefinitionRegistry registry = getFlowDefinitionRegistryBuilder().addFlowLocation("/WEB-INF/flows/order/flowcnf.xml","order").build();
   return registry;
}

@Bean
public FlowExecutor flowExecutor() {
    return

            getFlowExecutorBuilder(flowRegistry()).build();
}

@Bean
public FlowHandlerMapping flowHandlerMapping(){
    final FlowHandlerMapping handeler = new FlowHandlerMapping();
    handeler.setFlowRegistry(flowRegistry());
    handeler.setFlowUrlHandler(defaultFlowUrlHandler());
    return handeler;
}
@Bean
public DefaultFlowUrlHandler defaultFlowUrlHandler(){
    return new DefaultFlowUrlHandler();
}

@Bean
public FlowHandlerAdapter adapter(){
    FlowHandlerAdapter adapter = new FlowHandlerAdapter();
    adapter.setFlowUrlHandler(defaultFlowUrlHandler());
    adapter.setFlowExecutor(flowExecutor());
    return adapter;
}
}

As I said I'm using Spring MVC maybe the problems occurs due to it.

Code snippet below must run "thankCustomer" view-state, but it doesn't. I get 404 eror if i click the link.

<a class=button href="${flowExecutionUrl}&_eventId=thankCustomer">Замовити!</a>

And the flow code:

<?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"
  start-state="identify">
<var name="order" class="entity.BookOrder"/> 

<subflow-state id="identify" subflow="order/custom" >
    <output name="user" value="order.custName" />
    <transition on="userIsReady" to="buildOrder"/>
</subflow-state>

<subflow-state id="buildOrder" subflow="order/build">
    <input name="order" value="order" />
    <transition to="takePayment" on="orderBuilt" />
</subflow-state>


<subflow-state id="takePayment" subflow="order/takePayment" >
    <input name="order" value="order"/>
    <transition on="paymentTaken" to="saveOrder" />
</subflow-state>
<action-state id="saveOrder">
    <evaluate expression="userServiceImpl.addOrder(order.custName,order)"/>
    <transition to="thankCustomer" />
</action-state>

<view-state id="thankCustomer" view="/WEB-INF/pages/greeting.jsp" >
    <transition to="end-point" />
</view-state>

<end-state id="end-point"/>

<global-transitions>
    <transition on="cancel" to="end-point" />
</global-transitions>

</flow>

I've tried to put flow id (order) instead of empty flowExecutionUrl, but still the same eror, I'll be grateful for any kinda help.

6
  • there are no transitions on event thankCustomer in your flow. Commented Feb 21, 2019 at 15:43
  • saveOrder action-state ? Anyway I'm connecting directly to the view-state using href="${flowExecutionUrl}&_eventId=thankCustomer", aren't I ? Commented Feb 21, 2019 at 16:08
  • the xml file is your flow. in this case it looks like it is order. so first, you enter your order flow (/order) then you can transition with an event. in this case your event is thankCustomer but there is no such transition in your order flow. you cannot enter part of your flow directly, at least not like that Commented Feb 21, 2019 at 17:42
  • I replaced start-state="identify" with start-state="saveOrder" but nothing has changed, when I go to localhost:8080/order/ i still getting 404 eror (Page Not Found) Commented Feb 21, 2019 at 17:51
  • 1
    Thank you for your help! The problem was that i didn't set order to my FlowHandlerMapping in WebFlowConfig ! Commented Feb 22, 2019 at 11:13

1 Answer 1

1

I needed to set "order" to my FlowHandlerMapping Bean, couse i already had 2 viewResolvers.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.