TerrenceRyan.com

I'm a 35 year old redhead geek from Philly.
I'm currently a Developer Evangelist for Adobe.
Also the author of Driving Technical Change

Entries for month: February 2009

ColdFusion + AIR applications

I'm just getting started into this evangelist thing, and I'm having trouble figuring out what AIR applications out there are being powered by ColdFusion on the backend. The only one that comes to mind for me at the moment is Broadchoice.

Can the ColdFusion community help me find the following?

AIR applications using either Flex or HTML/JS that use ColdFusion for any part of their backend

Please send URL's and any commentary to the comments of this page. Alternately, contact me through my contact page if you're willing to help, but can't talk about these things publicly.

How to Get Started With Flex

Due to a recent tweet of mine, I've received an influx of requests on how to get started with Flex. Here's how to get started with Flex:

Go to the Flex Download Site to download the 60 day free trial version of Adobe Flex Builder 3.

Then to learn Flex, check out the following:

Anyone else have good resources for learning Flex?

Flex Camp Miami

If you're looking to get a leg up on your Flex knowledge, or see a preview of what's coming in Flex 4, you should head to Flex Camp Miami on March 6th.

Flex Camp Miami
March 6th 8am - 5pm
BankUnited Center
University of Miami
Register

Flash Camp

Flash Camps are technical showcases for the Flash platform. At these events top speakers from both Adobe and the Flash Platform community show off both code samples and demos, to both help jump start new developers and inspire proficient developers with new areas to explore.

Getting Adobe Software For Higher Education

A couple of my educational customers have asked me this, and I figured I would come up with a canonical (for me at least) answer.

How do I get Adobe Software with educational pricing?

Free Software

Both ColdFusion and Flex Builder are free for Students, Faculty, or Staff using them for academic purposes. In order to take advantage of that, you have to go to either the Flex or ColdFusion FreeRIATools site. The only thing you have to do to secure the software is prove you are eligible. The easiest way to do so is to take a picture of your student ID and send it in. I know from experience that they accept that.

If you would like to obtain a bulk license for a lab or classroom, you can do it through that site. You just:

Discounted Software

In North America, Adobe has a tool that will allow you to search for local resellers for our products. I did a spot check for the Philadelphia area (my local), and it looked very up to date.

Adobe - Find an education reseller

In Europe (and North America) Adobe products can be found online at Studica. Additionally Fuzzy Orange, can also resell Adobe software and provide educational discounts. They do not have a online catalog/store, but if you contact them they will be more than happy to help you out.

In other parts of the world, the online Adobe store has an educational section:

Adobe Store – Select a store

I'm not convinced this covers everyone so if you can't find a way to buy Adobe products for Higher Education in your country or region, let me know, and I'll research it.

Adobe Day - Washington DC

Adobe Days are free events designed to introduce you to various players on the Flash platform. Next week in DC we'll be doing one focusing on Flex and ColdFusion.

I'll be attending, lending moral support to Ryan Stewart. And by "lending moral support to" I mean "learning the ropes from".

So if you're in DC and are looking for a good and free overview of what Flex can do for you, c'mon down.

Adobe Day Washington, D.C.
Thursday, February 26, 2009
9:30 a.m. - 2:00 p.m. EST
Agenda

Grand Hyatt Hotel
1000 H St NW
Washington DC 20001

Registration is free.

Link: Adobe Day Washington DC

ColdFusion Has Many Roles to Play

Finishing up my series on my idea of why I am drawn to ColdFusion is my final point - ColdFusion has many roles to play. ColdFusion doesn't force you to use only it for all layers of your web application. You can selectively choose to use ColdFusion for as much or as little of your application as you want. ColdFusion doesn't just allow this, like everything else, it makes it easy. Off the top of my head here are some uses cases for ColdFusion in your application:

Let's start with the traditional HTML generated application:

<cfquery name="qry" datasource="cfartgallery">
   SELECT    *
   FROM    app.artists
</cfquery>

<table>
   <tr><th>Name</th><th>City</th><th>State</th></tr>
   <cfoutput query="qry">
      <tr><td>#firstName# #lastName#</td><td>#city#</td><td>#State#</td></tr>
   </cfoutput>   
</table>

Sure, I can just take a query and pass it to an HTML renderer and... instant data screen. ColdFusion can do the entire thing. But that code would provide a poor user experience. That table is pretty much just phoning it in. Instead, I can use ColdFusion's built in AJAX features to make a better UI using a datagrid.

First I have to move the query to a CFC, and run it through a simple function that formats the data for the datagrid:

