无法在spring flowScope中访问变量

时间:2016-02-02 03:17:38

标签: java spring spring-webflow spring-webflow-2

方法getClientByCredential()将返回依赖于'clientType'的Client子实例。

客户端是一个抽象类。 class Individual和Corporate扩展客户。所以我不能在flow.xml中声明这样的变量客户端:

App.PostsPostRoute = Ember.Route.extend({
  model: function(post) {
    return post;
  },
  renderTemplate: function() {
    this.render({ into: 'application' });
  }
});

这是我的flow.xml,但它不起作用。

<var name="client" class="somepackage.domain.Client" /> 

以下是根异常:

<view-state id="start">
    <transition on="credentialEntered" to="getClient"/>
</view-state>

<action-state id="getClient">
    <evaluate result="flowScope.client" expression="clientActions.getClientByCredential(requestParameters.clientType, requestParameters.credentialType, requestParameters.credentialNo)"/>
    <transition to="clientReady"/>
    <transition to="clientAddFork" on-exception="com.rtongsoft.loansystem.util.exception.ClientNotFoundException"/>
</action-state>

<action-state id="clientAddFork">
    <evaluate expression="requestParameters.clientType" />
    <transition on="INDIVIDUAL" to="individualAdd"/>
    <transition on="COPORATE" to="coporateAdd"/>
</action-state>

<action-state id="coporateAdd">
    <transition to="cancel"/>
</action-state>

<view-state id="individualAdd" model="client"> <!-- the exception place -->
    <on-render>
        <evaluate result="viewScope.credentialTypeList" expression="entryService.getEntrysByfield('credentialType')"/>
        <evaluate result="viewScope.nationalityList" expression="entryService.getEntrysByfield('nationality')"/>
        <evaluate result="viewScope.ethnicGroupList" expression="entryService.getEntrysByfield('ethnicGroup')"/>
        <evaluate result="viewScope.educationBackgroundList" expression="entryService.getEntrysByfield('educationBackground')"/>
        <evaluate result="viewScope.genders" expression="T(com.rtongsoft.loansystem.enumeration.Gender).values()"/>
        <evaluate result="viewScope.maritalStatuses" expression="T(com.rtongsoft.loansystem.enumeration.MaritalStatus).values()"/>
    </on-render>
    <transition on="submit" to="addClient"/>
</view-state>

<action-state id="addClient">
    <evaluate expression="clientService.addClient(flowScope.client)"/>
    <transition to="clientReady"/>
</action-state>

<!-- flow end -->
<end-state id="clientReady" >
    <output name="client"/>
</end-state>
<end-state id="cancel" />

<global-transitions>
    <transition on="cancel" to="cancel" />
</global-transitions>

1 个答案:

答案 0 :(得分:0)

我终于找到了问题。当getClientByCredential()抛出ClientNotFoundException时,它永远不会将Client实例返回给flowScope。 抱歉我粗心。

顺便问一下,有没有人知道如何设置

<var name="client" class="somepackage.domain.Client" /> 

当客户端是抽象类时。

varibale&#39;客户&#39;将被分配给客户孩子。个人或公司。