In the following example I make a request to test/first. When reaching firstSubFlow I save some variables on the flow and converstion contexts. In showSomeView gsp I display those variables but it seems that only the variables stored on the conversation context are still available. The ones stored on the flow context are null.
This problem appears only when working with subflows. I am using Grails 2.3.11 and Web Flow plugin, version 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>
The above gsp renders the following to the browser:
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
As we can see anotherTestValue variable is null. I also submitted a Jira issue and attached a Grails project reproducing the exact same error: https://jira.grails.org/browse/GPWEBFLOW-110
Is it something I am doing wrong? Any help would be appreciated.
Thank you,
Radu
Sorry, there is a typo in the above code. I misspelled flow.anotherTestvalue. It was actually flow.anotherTestValue, with uppercase V at value. Now everything works fine.