<cfcomponent output="false">
   
   <cffunction name="list" access="remote" returntype="query">
      <cfset var qry = "" />   
   
      <cfquery name="qry" datasource="cfartgallery">
         SELECT    *
         FROM    app.artists
      </cfquery>

      <cfreturn qry />
   </cffunction>

   <cffunction name="listForGrid" access="remote" returntype="struct" returnformat="json">
      <cfargument name="page" type="numeric" required="true">
      <cfargument name="pagesize" type="numeric" required="true">
      <cfargument name="sortcol" type="string" required="false">
      <cfargument name="sortdir" type="string" required="false">
      
      <cfreturn queryConvertForGrid(list(), arguments.page, arguments.pagesize) />
   </cffunction>

</cfcomponent>

Once that is done, I can call that CFC from a datagrid component:

<cfform name="tableform">
<cfgrid format="html" name="grid"
   bind="cfc:data.listForGrid({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})">

<cfgridcolumn name="firstName" header="First Name" >
<cfgridcolumn name="lastName" header="Last Name" >
<cfgridcolumn name="city" header="City" >
<cfgridcolumn name="state" header="State" >
</cfgrid>
</cfform>

Or I can instead opt out of using ColdFusion UI components, and either roll my own or use an established framework (both using cfajaxproxy):

<cfajaxproxy cfc="data" jsclassname="cfData" />

<s cript type="text/javascript" src="qtt.js" />

<div id="dataTable" />

<s cript type="text/javascript">
   
   var cfData = new cfData();
   cfData.setSyncMode();
   cfData.setQueryFormat('column');
   
   datatable = document.getElementById('dataTable');
   res = cfData.list();
   table = queryToTable(res);
   
   datatable.appendChild(table);
   
   function queryToTable(result){
   
      table = document.createElement('table');
      tbody = document.createElement('tbody');
      
      for(i=0;i<res.ROWCOUNT;i++){
    row = document.createElement('tr');
         
         cellFname = document.createElement('td');
         txtFname = document.createTextNode(res.DATA.FIRSTNAME[i]);
         cellFname.appendChild(txtFname);
         row.appendChild(cellFname);
         
         cellLName = document.createElement('td');
         txtLName = document.createTextNode(res.DATA.LASTNAME[i]);
         cellLName.appendChild(txtLName);
         row.appendChild(cellLName);
         
         cellCity = document.createElement('td');
         txtCity = document.createTextNode(res.DATA.CITY[i]);
         cellCity.appendChild(txtCity);
         row.appendChild(cellCity);
         
         cellState = document.createElement('td');
         txtState = document.createTextNode(res.DATA.STATE[i]);
         cellState.appendChild(txtState);
         row.appendChild(cellState);
         
         tbody.appendChild(row);
         
    }
      
      table.appendChild(tbody);
      return table;
   }
   
</script>

If, however, I wanted to go with something other than HTML/JavaScript for the front end, I still have options. ColdFusion is perfectly suited to act as a back end for Flex. In fact that CFC above still works with Flex. To call it from Flex I just have to point an end point to it and add a datagrid:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" applicationComplete="getList(event)">

   <mx:Script>
      <![CDATA[
         import mx.collections.ArrayCollection;
         import mx.rpc.events.ResultEvent;
         
         [Bindable]
         private var ac:ArrayCollection;
         
         private function onResult( e : ResultEvent ) :void
         {
            ac = e.result as ArrayCollection;
         }
         
         private function getList( e:Event ) :void
         {
            ws.list.send();
         }
         
      ]]>
   </mx:Script>

   <mx:RemoteObject id="ws" destination="ColdFusion" source="CFisEasy.roles.data">
   <mx:method name="list" result="onResult(event)" />
   </mx:RemoteObject>

   <mx:DataGrid left="10" right="10" top="10" bottom="10" dataProvider="{ac}" />
   
</mx:Application>

But let's say that you instead wanted to interact with some sort of other interface like SMS, JMS, or as in the following example, an XMPP client using Gtalk:

<cffunction name="onIncomingMessage" output="false">
<cfargument name="incomingIM" type="struct" required="true" />

   <cfset var outgoingIM = StructNew() />
<cfset var data = createObject("Component", "data") />
   <cfset var people = data.list() />
   <cfset var message ="" />

   <cfloop query="people">
      <cfset message = message & "#firstName# #lastName# #city# #state# #Chr(10)#" />
   </cfloop>   

   <cfset outgoingIM.BuddyID = arguments.incomingIM.Data.sender />
   <cfset outgoingIM.Message = message />
<cfreturn outgoingIM />
</cffunction>

That's a lot of mileage out of that little query. From that simple query, I've rendered a plain old HTML page, a ColdFusion AJAX display page, a custom written AJAX-driven page, a Flex display component, and a Gtalk Bot. That's what I mean by ColdFusion can play lots of roles. It can do the whole thing, or just part of it. Combine that with the concepts in my previous post, and ColdFusion can do the following:

