How to pass parameters to spring webflow

2020-07-18 05:27发布

问题:

I am working on spring webflows. I have two webflows in my application, one to add a person details and one to modify the person details. Both flows are working fine. Now I would like to pass parameter(s) to my modify flow and access it, so that I can preselect some of the values based on the passed parameter. How can I achieve it for below mentioned scenarios?

  1. From the Add flow end state.
  2. From outside the flow i.e from anywhere in the application except add flow.

回答1:

I figured it out. In the end it was very simple and i just had to pass the parameters in url and get the parameters that I pass using input tag in the flow.xml. Earlier i wasn't using the input tag.

Url will be something like ths

http://localhost:8080/modifyPerson?personName=xxx

Then in flow.xml personName parameter that is passed is retrieved using input tag and set to the model.

 <input name="personName"/>

 <view-state id="modifyBasics" view="modifyBasics" model = "person">
    <on-render>
        <set name="person.personName" value="personName"></set>
    </on-render>
    ....
 </view-state>