2014-11-06 52 views
2

我正在使用Grails 2.3.6WebFlow 2.0.8.1插件已安裝。我正在嘗試使用SubFlow獲得概念證明。在查看示例SubFlow documented here之後,我很難得到一個簡單的SubFlow工作。Grails SubFlow不會呈現其查看頁面並返回HTTP 404

注:我是Grails和WebFlow的新來者。

這是我的項目結構:

Project Structure

HelloController呈現此頁:

HelloController Page

DemoController呈現此頁:

DemoController Page

然而,當我點擊轉至HelloController中的頁面上接頭流動按鈕,我收到了404:

enter image description here

如果我提供/hello/hello/subflowDemo.gsp,頁面呈現,但它不是從頁面DemoController

我在做什麼錯?

HelloController中

package helloworld 

class HelloController { 
    def helloFlow = { 
     hello { 
      on("goToSub").to "subflowDemo" 
     } 
     subflowDemo { 
      subflow(controller: "demo", action: "demo") 
     } 
    } 
} 

hello.gsp

<html> 
<body> 
    Hello world! 
    <g:form> 
     <g:submitButton name="goToSub" value="Go To Sub Flow" /> 
    </g:form> 
</body> 
</html> 

DemoController

package helloworld 

class DemoController { 
    def demoFlow = { 
     demo { 
     } 
    } 
} 

demo.gsp

<html> 
<body> 
    This is the demo screen! 
</body> 
</html> 

回答

1

你必須完成流動循環。我相信子流的狀態不可能是主流的最終狀態。所以結束主流程中的流程。

下面的代碼改變的觀點爲我工作,

HelloController.groovy

class HelloController { 

    def helloFlow = { 
     hello { 
      on("goToSub").to "subflowDemo" 
     } 
     subflowDemo { 
      subflow(controller: "demo", action: "demo") 
      on("gotomainflow").to "endstate" // have a transition to endstate 

     } 
     endstate { 

     } 
    } 

} 

endstate.gsp /打招呼/你好/ endstate.gsp

<html> 
<body> 
    Came Back to main- endstate 
</body> 
</html> 

DemoController.groovy

class DemoController { 
    def demoFlow = { 
     demo { 
      on("gotomainflow").to "gotomainflow" //have the transition which calls a event 
     } 
     gotomainflow() // this event will trigger the event in the main flow 
    } 
} 

演示。gsp in views/demo/demo/

<html> 
<body> 
    This is the demo screen! 
    <g:form> 
     <g:submitButton name="gotomainflow" value="Go To Main Flow" /> 
    </g:form> 
</body> 
</html> 
+0

謝謝Dinesh Kumar,現在可以工作了! – 2014-11-11 15:34:34