Spring Web Flow - 集成Javascript确认决策

时间:2014-05-26 18:39:54

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

我想将一个javascript对话框集成到Web流的开头,其中所选的选项确定是将现有对象添加到流还是新对象。

<on-entry>
<evaluate expression="appService.checkMembershipStatus(memberId)"/>
   // this will check if the state is 'RENEW' and return boolean
   // If returns true, then show javascript dialog to say "Renew existing?". 
         //If they select 'Yes', the existing membership is loaded into the flowScope. 
         //If they select 'No', then a new membership (object) is loaded into the flowscope
   // else
     // A new memebership (object) is loaded into the flowscope

</on-entry>

<view-state id="begin">
   // continue as normal
</view-state>

由于

1 个答案:

答案 0 :(得分:1)

您可以使用<decision-state>来实现此目的。样本流程如下

<view-state id="screen1">
    <transition to="checkMembershipStatus" />
</view-state>

<decision-state id="checkMembershipStatus">
    <if test="appService.checkMembershipStatus(memberId)"
        then="renewMembership"
    else="loadNewMember" />
</decision-state>

<!--In this page show a javascript dialog (or custom JSP page) on load to get the answer [YES/NO] -->
<view-state id="renewMembership">
    <transition on="Yes" to="loadExistingMember" />
    <transition on="No" to="loadNewMember" />
</view-state>

<action-state id="loadExistingMember">
   <evaluate expression="loadExistingMember()" result="member" />
   <transition to="begin" />
</action-state>

<action-state id="loadNewMember">
   <evaluate expression="loadnewMember()" result="member" />
   <transition to="begin" />
</action-state>

<view-state id="begin">
   // continue as normal
</view-state>