4

First of all, I don't know how can config restful url request for spring webflow, for example,how can I invoke my webflow when type address: http://localhost/app/order/edit/1002

It's easy to write spring mvc controller to handle this,but in case of webflow, I don't know how to pass parameters.

Can anybody help me? Thanks

skaffman
  • 398,947
  • 96
  • 818
  • 769
Tom
  • 2,857
  • 9
  • 46
  • 59

2 Answers2

3

Try reading request parameter like following. It processes "http://example.com/message?messageId=3" but when rendering view, the URL changes to something like "http://example.com/message?execution=e1s1".

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

    <on-start>
        <evaluate expression="FooWebFlowController.create(flowRequestContext)"
                  result="flowScope.fooModel"/>
    </on-start>

    <view-state id="view" model="fooModel" view="fooView">
    </view-state>
</flow>

FooWebFlowController bean:

import org.springframework.webflow.execution.RequestContext;

@Component
public class FooWebFlowController {

    @Autowired
    private FooDAO fooDAO;

    public Foo create(RequestContext requestContext) {
        String messageId = requestContext.getRequestParameters().get("messageId")
        Foo foo = fooDAO.findByMessagId(messageId);
        return foo;
    }
}
another
  • 3,440
  • 4
  • 27
  • 34
digz6666
  • 1,798
  • 1
  • 27
  • 37
0

Is the RequestPathFlowExecutorArgumentHandler what you're looking for?

Flow executor argument handler that extracts arguments from the request path and exposes them in the URL path.

This allows for REST-style URLs to launch flows in the general format: http://${host}/${context path}/${dispatcher path}/${flowId}

<bean id="flowController" class="org.springframework.webflow.executor.mvc.FlowController">
    <property name="flowExecutor" ref="flowExecutor" />
    <property name="argumentHandler">
        <bean class="org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler" />
    </property>
</bean>
JoseK
  • 31,141
  • 14
  • 104
  • 131
  • Thanks,JoseK. I think that is what I want, but still wondering how to use the url like:http://localhost/app/order/edit/1002 to start a flow to eidt order 1002? Could you please give some sample code? – Tom Sep 23 '10 at 08:14
  • By the way, I am using spring webflow 2.1.1,I didn't found class org.springframework.webflow.executor.mvc.FlowController and class org.springframework.webflow.executor.support.RequestPathFlowExecutorArgumentHandler in spring-webflow-2.1.1.RELEASE.jar – Tom Sep 23 '10 at 08:29
  • Your link is based on 1.0.x,not my version. – Tom Sep 23 '10 at 12:57