在下面的例子中,我发出了一个测试/第一个请求。当达到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
我们可以看到 anotherTestValue 变量为null。我还提交了一个Jira问题并附上了一个Grails项目,重现了完全相同的错误:https://jira.grails.org/browse/GPWEBFLOW-110
我做错了吗?任何帮助将不胜感激。
谢谢你,
拉杜
答案 0 :(得分:0)
抱歉,上面的代码中有拼写错误。我拼错了flow.anotherTestvalue。它实际上是flow.anotherTestValue,大写字母V值。现在一切正常。