首页 | 新闻 | 新品 | 文库 | 方案 | 视频 | 下载 | 商城 | 开发板 | 数据中心 | 座谈新版 | 培训 | 工具 | 博客 | 论坛 | 百科 | GEC | 活动 | 主题月 | 电子展
返回列表 回复 发帖

通用页面流程框架及实例介绍(4)BTT 通用页面流程设计和各种流程后续1

通用页面流程框架及实例介绍(4)BTT 通用页面流程设计和各种流程后续1

下面是 Web 页面流程的实例,XML 配置的方式清晰易懂,就算是业务人员也可以看懂。注释中有相应的流程解释:
清单 2. Web 页面流程(HTML Flow Processor)实例
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
<!-- HTML Processor表示Web页面流程, id唯一标示这个web页面流程-->
<htmlProcessor context="creditCardsCtx" id="creditCardsProc">
  <!-- 开始状态-->
  <htmlState id="initial" type="initial">
    <transitions>
      <htmlTransition id="initial.start" targetState="creditCardsWellcome"/>
    </transitions>
  </htmlState>
  <!-- 欢迎页面状态, 导航到欢迎页面。type="page"表示是页面状态,
  typeIdInfo="creditCardsWellcome.jsp"表示页面内容。-->
  <htmlState id="creditCardsWellcome" type="page"
    typeIdInfo="creditCardsWellcome.jsp">
    <transitions>
      <!-- 根据页面上出发的事件,转到下一个状态creditHistoryOpState。
      页面上的事件如: nextEventName="history" -->
      <htmlTransition
        context="creditCardsWellcome_history_Ctx"
        id="creditCardsWellcome.history" targetState="creditHistoryOpState"/>
    </transitions>
  </htmlState>
  <!-- 从页面到此业务状态,执行相应的业务操作,
  type="operation"表示这个状态是一个业务操作,
  typeIdInfo="creditHistoryOp"表示这个业务操作的ID-->
  <!-- Operation state. The operation is executed by the specialized state.
  The operation is firing the exit events -->
  <operationState id="creditHistoryOpState" type="operation"
    typeIdInfo="creditHistoryOp">
    <!-- 根据业务操作的返回结果,转移到下一个Web流程的下一个状态-->
    <transitions>
      <transition id="creditHistoryOpState.accountExists"
        targetState="selectCardsOpState"/>
      <transition id="creditHistoryOpState.newAccount"
        targetState="financialInfoState"/>
      <transition id="creditHistoryOpState.error"
        targetState="finalNotOK"/>
    </transitions>
  </operationState>
  <!-- 子流程状态,这是一个特殊的页面状态,
  type="subFlow"表示是一个子页面流程,
  typeIdInfo="financialInfoProc"表示子页面流程的ID,
  Web流程会根据ID并且执行子页面流程-->
  <htmlState id="financialInfoState" type="subFlow"
    typeIdInfo="financialInfoProc">
    <!-- 根据子页面流程的结果,Web流程执行下一个流程状态 -->
    <transitions>
       <!-- 如果子页面流程执行成功,则到selectCardsOpState状态 -->
       <htmlTransition id="financialInfoState.OK"
         outputMapFmt="financialInfoToCreditApplFormat"
           targetState="selectCardsOpState"/>
       <!-- 如果子页面流程执行失败,则到finalNotOK状态 -->
       <htmlTransition id="financialInfoState.notOK"
         outputMapFmt="errorMessagesMapper"
           targetState="finalNotOK"/>
       <!-- 如果子页面流程取消,则重新回到欢迎界面,用户可以重新开始流程 -->
       <transition id="financialInfoState.canceled"
         targetState="creditCardsWellcome"/>
    </transitions>
  </htmlState>
  <!-- 这个状态得到信用卡的种类信息 -->
  <htmlState id="selectCardsOpState">
    <entryActions>
      <executeOperationAct id="selectCardsAct"
        operationName="selectCardsOp"/>
    </entryActions>
    <transitions>
      <transition id="selectCardsAct.ok" targetState="creditCardsPage"/>
      <transition id="selectCardsAct.error" targetState="finalNotOK"/>
    </transitions>
  </htmlState>
  <!-- 选择信用卡类型页面状态,type="page"表示这个状态是页面,
  typeIdInfo="creditCardsPage.jsp"表示页面内容。-->
  <htmlState id="creditCardsPage" type="page"
    typeIdInfo="creditCardsPage.jsp">
    <!-- 根据选择信用卡的结果,转到流程的下一个状态 -->
    <transitions>
      <!-- 如果用户信用卡选择成功,转到流程的下一个状态creditCardConfirmationPage -->
      <transition id="creditCardsPage.OK"
        targetState="creditCardConfirmationPage"/>
      <!-- 如果用户取消了信用卡申请,则转到流程的下一个状态finalOK -->
      <transition id="creditCardsPage.Cancel" targetState="finalOK"/>
    </transitions>
  </htmlState>
  <!-- 信用卡确认信息页面,type="page"表示这个状态是页面,
  typeIdInfo="creditCardConfirmationPage.jsp"表示页面内容 -->
  <htmlState id="creditCardConfirmationPage" type="page"
    typeIdInfo="creditCardConfirmationPage.jsp">
    <transitions>
      <!-- 如果用户确认了信用卡信息,
      则转移到下一个流程状态creditCardProcessingOpState。 -->
      <transition id="creditCardConfirmationPage.OK"
        targetState="creditCardProcessingOpState"/>
      <!-- 如果用户取消了信用卡申请,则转到流程的下一个状态finalOK -->
      <transition id="creditCardConfirmationPage.Cancel"
        targetState="finalOK"/>
    </transitions>
  </htmlState>
  <!-- 信用卡处理逻辑状态 -->
  <htmlState id="creditCardProcessingOpState">
    <entryActions>
    <!-- 执行业务操作,operationName="creditCardProcessingOp"表示业务操作的ID -->
    <executeOperationAct id="creditCardProcAct"
      linkContextTo="processor" operationName="creditCardProcessingOp"/>
    </entryActions>
  <transitions>
    <!-- 如果信用卡处理申请提交成功,则转移到下一个状态creditCardProcessedState。 -->
    <transition id="creditCardProcAct.ok" targetState="creditCardProcessedState"/>
    <!-- 如果信用卡处理申请提交失败,则转移到下一个状态finalNotOK。 -->
    <transition id="creditCardProcAct.error" targetState="finalNotOK"/>
    </transitions>
  </htmlState>
  <!-- 信用卡处理完成页面。type="page"表示这个状态是页面,
  typeIdInfo="creditCardProcessedPage.jsp"表示页面内容 -->
  <htmlState id="creditCardProcessedState" type="page"
    typeIdInfo="creditCardProcessedPage.jsp">
    <transitions>
      <transition id="creditCardProcessedState.OK" targetState="finalOK"/>
    </transitions>
  </htmlState>
  <!-- 申请错误页面。type="final"表示这个状态是流程的结束状态,
  finalPage="apologies.jsp"表示页面内容 -->
  <htmlState finalPage="apologies.jsp" id="finalNotOK"
      type="final" typeIdInfo="notOK"/>
  <!-- 申请成功页面。type="final"表示这个状态是流程的结束状态,
  finalPage="accountinquiry.jsp"表示页面内容 -->
  <htmlState finalPage="accountinquiry.jsp" id="finalOK"
      type="final" typeIdInfo="OK"/>
</htmlProcessor>

返回列表