4 Replies Latest reply on Sep 8, 2007 11:30 AM by Naseem_Khan

    viewstack child container


      I am using viewstack in a flex application where I have different child containers (VBox). I am showing the child containers by its id.


      <mx:ViewStack id="myViewStack" width="100%" height="100%" y="0"
      paddingLeft="0" paddingRight="0" paddingTop="0" >

      <TRAVEL:activityMonitor width="100%" height="100%" name="activityMonitor" id="activityMonitor"/> <TRAVEL:travelReq1 width="100%" height="100%" name="requestStep1" label="Step 1" id="requestStep1"/>
      <TRAVEL:travelReq2 width="100%" height="100%" name="requestStep2" label="Step 2" id="requestStep2"/>
      <TRAVEL:travelReq4 width="100%" height="100%" name="requestStep3" label="Step 3" id="requestStep3"/>

      Now to show a displayobject of my viewstack say travelRequest1.mxml page, I call viewPage(Application.application.requestStep1) function which is like this:.


      function viewPage(displayPage:DisplayObject):void{
      Application.application.myViewStack.selectedIndex=Application.application.myViewStack.get ChildIndex(displayPage);

      Now say I am on page travelRequst1.mxml, I enter some text in travel form. Make a db hit and save the entered data and move to some other mxml page by calling the same viewPage() method.

      When I come back to my travelRequest1.mxml page, I found that all my previous entries are still in the form. I am getting a filled page. How do I get a blank page everytime I come to travelrequest1.mxml. I think that flex caches all my previous data but not sure.

      Guys please help me out.

      Warm Rgds,
        • 1. Re: viewstack child container
          Naseem_Khan Level 1
          Hi guys,

          I googled it alot but I did not find solution for this. There was some discussion on displayObject loaderInfo to get first a loader info and get its loader and call unload() method to unload the data.

          No clue whats going on behind the scene in flex. On some pages, I have grid rows which are dynamically added in the pages when user click + button and gets removed when user clicks - button.

          Now if on some page, I add few grid rows and then simply go to some other page. When I come back to my first page, all my previous grid rows are still in the mxml page.

          Please provide some pointer on this.

          Thanks and Regards,
          • 2. Re: viewstack child container
            JKohn99 Level 1
            You're thinking like a web developer where moving from page to page
            is a server trip and a refresh of the page. Your components that you make visible in your view stack are created once and sitting in memory (on the client). So when you go backthe page will aways appear like you left it.

            So you must add an initialization type function to your components to set things
            the way you want them before you show the page.

            add a mx:Script tag and add a public method that does what ever
            updates as you require.

            • 3. Re: viewstack child container
              Handycam Level 1
              You could also put the form in a pop-up window. When the window is destroyed (i.e. in your "submit") handler the data is discarded.

              The next time you call the function to open the form window, the form will be blank (unless you create code to save & redisplay the entries yourself).
              • 4. Re: viewstack child container
                Naseem_Khan Level 1
                Thank you so much for giving your time and looking it. Well I thought that there will be some enbuilt fucntion in flex might unload all the data from the mxml page. Anyway I will write code which will initialize my each mxml page when user visit next time.