Hello,
I need help with implementing cookie type variables in my flow. I have a user preference setting value that I store in a flowscoped object.
I am setting the initial value for this field at the start of the flow.Code:public class MyFlowUtil{ private String userPreference; //getter and setter }
my-flow.xml
Then I am trying to show this value on the UI and give an option to the users to update the value.Code:<on-start> <evaluate expression="myUtil.setUpMyFlowUtil" result="flowScope.myFlowUtil"/> </on-start> <view-state id="first"> <transition on="blah" to="second"/> <transition on="updatePref"> <evaluate expression = myFlowUtil.setUserPreference(requestParameters.newPreference)/> </transition> </view-state> <view-state id="second"> <transition on="updatePref"> <evaluate expression="flowScope.myFlowUtil.setUserPreference(requestParameters.newPreference)"/> </transition> </view-state>
first.jsp
second.jspCode:<input type="text" name="userPref" value="${myFlowUtil.userPreference}/> <button type="submit" id="#userPref"/>
Code:<input type="text" name="userPref" value="${myFlowUtil.userPreference}/> <button type="submit" id="#userPref"/>
on both the pages, I use ajax get to pass the new value to the server.
This code almost seems to work except for one thing. If I update the preference value on first.jsp, I can see the new value on the second page. But if I update the value on second page and click first page navigation link, the old value is still there. We have breadcrumb navigation on our site that I have implemented following the tutorial at http://www.jwse.nl/blog/?p=167.
This is a really confusing issue. I thought we can update the flowScope variables and on every page render, we get the fresh flowScope variables. There is only one myFlowUtil object in the flowScope and once I updated the value in second.jsp, I expect to see this new value even if I trail - back in my navigation. Isn't that how flow works? Looking at the debug statements, it almost looks like, FlowExecutionListener is keeping a static memory of each view-state and using that memory to render the page every time it is shown.
If this is infact how the listener works, what changes I should make so that the new value of preference is rendered even if I navigate to previous page on the flow. Thanks!


Reply With Quote
