5 Replies Latest reply on Oct 1, 2008 3:56 PM by JasonMH

    General AIR "Can it be done" Questions

    NateBaldwin Level 3
      I'm setting up a proposal for a job that will involve AIR, and I wanted to make sure I had my facts straight. My intentions are to use a MySQL database on an external server, but build an AIR application in Flex Builder (3) for the user front-end.

      Am I correct in assuming that I'll be able to build a user interface to run in AIR with an internal SQLite database - the application would work directly in the SQLite database, then sync with MySQL on the web server (I'm very familiar with PHP, which I'd use as the go-between)? Basically, I want the user to be able to manipulate the data even if they're not online, but I need to be able to later share the data from the web server with external users without a manual export.

      Also, how "behind-the-scenes" can the syncing be? Assuming I can have it check for a connection and auto-sync with the web server on application launch (or data edit).

      Finally, are there any tools available for exporting data to Office applications like Excel or Access? Could always dump Excel-compatible HTML tables or delimited text files and share data that way, but was hoping for something more direct, possibly allowing for data formatting and such. Not essential, but would be a nice touch.

      Thanks in advance for any help.
        • 1. Re: General AIR "Can it be done" Questions
          ilsh Level 1
          An AIR application I am working on is basically doing the same thing with yours -- store data locally (sqlite) and synchronize with remote mysql (server side php). However, I am not aware of how AIR can automatically synchronize for you; I had to write the sync code myself.
          • 2. Re: General AIR "Can it be done" Questions
            JasonMH
            I use WebOrb for PHP to handle communication between the client and the server. The syncing logic is not provided for you, though, only the communication. You will run into various minor glitches passing data back and forth like translating Date values, dealing with nulls, etc.

            If you just have straight-up replication I think there may be some ready-made solutions such as Blaze, but that's in Java. If it is not simple replication, you will have to write all the logic yourself to deal with syncing, conflict resolution, etc.

            The good news is that it can be very seamless for the user, but depending on your app it is not necessarily easy to write.

            As far as I know there's no utils for importing directly from office applications, but of course you can write whatever you want to parse text files.
            • 3. Re: General AIR "Can it be done" Questions
              NateBaldwin Level 3
              Thanks both - that's what I needed to know. Should be able to handle manual syncing, just wanted to make sure that was how it had to be done. If I can post a follow-up question... grabbing bulk data from the server is straightforward enough, but what are you using to push data in bulk from the internal SQLite DB to MySQL? Is that where WebOrb comes in, or are you having to post the data with multiple HTTP(S) requests?
              • 4. Re: General AIR "Can it be done" Questions
                ilsh Level 1
                I use amfphp for both retrieving data from mysql and pushing data to mysql.

                quote:

                Originally posted by: NateBaldwin
                Thanks both - that's what I needed to know. Should be able to handle manual syncing, just wanted to make sure that was how it had to be done. If I can post a follow-up question... grabbing bulk data from the server is straightforward enough, but what are you using to push data in bulk from the internal SQLite DB to MySQL? Is that where WebOrb comes in, or are you having to post the data with multiple HTTP(S) requests?


                • 5. Re: General AIR "Can it be done" Questions
                  JasonMH Level 1
                  quote:

                  Originally posted by: NateBaldwin
                  ...what are you using to push data in bulk from the internal SQLite DB to MySQL? Is that where WebOrb comes in, or are you having to post the data with multiple HTTP(S) requests?


                  The cool thing about WebOrb is that you really just create a plain old PHP class with whatever methods you want and throw it in the WebOrb services folder. That's it. You don't put any special "weborb" code in your PHP, you don't inherit from any special class. It's just plain old PHP classes. Your Flex project can start making remote calls directly to that PHP code using RemoteObject. Your methods can have simple arguments or even complex types and you can use metadata in Flex to map Flex classes to PHP classes. WebOrb automagically does the conversion for you both ways. As I mentioned, though, it's not all rosy - Dates and certain other things can cause grief for you until you figure it all out.

                  You can get the same results with amfphp however I wonder if that project has been abandoned since the original developer left the project? The last release v1.9 was written when Flex2 came out and it is missing some low-level stuff like authentication. WebOrb also has a really nice management console that auto-generates client Flex code for you in a variety of formats (PureMVC, Cairngorm, plain AS3, etc)