4 Replies Latest reply on May 23, 2011 11:41 AM by chiedozi

    Clarification of Session Persistence

    cfjedimaster Level 3

      I want to make sure I understand something about Session Peristence (http://help.adobe.com/en_US/flex/mobileapps/WSb0a29bf92525419c-54dd253312afbec3ecb-8000.ht ml#WS8b1c39bd7e9fc364-26b394fa12ba6c7fdd7-7fff). Is it meant to only persist information in the "data" variable? That's what my testing shows and the example in the docs demonstrate that.

       

      I have a VERY simple one page mobile app. It has no views. I want to maintain state though in case the app gets shut down. Normally "data" exists when you call a 2nd (or N) view and pass stuff. In my testing I could use a viewActivate/init() function and do something like:

       

      if(data == null) data = {};

       

      Is this recommended? It seems to work fine, but isn't quite how things are documented. But I have to assume that support for an app being shut down on the first view is expected as well, right?

        • 1. Re: Clarification of Session Persistence
          jrunrandy Adobe Employee

          Hi Ray,

          Stephen is out on jury duty today, and he's the expert on the persistence doc, so don't take my feedback as gospel....

           

          I wrote a simple app, changed things on the initial view, closed the app, and my changes were present when I reopened it, so It looks like the data object gets created as you make changes to the first view.

           

          HTH,

          -Randy

          • 2. Re: Clarification of Session Persistence
            cfjedimaster Level 3

            That's my experience too. I have to say - the "data" concept is an odd one. In some cases it acts like an Arguments scope (ala ColdFusion) for Views. I can load a view and pass crap in and it works great. But it also acts like a "This is stuff you should care about!" scope in terms of persistence. It all kinda works but feels a bit underdocumented/fleshed out. I say that with all due respect. The confusion is probably all just me being new to it.

            • 3. Re: Clarification of Session Persistence
              jrunrandy Adobe Employee

              Yeah. Now that the dust has settled a bit, I'll ask Stephen to look in to this and see what else we can say.

               

              Thanks for the feedback,

              -randy

              • 4. Re: Clarification of Session Persistence
                chiedozi Level 1

                Hey,

                 

                So how the persistenceManager works is when the application is shutdown, it will automatically save all the information that is stored in each view's data property, and any data set using the persistenceManager.setProperty() method.  When the applicaiton is relaunched, the data property will be assigned to what it previously was.  It is the responsibilty of the developer to initialize a view's state based on the data when the view is created. 

                 

                All views, regardless of whether its the first one or not, has a data property, and the information will be saved.  As stated above, you can also use the setProperty() method to save other data or more global information.

                 

                Hopefully that helped, if not, let me know.

                Chiedo