我有以下 View 状态
:
<view-state id="editbestellung" view="eap/orderedit.xhtml"
model="flowScope.entity">
<transition on="save" to="eaporderlist" bind="true">
<evaluate
expression="eapBestellungDelegate.save(flowScope.entity,currentUser.name)" />
</transition>
</view-state>
没有其他地方,我将 flowScope.isToDo
设置为 true。
现在我需要检查这个 flowScope 是否为真。如果是,transition
应该重定向 to="eapordertodolist"
,如果是 false,它应该重定向到 to="eaporderlist"
。< br/>
但我只知道如何设置 if 语句:
<if test="testingMethod()" then="view-state when true" else="view-state when false" />
那么如何在上面的 View 状态中实现 if 语句并执行所需的操作?
最佳答案
Use the decision-state element as an alternative to the action-state to make a routing decision using a convenient if/else syntax. The example below shows the moreAnswersNeeded state above now implemented as a decision state instead of an action-state
您的 editbestellung
状态将如下所示(注意我将 更改为
):
<view-state id="editbestellung" view="eap/orderedit.xhtml"
model="flowScope.entity">
<transition on="save" to="eaporderdecision" bind="true">
<evaluate
expression="eapBestellungDelegate.save(flowScope.entity,currentUser.name)" />
</transition>
</view-state>
然后添加决策状态:
<decision-state id="eaporderdecision">
<if test="flowScope.isToDo" then="eapordertodolist" else="eaporderlist" />
</decision-state>
关于spring - View 状态内 webflow 中的 If & Else 语句,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18330907/