其他分享
首页 > 其他分享> > 春季-如果if&Else语句在视图状态内的webflow中

春季-如果if&Else语句在视图状态内的webflow中

作者:互联网

我有以下视图状态:

<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是否为true.如果是,则过渡应重定向到=“ eapordertodolist”,如果为false,则应转到=“ eaporderlist”.
但是我只知道如何像这样设置if语句:

<if test="testingMethod()" then="view-state when true" else="view-state when false" />

那么如何在上面的视图状态内实现if语句并执行所需的操作?

解决方法:

使用Decision-States

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-webflow,spring
来源: https://codeday.me/bug/20191122/2063222.html