Webflow:可以在流之间切换吗?

时间:2013-04-22 18:55:47

标签: grails spring-webflow grails-2.2

我有两个控制器,每个都有一个流程。在我的菜单中,我有一个流程链接。如果我在流#1中并单击流#2的链接,Grails将向我显示流#1的视图。

我发现实现此转换的唯一方法是获得指向重定向到流的操作的链接。

class FirstController {
  def firstFlow = {
  }

  def toFirst() {
    redirect action: 'first'
  }

}

class SecondController {
  def secondFlow = {
  }
  def toSecond() {
    redirect action: 'second'
  }
}
  • 转到/first/first会正确显示视图。
  • 转到/second/second会显示第一个的视图。
  • 转到/second/toSecond重定向并正确显示视图。
  • 返回/first/first会显示第二
  • 的视图
  • Goingo到/first/toFisrt会正确显示视图。

这是预期的行为吗?为什么流程没有进入正确的视图?

修改

使用Platform Core Navigation API创建菜单。

navigation = {
  app {
    first(controller: 'first', action: 'first', title: 'nav.exportar')
    second(controller: 'second', action: 'second', title: 'nav.importar')
  }
}

链接

http://localhost:8080/my-application/first/first?execution=e14s1
http://localhost:8080/my-application/second/second?execution=e14s1

1 个答案:

答案 0 :(得分:0)

如果我们想要停止流程(如点击菜单),我们需要告诉webflow end-state

因此菜单链接网址应包含eventId参数,表示end-state

我不知道导航api,但g:link示例如下:

<g:if test="${params.action=='first'}"><%-- we are in first flow. --%>
    <g:link event="toSecond">Go to second</g:link>
</g:if>
<g:else><%-- we are not in first flow, normal link. --%>
    <g:link controller="second" action="second">Go to second</g:link>
</g:else>

和第一个控制器:

class FirstController {
    def firstFlow = {
        // view-state
        firstViewState {
            on('next').to 'nextAction'
            on('toSecond').to 'toSecond' // <g:link event='toSecond'> in gsp
        }

        // end-state
        toSecond() {
            redirect (controller:'second', action:'second')
        }
    }

    def toFirst() {
        redirect action: 'first'
    }
}