2
votes

My application is about 80% Spring MVC, but I have a fair amount of code that uses Webflow. I'm currently using a Spring MVC SimpleUrlHandlerMapping to dispatch to the webflow, which I know isn't how I'm "supposed" to do it.

My flow definitions are defined as follows:

  • /WEB-INF/flows/process1/reservation/reservation-flow.xml
  • /WEB-INF/flows/process1/modify/modify-flow.xml
  • /WEB-INF/flows/process2/reservation/reservation-flow.xml
  • /WEB-INF/flows/process2/modify/modify-flow.xml

I want to be able to access them via the following URLS:

My flow registry bean looks like this:

<webflow:flow-registry id="flowRegistry" base-path="WEB-INF/flows" flow-builder-services="flowBuilderServices" >
    <webflow:flow-location-pattern value="/**/*/*-flow.xml"/>
</webflow:flow-registry>

My javascript to dispatch to the webflow looks like this (javascript snippet, it's a very complex page):

var form = $('<form    action="${pageContext.request.contextPath}/process1/reservation/reservation.html"    method="POST">');

    form.append('<input name="param1" value="' + record.param1 + '" />');
    form.append('<input name="param2" value="' + record.param2 + '" />');
    form.append('</form>');
    submitForm(form);

Now for the real question: How do I set up a url handler mapping for it, whether it be SimpleUrlHandlerMapping or something else?

Thanks!

1
So there must be a reason you used SimpleUrlHandlerMapping instead of FlowHandlerMapping, the way you're "supposed" to do it? If I understand correctly what you're asking, shouldn't FlowHandlerMapping give you what you want?dbreaux
As @dbreaux mentioned,is there any particular reasoning behind not using FlowHandlerMapping.Also,did you explore using subflows and adding further transitions in flow mapping config file.Shivam Aggarwal
The reason I didn't use FlowHandlerMapping is that it never worked for me. Under my base path, I would have this: /process1/reservation/reservation.xml I would expect that to map to: example.com/context/process1/reservation/reservation.html But no luck.Jason
one more thing,in web flow,xml files contain flow defintions for various transitions,so why to have flow confi,when you directly want it to redirect to a page?Shivam Aggarwal
What patterns are your dispatcher servlet matching in web.xml? Once I added *.html, my flows started responding to that as well. (The DefaultFlowUrlHandler javadoc describes that it will ignore extensions in determining the flow ID.)dbreaux

1 Answers

0
votes

Usually if you want to dispatch request to web-flow through Spring-MVC, we have to set up FlowHandlerAdapter like:

<!-- Enables FlowHandler URL mapping -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerAdapter">
    <property name="flowExecutor" ref="flowExecutor" />
</bean>

And then define flowMapping:

<!-- Maps request paths to flows in the flowRegistry;
    e.g. a path of /movie/showtime looks for a flow with id "movie/showtime" -->
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry"/>
    <property name="order" value="0"/>
</bean>

For detail implementation, you can also refer to spring docs.