【问题标题】:how to store value returned by a business service in a variable in spring web flow?如何将业务服务返回的值存储在spring web flow中的变量中?
【发布时间】:2016-04-09 18:22:59
【问题描述】:

情况:我正在开发一个spring mvc web flow应用程序,我有两个表customercustomerAdress以及两个对应的模型:customerModelcustomerAdressModel,现在关注是我的 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 插入客户地址

问题:我的问题是这段代码不起作用,特别是insertCustomerAdress 不起作用,我认为我在标记id 或将业务服务的值分配给id 时犯了一些错误,有人可以告诉我正确的语法吗?

【问题讨论】:

    标签: spring jsp spring-mvc spring-webflow spring-webflow-2


    【解决方案1】:

    默认情况下,动作状态只执行第一个动作。要执行一系列操作,请使用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>
    

    【讨论】:

      猜你喜欢
      • 2012-06-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-07
      • 1970-01-01
      • 2022-11-17
      • 1970-01-01
      • 2017-01-07
      相关资源
      最近更新 更多