2014-11-03 20 views
0

在下面的示例中,我提出了測試/ first的請求。當到達firstSubFlow時,我在流和轉換上下文中保存一些變量。在showSomeView gsp中,我顯示了這些變量,但似乎只有存儲在對話上下文中的變量仍然可用。存儲在流上下文中的那些爲空。Grails Web Flow插件 - 在子流中使用時丟失流環境

僅當使用子流時纔會出現此問題。我使用的Grails 2.3.11和Web流量插件,版本2.0.8.1

TestController.groovy

class TestController { 

    def firstFlow = { 
     start { 
      action { 
       flow.testValue = 'first flow Flow Scope'; 
       conversation.conversationTestValue = 'first flow Conversation Scope' 
       gotoFirstSub() 
      } 

      on("gotoFirstSub") {}.to "firstSub" 
     } 

     firstSub { 
      subflow(firstSubFlow) 
      on("done") {}.to "done" 
     } 

     done {} 

    } 

    def firstSubFlow = { 
     start { 
      action { 
       flow.anotherTestvalue = 'subflow Flow Scope' 
       conversation.conversationAnotherTestValue = 'subflow Conversation Scope' 
       gotoShowSomeView(); 
      } 

      on('gotoShowSomeView') {}.to 'showSomeView' 
     } 

     showSomeView { 
      on('next') {}.to 'done' 
     } 

     done() 
    } 
} 

showSomeView.gsp

<html> 
<head> 
    <title>Flow context lost when used in a subflow</title> 
</head> 
<body> 
Value from main flow scope: ${testValue}<br/> 
Value from main flow conversation scope: ${conversationTestValue}<br/> 
Value from subflow flow scope: ${anotherTestValue}<br/> 
Value from subflow conversation scope: ${conversationAnotherTestValue} 
</body> 
</html> 

以上GSP向瀏覽器呈現以下內容:

Value from main flow scope: 
Value from main flow conversation scope: first flow Conversation Scope 
Value from subflow flow scope: 
Value from subflow conversation scope: subflow Conversation Scope 

正如我們所見anotherTestValue變量爲空。我還提交了Jira問題,並附上了一個Grails項目,其中複製了完全相同的錯誤:https://jira.grails.org/browse/GPWEBFLOW-110

這是我做錯了什麼嗎?任何幫助,將不勝感激。

謝謝
拉杜

回答

0

對不起,在上面的代碼一個錯字。我拼錯了flow.anotherTestvalue。它實際上是flow.anotherTestValue,大寫V值。現在一切正常。