如何将业务服务返回的值存储在Spring Web Flow的变量中? [英] how to store value returned by a business service in a variable in spring web flow?
问题描述
情况:我正在开发一个Spring MVC Web Flow应用程序,因为我有两个表customer
和customerAdress
以及两个相应的模型:customerModel
和customerAdressModel
,现在如下是我的flow.xml:
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>
现在insertCustomer
插入客户,fetchCustomerId
获取客户的ID,insertCusotomerAdress
通过id
Now insertCustomer
inserts customer , fetchCustomerId
fetches customer's id and insertCusotomerAdress
inserts adresses of customer by id
问题:我的问题是此代码无法正常工作,尤其是insertCustomerAdress
无法正常工作,我认为我在对id
进行除法或将商务服务的值分配给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 ?
推荐答案
默认情况下,动作状态仅执行第一个动作.要执行一系列操作,请使用
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>
这篇关于如何将业务服务返回的值存储在Spring Web Flow的变量中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!