【发布时间】:2014-12-30 05:58:03
【问题描述】:
在下面的示例中,我提出了 test/first 的请求。到达 firstSubFlow 时,我在流和转换上下文中保存了一些变量。在 showSomeView gsp 中,我显示了这些变量,但似乎只有存储在对话上下文中的变量仍然可用。存储在流上下文中的是 null。
此问题仅在使用子流时出现。我正在使用 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 变量为空。我还提交了一个 Jira 问题并附加了一个 Grails 项目,重现了完全相同的错误:https://jira.grails.org/browse/GPWEBFLOW-110
是不是我做错了什么?任何帮助将不胜感激。
谢谢你,
拉度
【问题讨论】:
标签: java spring grails groovy spring-webflow