2013-04-22 80 views
1

我有两个控制器,每个都有一个流量。在我的菜单中,我有一个链接到流量。如果我在#1流程中并单击流程#2的链接,Grails会向我显示流程#1的视图。Webflow:可以在流之间切换吗?

我发现做这个转换工作的唯一方法是有一个链接到重定向到流程的操作。

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 
+0

请问你的链接到其他流程的样子或你如何创建它? – 2013-04-22 19:07:50

+0

@johnSmith我用菜单信息编辑了问题。 – 2013-04-22 19:15:44

+0

我可能在这里弄错了,但是执行url(e14s1)对于两者来说都是一样的,如果你有两个不同的流程,应该不会有所不同吗?也许这就是为什么它超出其他流程 – Alidad 2013-04-25 03:16:23

回答

0

如果我们要停止的流程过程(如单击菜单),我们需要告诉Webflow的end-state

所以菜单链接url应该包含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' 
    } 
}