Announcement Announcement Module
Collapse
No announcement yet.
Viewstate on render - set up default Model parameters Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Viewstate on render - set up default Model parameters

    Hi,

    Can someone please clarify at what instant the "model" objects of view state will be added to the flowscope? I am trying to setup some default values to my model object but the object isn't there in flowcope at on-render time.

    Here is what I have so far..

    myflow.xml........

    Code:
     <flow....>
                 <on-start>
                        <evaluate expression="myFlowAction.setupFlowData"/>
                 </on-start>
    
                 <view-state id="home" view="home" model="homeModel">
                        <on-render>
                                   <evaluate expression="myFlowAction.setupHomeModelDefaults"/>
                       </on-render>
                       <transition>.........</transition>
                 </view-state>
      </flow>
    MyFlowAction

    Code:
        public class MyFlowAction extends MultiAction{
    
                      public void setupFlowData(RequestContext context){
                                        //setup data required through out the flow
                        }
    
                     public void setupHomeModelDefaults(RequestContext context){
                                         HomeModel homeModel = context.getFlowScope().get("homeModel");
                                        
                                        homeModel.setXXX();
                                        ////////////////
    
                     }
    
        }
    but the homeModel object in setupHomeModelDefaults in null. I thought that the model will be added to flow scope before rendering the page. If I change the method to like the one below, it works perfectly.

    Code:
     public void setupHomeModelDefaults(RequestContext context){
                                         HomeModel homeModel = new HomeModel();
                                        
                                        homeModel.setXXX();
                                        ////////////////
    
                                         context.getFlowScope().put("homeModel", homeModel):
    
                     }

    Are we supposed to manually add the model object after setting the values all the time? I am sure I must be missing something here.

    Thanks in advance!
Working...
X