在下面的示例中,我请求进行测试/首先。当到达firstSubFlow时,我将一些变量保存在流和会话上下文中。在showSomeView gsp中,我显示了这些变量,但是似乎只有存储在对话上下文中的变量仍然可用。流上下文中存储的那些为空。
仅在使用子流时才会出现此问题。我正在使用Grails 2.3.11和Web Flow插件版本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
如我们所见,另一个TestValue变量为null。我还提交了一个Jira问题,并附加了一个Grails项目,该项目再现了完全相同的错误:https : //jira.grails.org/browse/GPWEBFLOW-110
我做错了什么吗?任何帮助,将不胜感激。
谢谢你,
拉杜
抱歉,上面的代码中有错字。我拼错了flow.anotherTestvalue。它实际上是flow.anotherTestValue,其中大写的V为value。现在一切正常。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句