how to store value returned by a business service in a variable in spring web flow?

风格不统一 提交于 2019-12-12 04:05:56

问题


Situation : I am developing a spring mvc web flow app , in that i have two tables customer and customerAdress and two corresponding models : customerModel and customerAdressModel , now following is my flow.xml :

   <var name="customer" class="com.model.Customer"/>
   <var name="customerAdress" class="com.model.CustomerAdress"/>
   <var name="id">

   <view-state id="customer" view="customerView.jsp" model="customer">

    <transition on="next" to="customerAdress"/>
    </view-state>

    <view-state id="customerAdress" view="customerAdressView.jsp" model="customerAdress">

    <transition on="next" to="insertCustomer"/>
    </view-state>

   <action-state id="insertCustomer">
    <evaluate expression="Buisness.insertCustomer(customer)"/>
    <evaluate expression="Buisness.fetchCustomerId(customer)" result="id"/>
    <evaluate expression="Buisness.insertCustomerAdress(id,cutomerAdress)"/>
    </action-state> 

Now insertCustomer inserts customer , fetchCustomerId fetches customer's id and insertCusotomerAdress inserts adresses of customer by id

Problem : My problem is this code is not working , specifically insertCustomerAdress is not working , i think i have done some mistake in decalring id or assigning buisness service's value to id , can somebody please tell me proper syntax ?


回答1:


By default action state executes only first action. To execute a chain of actions use Named actions.

<action-state id="insertCustomer">
    <evaluate expression="Buisness.insertCustomer(customer)">
        <attribute name="name" value="insertCustomer" />
    </evaluate>
    <evaluate expression="Buisness.fetchCustomerId(customer)" result="id">
        <attribute name="name" value="fetchCustomerId" />
    </evaluate>
    <evaluate expression="Buisness.insertCustomerAdress(id,cutomerAdress)">
        <attribute name="name" value="insertCustomerAdress" />
    </evaluate>
    <transition on="insertCustomerAdress.success" to="[state id to transit]" />
</action-state>


来源:https://stackoverflow.com/questions/36515008/how-to-store-value-returned-by-a-business-service-in-a-variable-in-spring-web-fl

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!