how to store value returned by a business service

2019-09-04 07:45发布

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条回答
趁早两清
2楼-- · 2019-09-04 08:32

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>
查看更多
登录 后发表回答