ColdFusion, WDDX, and Flash (Page 4 of 8)


You'll notice in the ColdFusion template that was included with the source files that line 11 is missing. This was done intentionally. Add the following line of code to line 11 in the template:

<cfwddx action="CFML2WDDX" input="##GetEmployees##" output="myWDDXPacket">

Your ColdFusion template is now complete and should work well when it is called from Flash later on. However let's go ahead and test the template to be sure everything is in order. Start up another instance of your web browser and load the ColdFusion template in the wddxTutorial directory you created earlier.

The first thing you will notice is that all your data is displayed in one large string. This is good. To see the actual WDDX packet (XML), view the source of your template. See what ColdFusion has done? It's created well-formed and valid XML for you! Pretty neat huh? I ran into a couple of problems when ColdFusion output the packet. Viewing the source of the CF output will allow you to be sure there are no blank lines at the head of the packet. Because we are using CFSILENT coupled with ENABLECFOUTPUTONLY you should be okay. There are some additional tags in the ColdFusion language that will aid you in being sure your packet is valid XML.

This function was introduced in ColdFusion 5.0. It returns true if your packet is well-formed and false if not.

This is another ColdFusion function that will escape special XML characters so that you can put arbitrary strings safely into XML. The characters that are escaped by XMLFormat include: greater than sign (>), less than sign (<), single quotation mark ('), double quotation mark ("), and the ampersand (&).

There is also a set of WDDX JavaScript Objects that you may find useful. Check your ColdFusion help files for more information on these.