As I mentioned earlier this week, building AIR applications using HTML and JavaScript is pretty simple (arguably easier than doing so in MXML/AS for those of us with a web background). But how do you port a ColdFusion powered web app to be an AIR app?
One simple solution is not to. After all, you could create a simple AIR app that just invoked the URL of your ColdFusion app (perhaps in a frame if using HTML/JS, or in an HTML control if using Flex). But that’s cheating, all you’ve really done is turned your AIR app into a custom browser.
To truly turn your ColdFusion web app into an AIR app you need to keep in mind the following:
- AIR can’t process CFML, but it can process the HTML generated by CFML.
- Within an AIR application, all required external files (for example, JavaScript files) should be local, within the AIR app itself.
- Within an AIR application, relative paths will point within the AIR application, not back to the server.
With that said, here is a simple example (based on the two related Ajax controls that I posted months ago):
- Create a new project or site for your new AIR application.
- Execute the ColdFusion app (the .cfm for the two related controls) in your browser to make sure it is working.
- Use the browser View Source option to see the ColdFusion generated source.
- Save the source as a file in to your AIR project or site (you’ll probably want to use a .htm extension, instead of .cfm).
- Check the newly saved file for any relative URLs (both in your own code, as well as ColdFusion generated JavaScript) and edit those URLs so that they are fully qualified. In the two related controls example, the only paths you need to worry about are the two JavaScript calls back to the art.cfc (passed to ColdFusion.Bind.register).
- If the generated code refers to ColdFusion JavaScript files /CFIDE/scripts (the two related controls example obviously does) then you’ll want to copy that folder into your your AIR project. You can copy the entire /CFIDE/scripts folder, or just the required files (the latter is preferred, but requires a bit more effort on your part).
- Now just run the app (in Dreamweaver you can right click, and then Preview In Adobe AIR, or Package As Adobe AIR Application).
Obviously, this process is far from perfect. But, until we implement native AIR integration in ColdFusion, this is a workable solution.
Leave a Reply