2013-04-22 42 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' 
    } 
}