Monday, March 3rd, 2008

Dojo on AIR shows detail on AIR itself

Category: Adobe, Dojo

At first when you hear “FooAjaxLibrary now supports AIR” you think “er, OK, AIR has WebKit so it supports them all doesn’t it?”. SitePen added support for AIR in Dojo and gave us detailed information about the changes.

The value of this document is that it gives hints to us Ajax folk as we develop applications running on AIR. The main message is that the security sandbox that AIR gives you has subtle side effects that you need to be aware of.

For example, note the function(){} wrapper in the AIR-specific code:


  1. if (dojo.isAIR) {
  2.         this._xdTimer = setInterval(function(){dojo._xdWatchInFlight();}, 100);
  3. } else {
  4.         this._xdTimer = setInterval(dojo._scopeName + "._xdWatchInFlight();", 100);
  5. }

There are other small issues such as not having eval() available post-load that you can see in the changeset. If you run into something as you develop your Ajax application in AIR, you have another resource to check (as well as the Adobe resources of course).

As well as making changes to get Dojo working in AIR, SitePen also added support for some of the AIR APIs themselves, including:


The AirFileStorageProvider store the data in flat files in the app-storage directory. For example, a key of “MyKey”, value of “Hello World!”, and namespace of “MyNamespace” would create the file app-storage:/__DOJO_STORAGE/MyNamespace/MyKey which contains the text “Hello World!”. This storage provider allows for large amounts of data to be stored. Not only can strings be stored, but also objects thanks to AIR’s serialize/de-serialize functionality. On the downside, data is not encrypted on disk. It would be trivial however to encrypt the information using dojox.crypto before storing the data.


The AirDBStorageProvider leverages AIR’s embedded database. When the provider is initialized, a database file is created in the app-storage directory and the Dojo storage table is created. The table holds the namespace, key, and value. This provider is similar to the AirFileStorageProvider in which it can store large amounts, but it cannot store serialized objects because there is no way to de-serialize them due to eval() being unavailable post-onload. The database file is not encrypted, but you could encrypted the data using dojo.crypto prior to storing the data. One advantage of the AirDBStorageProvider is there is only one file written to disk whereas the AirFileStorageProvider writes a file for each key/value.


The AirEncryptedLocalStorageProvider uses AIR’s encrypted local data store functions. Data, such as passwords, will be encrypted when being stored and decrypted when being retrieved. Similar to the AirEncryptedLocalStorageProvider, objects cannot be stored because they cannot be
de-serialized with an eval(). One limitation of the AIR’s encrypted local data store is it does not provide a way to enumerate keys. To solve this, the AirEncryptedLocalStorageProvider creates a registry using AIR’s encrypted local data store to track the namespaces and keys.

Dojo adds it’s name to the list of Ajax frameworks that are ready for AIR work. Since Dojo has a large coverage of features (especially via the dojox.* components) it can be well suited for larger desktop apps.

Posted by Dion Almaer at 8:10 am
Comment here

4.1 rating from 21 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.