The idea here is that when you use ColdFusion, you can either use it full hog, or selectively swap in technologies that better address your needs. ColdFusion doesn't lock you in; quite the opposite, it opens doors for you.

ColdFusion Developers the Flex Builder Team Wants You

Tim Buntel just posted a call for ColdFusion Developers to join the pre-release program for Flex Builder 4. There are some new features in there will be especially appealing to you, and he wants your feedback. Go help him out, and see the cool things coming down the pike.

Link: CF and the future of Flex

ColdFusion Plays Well With Others

Continuing on with the series I started on Tuesday, I'm going to explore ColdFusion's ability to play with many other technologies, and do so very well.

First, let's start with what ColdFusion was designed for, getting information out of databases. ColdFusion ships with drivers for talking seamlessly to the following database systems:

Does that mean if you are a FoxPro or SQLite developer, you're out of luck? Hardly - if it has a JDBC driver you can talk to it with ColdFusion.

Databases are only a portion of what you have to deal with, especially if you are talking to back end systems with various interfaces. The can include directory servers, file servers, mail servers, etc. Here's a non exhaustive list of ColdFusion tags that can talk to those sorts of servers:

cffile, cfdirectory 

Both local and remote file stores 

cfexchangecalendar, cfexchangemail, cfexchangeconnection, cfexchangetask, cfexchangecontact, cfexchangefilter

Microsoft Exchange Servers 

cfftp  

FTP and SFTP servers 

cfhttp 

Other web servers, REST webservices 

cfldap  

LDAP Directory services, Active Directory 

cfmail, cfmailpart, cfmailparam 

SMTP servers for sending mail

cfobject, cfinvoke

SOAP webservices 

cfntauthenticate 

Active Directory for authentication purposes 

cfpop 

POP3 Mail servers for acting as a mail client 

cfprint 

Any printer accessible by the ColdFusion host 

 

That's a pretty big list. Keep in mind that it's not just about talking to those services; it's about easily talking to those services. Yesterday, I showed the cfexchange tags and cfmail tags in action. They're all pretty much that easy and concise to use.

Next, ColdFusion can call just about anything that can be run from the command line via cfexcecute:

<cfset pathToScript = ExpandPath('.') & "/rubytest.rb" />
<cfexecute name="ruby" arguments="#pathToScript#" variable="results" timeout="1" />
<cfoutput>#results#</cfoutput>

That's not necessarily compelling. Pretty much every programming tool can make calls to the shell. But I think it's important to point it out, keeping in mind that this is a must have feature for any tool.

But shelling out to the OS, running a command, reading it into a variable and parsing it is a pain. It's a lot of extra coding, extra bug trapping, and usually a performance hit. So it would be nice if you could interface with certain other tools without having to do that.

I kinda, gave a sneak preview of some of this content the other day, when I showed getting information from .Net into Java in two lines of code:

<cfset pwd = CreateObject(".Net", "System.IO.Directory").getCurrentDirectory() />
<cfset jString = CreateObject("java", "java.lang.String").init(pwd) />

I didn't have to import any libraries to accomplish this, it just worked from the moment I installed ColdFusion. I consumed a .Net assembly, got a string from it, and passed it a Java Object. That was just a string, but if the return had been a more complex object, ColdFusion would have converted it to a native ColdFusion structure. Any errors would have been caught and delivered via ColdFusion's error handling mechanism. The same applies to the Java call.

The .Net communication was added in ColdFusion 8, but the Java communication has been around since ColdFusion MX 6. The reason behind this is the often overlooked fact that ColdFusion is written in Java, runs on Java, and can be looked at as Java framework. Anything Java can do, you can get done in a ColdFusion page or component. You might have to drop down to coding in Java to do it, but that's pretty easy to do:

<cfset math = CreateObject("java", "java.lang.Math") />
<cfset result = math.pow(2,5) />
<cfoutput>#result#</cfoutput>

As you can see, I can use the result generated by Java without any special conversion.

Finally, ColdFusion can run with support from Adobe on many platforms:

Those are just the supported platforms. It's also quite possible to run CF on Ubuntu or Centos. (But I must stress, Adobe doesn't support these distros of Linux, yet.)

I hope, I was able to show you in this long, but frankly shallow overview, that ColdFusion can talk to a lot of different system, using many different interfaces, and do so on pretty much every mainstream platform you could need.

DMD Project at Carnegie Mellon University

I got to see a very cool use for Flex and AIR in Higher Education today. It's the DMD Project from the Masters in Human-Computer Interaction Program at Carnegie Mellon University.

It's a prototype RIA for patient management at dental offices. It was designed for touch screens, but also can be used with the traditional keyboard and mouse interface as well. It shows everything dentists, hygienists, and front office staff would need to manage the entire patient interaction.

I got a chance to talk with one of the developers, Jaanus Kase, about it. He told me that they spent most of their time upfront researching how exactly dentist's offices would need to interact with a system. That yielded a few custom interfaces, including the "radiograph view" which the rest of us just know as "an x-ray of all of your teeth." The other cool thing I noticed was the high emphasis they place on important information like "Severe Penicillin Allergy." Clearly, this program really does focus on quality computer-human interactions.

The project itself is a prototype; don't expect to see it in your dentist's office anytime soon. But the app is available as an AIR application for your review.

Jaanus is done with the Masters program now, and is working with an startup in New York named World Evolved.

Queries are the Secret Sauce of ColdFusion

Kevin Hoyt commented on my blog post yesterday about ColdFusion Makes Hard Things Easy. He reminded me of a feature of ColdFusion that gets overlooked because it is so elemental to the language: the query variable.

In ColdFusion results that are returned from database get returned in a query variable. Query variables are an implementation of the iterator pattern and have a few special properties:

That's all a really complicated way of describing what happens in this code:

<cfquery name="qry" datasource="cfartgallery">
   SELECT    firstName, lastname
   FROM    app.artists
</cfquery>

<cfoutput>
   <p>#qry.recordCount# records returned with columns named: #qry.columnList#</p>
</cfoutput>

<cfoutput query="qry">
#currentRow# of #recordcount# - #FirstName# #lastName#<br />   
</cfoutput>

You see, the first cfoutput tag didn't have a query attribute, so I had to prepend the properties recordCount and columnList with qry. Later when I was iterating over the query using cfoutput, I didn't have to bother prepending.

That's cool, and easy, but not outside the realm of what you can do in other languages. So let's get to what Kevin mentioned in his comment Query of Queries. Query of Queries refers to ColdFusion's ability to use a ColdFusion query as a table against which to perform SQL in another query. Want to get all of the records from the previous query that begins with A:

<cfquery name="anames" dbtype="query">
   SELECT    firstName, lastname
   FROM    qry
   WHERE    firstname like 'A%'
</cfquery>

Want to get all of the records that begin with E:

<cfquery name="enames" dbtype="query">
   SELECT    firstName, lastname
   FROM    qry
   WHERE    firstname like 'E%'
</cfquery>

Want to combine the A records and E records:

<cfquery name="uber" dbtype="query">
   SELECT    firstName, lastname
   FROM    anames
   UNION
   SELECT    firstName, lastname
   FROM    enames
</cfquery>

That's right query of queries will let you do unions or joins too.

Now some of you might be questioning the usefulness of this. You think things like filtering, joins and unions are operations best handled by the database. You're right they do. But, imagine that I was pulling data out of separate databases, perhaps one in Oracle, and one in MSSQL? You couldn't do it in the database.

Also cfquery is not the only tag in ColdFusion that creates query variables. The others include (But I'm sure I'm missing some):

That means you can take any of the results of these tags and filter and group and join them just the way you can with a database. Want to see all of the files in your directory and are not .cfm files:

<cfdirectory action="list" name="files" directory="#ExpandPath('.')#" />
<cfquery name="nonCFFiles" dbtype="query">
   SELECT    *, directory + '/' + name as fullpath
   FROM    files
   WHERE    name not like '%.cfm'
</cfquery>

<table>
<cfoutput query="nonCFFiles">
<tr>
   <td>#fullpath#</td>
   <td>#size#</td>
   <td>#datelastmodified#</td>
</tr>
</cfoutput>
</table>

That's pretty easy, and I think that qualifies as something not every solution can do. It opens up the door to a lot of other possibilities:

ColdFusion queries, and query of queries are powerful features that make one of the most common jobs in web programming – displaying some kind of retrieved record – shockingly simple. Add to it that the number of entities addressable in a ColdFusion query includes many other sources than just the database, and you have one powerful feature that is not easily matched.

Categories

Monthly Archives

Tag Cloud

coldfusion web development flex coldfusion builder appearances squidhead coldfusion builder extensions higher ed flash builder air mobile android adobe apptacular html5 driving technical change running a coldfusion shop adobemax06 movable type flash catalyst flash blackberry adobemax07 adobemax08 hero finicky css adobemax09 holy crap i’m a mobile developer centaur basecamp cfc unfuddle motorola metablog irrational characters ios git evangelism devices code reviews ant wharton subversion security phonegap philly philadelphia multidevice knowledge@wharton jobs browserlab adobemax10 adobe tv unfuddlecfc svnauth.cfc semantic html semantic html responsive web design qnx nlb linux jquery mobile java it github flexorg fireworks edge eclipse dreamweaver apps apple adobemax11