<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Dan&#039;s Drivelings &#187; ColdFusion</title>
	<atom:link href="http://www.tntechnohermit.com/category/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tntechnohermit.com</link>
	<description>Random Thoughts of a Techno-Hermit</description>
	<lastBuildDate>Thu, 01 Sep 2011 16:37:53 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Automatically encrypting and decrypting data with ColdFusion ORM and annotations</title>
		<link>http://www.tntechnohermit.com/2011/04/04/automatically-encrypting-and-decrypting-data-with-coldfusion-orm-and-annotations/</link>
		<comments>http://www.tntechnohermit.com/2011/04/04/automatically-encrypting-and-decrypting-data-with-coldfusion-orm-and-annotations/#comments</comments>
		<pubDate>Mon, 04 Apr 2011 15:19:59 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.tntechnohermit.com/?p=525</guid>
		<description><![CDATA[I&#8217;m writing an application that uses ColdFusion&#8217;s ORM features heavily. Various fields in my database deal with Personally Identifiable Information (PII) and need to be encrypted to meet regulatory requirements. I&#8217;ve been mulling over the best way to deal with keeping the data encrypted while in the database but have it be readily usable when [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m writing an application that uses ColdFusion&#8217;s ORM features heavily. Various fields in my database deal with Personally Identifiable Information (PII) and need to be encrypted to meet regulatory requirements. I&#8217;ve been mulling over the best way to deal with keeping the data encrypted while in the database but have it be readily usable when loaded into an entity. None of the scenarios that came to mind felt right or could be implemented without an extensive amount of &#8220;work-around&#8221; code and I just wasn&#8217;t willing to go down those paths.  </p>
<p>I put the question out to the folks that follow me on Twitter and got a couple of responses, one of which was from <a href="http://www.compoundtheory.com">Mark Mandel</a> who suggested using annotations. Now, I&#8217;ve heard the word annotation mentioned, but had never had the time/opportunity to research what they were or how they were used. That was a few weeks ago and in the meantime, I&#8217;d gotten busy focusing on other things and just got around to thinking about the encryption thing again a few days ago. What I found out astonished me.<br />
<span id="more-525"></span></p>
<p>In ColdFusion CFCs, an annotation is nothing more than an additional attribute you put on a component, property or function tag (and maybe others too, but these will do for my scenario). To test this theory, I added the attribute <strong><em>encrypted=&#8221;true&#8221;</em></strong> to the password property of my User entity (the user accounts for people that are authorized to log into and use the application) and issued an ormReload() command to recreate the ORM entities. That worked without an error, but at this point it really didn&#8217;t do anything except just add a bit of metadata to that property tag.</p>
<p>The secret to the automatic encryption and decryption comes when you combine the <strong><em>encrypted=&#8221;true&#8221; </em></strong>annotation with the event handling methods provided by ColdFusion ORM. ORM provides the ability to run your own custom routines at various points throughout the ORM request cycle&#8211;preInsert(), preUpdate() and postLoad() are three of the ones that I took advantage of.  In essence, I used the preInsert() and preUpdate() methods to automatically replace the clear-text value of properties that had the <strong><em>encrypted=&#8221;true&#8221;</em></strong> flag with an encrypted version of that value. Similarly, I used the postLoad() method to reverse the process and replace the encrypted string that is stored in the database with the clear-text value.</p>
<p>I&#8217;ve included the code bits that I used below.</p>
<p>The password property of the User entity:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfproperty</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;password&quot;</span> </span>
<span style="color: #333333;">     encrypted<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span> </span>
<span style="color: #333333;">     <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> </span>
<span style="color: #333333;">     length<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;100&quot;</span> </span>
<span style="color: #333333;">     <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span> </span>
<span style="color: #333333;">     notnull<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></td></tr></table></div>

<p>The ORM event handler methods:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;preInsert&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span><span style="color: #0000FF;">&gt;</span></span>
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> encryptProperties<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;preUpdate&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span><span style="color: #0000FF;">&gt;</span></span>
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> encryptProperties<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;postLoad&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span><span style="color: #0000FF;">&gt;</span></span>
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> decryptProperties<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>I then created the encryptProperties() and decryptProperties() methods to loop through the properties of the given object looking for any properties that had the <strong><em>encrypted=&#8221;true&#8221;</em></strong> attribute set and perform the associated transformation when/if one is found:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;encryptProperties&quot;</span> </span>
<span style="color: #333333;">     output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> </span>
<span style="color: #333333;">     <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> </span>
<span style="color: #333333;">     returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
&nbsp;
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> props <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">getMetaData</span><span style="color: #0000FF;">&#40;</span> this <span style="color: #0000FF;">&#41;</span>.properties <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> array<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#props#&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;prop&quot;</span><span style="color: #0000FF;">&gt;</span></span>
          <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> <span style="color: #0000FF;">structKeyExists</span><span style="color: #0000FF;">&#40;</span>  prop, <span style="color: #009900;">&quot;encrypted&quot;</span> <span style="color: #0000FF;">&#41;</span> AND prop.encrypted <span style="color: #0000FF;">&gt;</span></span>
               <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables<span style="color: #0000FF;">&#91;</span> prop.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> </span>
<span style="color: #333333;">                 <span style="color: #0000FF;">encrypt</span><span style="color: #0000FF;">&#40;</span> variables<span style="color: #0000FF;">&#91;</span> prop.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">&#93;</span>, <span style="color: #009900;">&quot;&lt;key&gt;&quot;</span>, <span style="color: #009900;">&quot;AES&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
          <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span>
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;decryptProperties&quot;</span> </span>
<span style="color: #333333;">     output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> </span>
<span style="color: #333333;">     <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> </span>
<span style="color: #333333;">     returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> props <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">getMetaData</span><span style="color: #0000FF;">&#40;</span> this <span style="color: #0000FF;">&#41;</span>.properties <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfloop</span> array<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#props#&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;prop&quot;</span><span style="color: #0000FF;">&gt;</span></span>
          <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfif</span> <span style="color: #0000FF;">structKeyExists</span><span style="color: #0000FF;">&#40;</span>  prop, <span style="color: #009900;">&quot;encrypted&quot;</span> <span style="color: #0000FF;">&#41;</span> AND prop.encrypted <span style="color: #0000FF;">&gt;</span></span>
               <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> variables<span style="color: #0000FF;">&#91;</span> prop.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> </span>
<span style="color: #333333;">                 <span style="color: #0000FF;">decrypt</span><span style="color: #0000FF;">&#40;</span> variables<span style="color: #0000FF;">&#91;</span> prop.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">&#93;</span>, <span style="color: #009900;">&quot;&lt;key&gt;&quot;</span>, <span style="color: #009900;">&quot;AES&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
          <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfif</span><span style="color: #0000FF;">&gt;</span></span>
     <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfloop</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>To make the above approach even more useful, I put all those methods in a CFC named AbstractEntity.cfc that all my ORM entity CFCs extend.  So, now whenever I need to add another column to store encrypted data (no matter which entity I need them in as long as that entity extends the AbstractEntity.cfc), I define all the attributes for the property as normal and simply add the <strong><em>encrypted=&#8221;true&#8221;</em></strong> attribute to the property and ColdFusion handles the encryption and decryption for me automatically. The end result is that not only does this happen transparently to me as the developer, the clear-text values that I need to interact with in my application are encrypted when stored in the database as well as while in transit to/from the database.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2011/04/04/automatically-encrypting-and-decrypting-data-with-coldfusion-orm-and-annotations/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Adding ModelGlue&#8217;s event API to ColdFusion Builder&#8217;s code insight</title>
		<link>http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/</link>
		<comments>http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 16:54:23 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Development Environments]]></category>
		<category><![CDATA[Eclipse]]></category>
		<category><![CDATA[ModelGlue]]></category>

		<guid isPermaLink="false">http://www.tntechnohermit.com/?p=508</guid>
		<description><![CDATA[For the last year or so, all of my ColdFusion development projects have been built using the Model-Glue MVC framework. Over time, you get to where you know the most commonly used methods that are used to interact with the framework by heart. Sometimes there are lesser-used methods that you have to go look up. [...]]]></description>
			<content:encoded><![CDATA[<p>For the last year or so, all of my ColdFusion development projects have been built using the Model-Glue MVC framework. Over time, you get to where you know the most commonly used methods that are used to interact with the framework by heart. Sometimes there are lesser-used methods that you have to go look up. All the time (for me at least) I&#8217;m trying to find a way to write code faster and with less errors.</p>
<p>ColdFusion Builder has done a very nice job of providing code insight for ColdFusion tags, functions and CFC methods. This is especially true if you have a server configured in the &#8220;Servers&#8221; panel and mapped to your CF Builder project as it then will provide code insight for your own CFCs that you create on the page. However, when using Model-Glue, the &#8220;event&#8221; object is created for you and is always there. Because it&#8217;s not explicitly created on the page, CF Builder can&#8217;t provide code insight when you need to interact with it. However, it only takes a couple of settings in your project to make CF Builder aware of the event object and start providing help for it.</p>
<p>Here&#8217;s the process:</p>
<ol>
<li>Right click on your project and choosing &#8220;Properties&#8221;. </li>
<li>In the left pane of the window that comes up, click on &#8220;ColdFusion Variable Mappings&#8221;. </li>
<li>On the right side, click the &#8220;New&#8221; button and enter the following values into the boxes
<ul>
<li><strong>Variable Name:</strong> event</li>
<li><strong>Mapped To:</strong> html.ModelGlue.gesture.eventrequest.EventContext</li>
</ul>
</li>
<li>Press the &#8220;New&#8221; button and enter the following values into the boxes
<ul>
<li><strong>Variable Name:</strong> arguments.event</li>
<li><strong>Mapped To:</strong> html.ModelGlue.gesture.eventrequest.EventContext</li>
</ul>
</li>
<li>Press the Apply button then the OK button
</ul>
<p>* Note that the value in the &#8220;Mapped To&#8221; box is the actual dot-notated path to the EventContext.cfc file from your <strong>CF Builder project root</strong>. I happen to have my webroot files in a folder named &#8220;html&#8221; under the project root (see screenshot #1 below).</p>
<p>Once you have those settings saved, any time you type &#8220;event.&#8221; or &#8220;arguments.event.&#8221; you&#8217;ll get the list of methods contained in the Event object. Of course, this doesn&#8217;t only work with Model-Glue. Any CFC that you regularly use the same name with can be configured this same way.</p>
<p>I&#8217;ve attached some screenshots for reference. If you have any questions or something isn&#8217;t working, feel free to ping me.</p>

<a href='http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/cfbuilder-project-setup/' title='cfbuilder-project-setup'><img width="150" height="150" src="http://www.tntechnohermit.com/wp-content/uploads/2011/02/cfbuilder-project-setup-150x150.png" class="attachment-thumbnail" alt="Sample project setup" title="cfbuilder-project-setup" /></a>
<a href='http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/cfbuilder-variable-mappings/' title='cfbuilder-variable-mappings'><img width="150" height="150" src="http://www.tntechnohermit.com/wp-content/uploads/2011/02/cfbuilder-variable-mappings-150x150.png" class="attachment-thumbnail" alt="ColdFusion Builder Variable Mappings" title="cfbuilder-variable-mappings" /></a>
<a href='http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/cfbuilder-code-assist-view/' title='cfbuilder-code-assist-view'><img width="150" height="150" src="http://www.tntechnohermit.com/wp-content/uploads/2011/02/cfbuilder-code-assist-view-150x150.png" class="attachment-thumbnail" alt="cfbuilder-code-assist-view" title="cfbuilder-code-assist-view" /></a>
<a href='http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/cfbuilder-code-assist-controller/' title='cfbuilder-code-assist-controller'><img width="150" height="150" src="http://www.tntechnohermit.com/wp-content/uploads/2011/02/cfbuilder-code-assist-controller-150x150.png" class="attachment-thumbnail" alt="cfbuilder-code-assist-controller" title="cfbuilder-code-assist-controller" /></a>

]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2011/02/07/adding-modelglues-event-api-to-coldfusion-builders-code-insight/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Converting one company to CFML using an OSS CFML engine</title>
		<link>http://www.tntechnohermit.com/2010/12/03/oss-cfml-engine-success-story/</link>
		<comments>http://www.tntechnohermit.com/2010/12/03/oss-cfml-engine-success-story/#comments</comments>
		<pubDate>Fri, 03 Dec 2010 19:26:06 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>
		<category><![CDATA[Mach II]]></category>
		<category><![CDATA[Transfer ORM]]></category>

		<guid isPermaLink="false">http://www.tntechnohermit.com/?p=473</guid>
		<description><![CDATA[There have been some lively discussions on Twitter today centered around the adoption of open source CFML engines in various types of businesses. I can&#8217;t speak to any kind of trends anywhere, but I wanted to share my experience with a project I was involved in last year that used Railo as the CMFL engine. [...]]]></description>
			<content:encoded><![CDATA[<p>There have been some lively discussions on Twitter today centered around the adoption of open source CFML engines in various types of businesses. I can&#8217;t speak to any kind of trends anywhere, but I wanted to share my experience with a project I was involved in last year that used <a href="http://getrailo.org">Railo</a> as the CMFL engine.<br />
<span id="more-473"></span></p>
<p>My brother, <a href="http://twitter.com/andrewskaggs">Andrew</a>, is the head of the IT department for a firm that sells books and other supplies to school libraries all over the country. When he took over the position, he inherited a web site built on Java using the Struts framework.  The original site had been in place for quite some time and the ownership decided it was time to refresh the site. The main issue (besides the outdated design) with the site was that it was so difficult to update.  I&#8217;m not a Java developer by any stretch of the imagination, but from what I understand, even the simplest update required the site to be recompiled. The actual implementation of the site was fairly brittle as well, so new features were generally not even considered for fear of breaking something that was currently working. </p>
<p>Andrew had previously done some ColdFusion work with me on some of my other projects. He approached his management about contracting with me to help them replace their java web site with one built on CFML. During the initial requirements gathering and planning phases, the decision was made to use Railo as the CFML engine for the site.  The site was launched a few months after Railo released their first open source version which appealed to them as they have several systems within the company that are open source. Cost was not a major concern (Railo being free vs the cost of a standard license of <a href="http://www.adobe.com/coldfusion">Adobe ColdFusion</a>) but it was a consideration as this project did have a fixed budget. When we started the project, Adobe ColdFusion 8 was the most current release. Budgetary constraints probably a few more factors I wasn&#8217;t privy to led to the decision to use Railo as the CFML engine for the site.</p>
<p>Our experience developing with Railo was very positive. We built the site using <a href="http://www.mach-ii.com">Mach-II</a>, <a href="http://www.transfer-orm.com">Transfer</a>, <a href="http://coldspringframework.org">ColdSpring</a> using a <a href="http://www.postgresql.org">PostgreSQL</a> database backend. We had one little issue with Mach-II when we plugged in the Mach-II Dashboard module into our main config. <a href="http://blog.maestropublishing.com/">Peter Farrell</a> and I traced it down and found that it was due to a difference in how Railo parsed XML vs how Adobe ColdFusion did. I worked with the folks at Railo and they got the problem sorted out in one of the next releases.</p>
<p>The site went live the first of August, 2009.  Between January 1 and August 1 of 2010, the site experienced a 562% increase in revenue generated when compared to the same time period of 2009 (the YTD time frame leading up to the new site going live). They&#8217;ve also seen a dramatic increase in the amount of traffic to the site since the new version went live (although I don&#8217;t have exact percentages at my fingertips to share). Just as importantly, in the months sice the new site went live, they have been able to add dozens of new features to the site&#8211;both publicly-available features as well as features for administrators and sales people that just would have been too difficult to try to weave into the previous java struts based application.</p>
<p>Finally, while this &#8220;success story&#8221; has Railo as <em><strong>one</strong></em> of its key components, the bigger issue in my mind is the fact that a formerly java-centric shop has converted to using CFML successfully to run their business and provide a better experience for their customers and employees.</p>
<p>Disclaimer: I&#8217;m not on either side of the Railo/OpenBD/Adobe CF argument. I&#8217;ve not had a client since that project that&#8217;s given me the option to use Railo so all of my work since then has been in Adobe CF but I certainly wouldn&#8217;t dismiss Railo straight away if there were an option to use it on a future project.  The intent behind this blog post is simply to provide one real-world example of Railo being an entry point into CFML development, not to take either side of the Twitter discussions that have been going on today.</p>
<p>**Update: Corrected the incorrect timeline of when Adobe ColdFusion 8 came out and removed some inaccurate statements about speed of Railo vs the Adobe CF version out at the time (which was mistakenly stated to be MX7). Thank you Adam for pointing out the error. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/12/03/oss-cfml-engine-success-story/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Dynamically set ColdFusion ORM datasource</title>
		<link>http://www.tntechnohermit.com/2010/09/20/dynamically-set-coldfusion-orm-datasource/</link>
		<comments>http://www.tntechnohermit.com/2010/09/20/dynamically-set-coldfusion-orm-datasource/#comments</comments>
		<pubDate>Mon, 20 Sep 2010 16:46:59 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=423</guid>
		<description><![CDATA[I&#8217;m a relative novice using ColdFusion&#8217;s ORM features having done just one &#8220;real&#8221; project so far that took advantage of it. I&#8217;m working on an application that needs to be able to set the datasource for each request based on the URL that the customer is using to access the site. For example, if a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m a relative novice using ColdFusion&#8217;s ORM features having done just one &#8220;real&#8221; project so far that took advantage of it. I&#8217;m working on an application that needs to be able to set the datasource for each request based on the URL that the customer is using to access the site.  For example, if a customer visits http://customera.demoapp.com I need the application to use the DSN named &#8220;dsn-customera&#8221;, http://customerb.demoapp.com gets &#8220;dsn-customerb&#8221; and so on.</p>
<p>Normally this wouldn&#8217;t be an issue&#8211;you&#8217;d do some sort of logic in the onRequestStart() method in Application.cfc and set a request or session scoped variable to the name of the DSN and go from there.  However, when using ColdFusion&#8217;s ORM functions, this approach doesn&#8217;t work since &#8220;this.datasource&#8221; is configure in the pseudo-constructor at the top of Application.cfc like so:<br />
<span id="more-423"></span></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;myApp&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">datasource</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;dsn-myapp&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></td></tr></table></div>

<p>The first way that I thought of solving this was to set this.datasource=&#8221;demo&#8221; in the pseudo-constructor and then overwrite the value in the onRequestStart() method like so:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;myApp&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">datasource</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;dsn-myapp&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;onRequestStart&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> local.calculatedDSN <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>   
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!--- Logic to determine correct DSN name for current customer here ---&gt;</span>
&nbsp;
   <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">datasource</span> <span style="color: #0000FF;">=</span> local.calculatedDSN <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>This did in fact override the value in this.datasource as evidenced by dumping the &#8220;this&#8221; scope at the start and end of the onRequestStart() method.  However, CF&#8217;s ORM system always used the value set in the pseudo-constructor even though the this.datasource value was changed successfully. After scratching my head for a while, I posted a message to the <a href="http://groups.google.com/group/cf-orm-dev">cf-orm-dev Google group</a> with what I was trying to do and the results I was seeing.</p>
<p>Turns out, I was on the right track, I just had my logic in the wrong place.  After exchanging a few messages with <a href="http://www.briankotek.com">Brian Kotek</a>, <a href="http://www.ten24web.com">Sumit Verma</a>, and <a href="http://www.andyscott.id.au/ ">Andrew Scott</a>, I learned that CF&#8217;s ORM system is configured before any of the event handlers specified in Application.cfc are fired. </p>
<p>In the end, the answer to what I was needing to do was to put a call to a custom, private function in the pseudo-constructor to set up the customer-specific DSNs and then CF&#8217;s ORM system would be configured dynamically on each each request for the correct customer database. The only other gotcha is that you have to have a unique application name set up for each customer in order for things to be cached correctly.  Attempting to set this.datasource per request while using a single application name resulted in all requests using the datasource specified by the logic on the first request to the application.</p>
<p>The code ended up looking something similar to this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfcomponent</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!--- Application settings ---&gt;</span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> setupCustomerValues<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
    <span style="color: #808080; font-style: italic;">&lt;!--- Normal Application.cfc event handler methods ---&gt;</span>
&nbsp;
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;setupCustomerValues&quot;</span> output<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;private&quot;</span> </span>
<span style="color: #333333;">       returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> local.customerName <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
       <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> local.customerDSN <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
        <span style="color: #808080; font-style: italic;">&lt;!--- Logic to determine customer-specific values here ---&gt;</span>
&nbsp;
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;myapp-#local.customerName#&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
        <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> this.<span style="color: #0000FF;">datasource</span> <span style="color: #0000FF;">=</span> local.customerDSN <span style="color: #0000FF;">/&gt;</span></span>
        <span style="color: #808080; font-style: italic;">&lt;!--- more settings declarations ---&gt;</span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cffunction</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>This is obviously demo/proof-of-concept/blog-brevity type code so there are a couple of things to note:</p>
<ul>
<li>This method creates a separate ColdFusion application in memory for every client. If you have a large number of objects that are created and cached at application startup and a large number of customers hitting the same server, you could/will run into memory issues. In my case, this was less of a problem than having to deploy a completely separate code base for each customer using the application.</li>
<li>The demo code doesn&#8217;t take into account any kind of caching of the results of the customer-specific logic.  Obviously in a production application, you wouldn&#8217;t want to execute that logic on every request, but cache the result after the first execution for that customer (in my example, the first request to a particular subdomain)
</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/09/20/dynamically-set-coldfusion-orm-datasource/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Returning ColdFusion 9 ORM objects with JSON</title>
		<link>http://www.tntechnohermit.com/2010/07/19/returning-coldfusion-9-orm-objects-with-json/</link>
		<comments>http://www.tntechnohermit.com/2010/07/19/returning-coldfusion-9-orm-objects-with-json/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 16:26:26 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=413</guid>
		<description><![CDATA[Last week I was working on a client&#8217;s project that makes heavy use of ColdFusion 9&#8242;s ORM features. Everything we&#8217;d done with ORM up to that point had been going really well and I continue to be impressed by the amount of time ORM saves me in development. I had gotten to a point in [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I was working on a client&#8217;s project that makes heavy use of ColdFusion 9&#8242;s ORM features. Everything we&#8217;d done with ORM up to that point had been going really well and I continue to be impressed by the amount of time ORM saves me in development. I had gotten to a point in the project where I needed to be able to use AJAX calls from jQuery to manage some of the data in the database. Based on my experiences using a RemoteFacade.cfc to feed data to a Flex app, I thought it should be pretty easy. Several hours later, I realized that my particular use case for this was anything but easy.<br />
<span id="more-413"></span></p>
<p>What I eventually found was, when trying to load an object using an AJAX call to RemoteFacade.cfc, any object that had a property that was an array of other objects was not returned to Javascript. It wasn&#8217;t even that it was sent across as an empty property. The property absolutely didn&#8217;t exist in the JSON returned by the CFC. I used the ColdFusion debugger to verify that the array existing in the object immediately prior to the &lt;cfreturn&gt; statement and then examined the JSON return using Charles Proxy only to find out that those properties weren&#8217;t in the JSON.  All the normal string, numeric, date, etc type properties were returned just fine, but any properties composed of other objects were missing.</p>
<p>As near as I can tell, the culprit is the serializeJSON() method that ColdFusion uses to convert complex objects into JSON notation. It doesn&#8217;t seem to work correctly on ORM objects. To test my theory, I manually built a structure and inserted each simple property from the ORM object. I then created a key in the structure that was an array and manually populated several items in the array each with a structure of data. When I returned that from the CFC as JSON, the array and all the structures it contained came across the wire just fine.</p>
<p>I&#8217;m not sure if this is a bug in the serializeJSON() method or if serializeJSON() wasn&#8217;t meant to handle objects. Whatever the case, this issue leads to quite a bit of extra work if you need to return an object via JSON and include its properties that are composed of other objects. I&#8217;d definitely be interested in hearing from anyone who has successfully done this with ORM and AJAX to see if I&#8217;ve done something incorrectly in my code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/07/19/returning-coldfusion-9-orm-objects-with-json/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Building Advanced Workflows with ColdSpring at cf.Obective()</title>
		<link>http://www.tntechnohermit.com/2010/04/24/building-advanced-workflows-with-coldspring-at-cf-obective/</link>
		<comments>http://www.tntechnohermit.com/2010/04/24/building-advanced-workflows-with-coldspring-at-cf-obective/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 22:53:03 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[cf.Objective()]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=406</guid>
		<description><![CDATA[Thanks to all the folks that came to my Advanced Workflows with ColdSpring session today at cf.Objective(). The conference this year was outstanding and I&#8217;m honored to have been chosen to speak. If you&#8217;re interested in getting the slides and code, I&#8217;ve uploaded a zip file that includes everything I used in the session.]]></description>
			<content:encoded><![CDATA[<p>Thanks to all the folks that came to my Advanced Workflows with ColdSpring session today at cf.Objective(). The conference this year was outstanding and I&#8217;m honored to have been chosen to speak.  If you&#8217;re interested in getting the slides and code, I&#8217;ve uploaded a <a href='http://dan.skaggsfamily.ws/wp-content/uploads/2010/04/cfObjective-Building-Advanced-Workflows-with-ColdSpring.zip'>zip file</a> that includes everything I used in the session.</p>
<p><object height="425" width="550"><param name="movie" value="http://slidesix.com/viewer/SlideSixViewer.swf?alias=Building-Advanced-Workflows-with-ColdSpring" /><param name="menu" value="false"/><param name="scale" value="noScale"/><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always" /><param value="transparent" name="wmode" /><param value="quality" name="best" /><embed src="http://slidesix.com/viewer/SlideSixViewer.swf?alias=Building-Advanced-Workflows-with-ColdSpring" allowscriptaccess="always" allowFullScreen="true" height="425" width="550" type="application/x-shockwave-flash" wmode="transparent" quality="best" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/04/24/building-advanced-workflows-with-coldspring-at-cf-obective/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Embracing &#8220;New&#8221; in ColdFusion 9</title>
		<link>http://www.tntechnohermit.com/2010/04/16/embracing-new-in-coldfusion-9/</link>
		<comments>http://www.tntechnohermit.com/2010/04/16/embracing-new-in-coldfusion-9/#comments</comments>
		<pubDate>Fri, 16 Apr 2010 17:54:08 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=395</guid>
		<description><![CDATA[I&#8217;m not sure how I missed this before but among the long list of things added to ColdFusion 9 is the ability to create a CFC using the &#8220;New&#8221; syntax. Up until now, to create a new object from a CFC we&#8217;d use the createObject() method like so &#60;cfset Team = createObject&#40;&#34;component&#34;, &#34;model.Team&#34;&#41; /&#62; Now, [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not sure how I missed this before but among the long list of things added to ColdFusion 9 is the ability to create a CFC using the &#8220;New&#8221; syntax. Up until now, to create a new object from a CFC we&#8217;d use the createObject() method like so</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> Team <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">createObject</span><span style="color: #0000FF;">&#40;</span><span style="color: #009900;">&quot;component&quot;</span>, <span style="color: #009900;">&quot;model.Team&quot;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>Now, using the New keyword, we can shorten that to</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> Team <span style="color: #0000FF;">=</span> New model.Team<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p><strong>But wait, there&#8217;s more! </strong><br />
When you use the New keyword, ColdFusion will automatically look for and run any init() method that exists in the CFC. It also respects any arguments that your init() method specifies, meaning that if you have a Team.init() method that can accept team name, color and manager arguments, you can build them right into your the same line of code used to create your object like so</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> Team <span style="color: #0000FF;">=</span> New model.Team<span style="color: #0000FF;">&#40;</span> <span style="color: #009900;">&quot;Bumblebees&quot;</span>, <span style="color: #009900;">&quot;Yellow&quot;</span>, <span style="color: #009900;">&quot;Benny Bee&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>Likewise, as you&#8217;d expect, named arguments are still supported. So if you had to send in arguments out of order or needed to omit some optional arguments at object creation, you could do</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> Team <span style="color: #0000FF;">=</span> New model.Team<span style="color: #0000FF;">&#40;</span></span>
<span style="color: #333333;">              manager<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Benny Bee&quot;</span>,</span>
<span style="color: #333333;">              <span style="color: #0000FF;">color</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Yellow&quot;</span>,</span>
<span style="color: #333333;">              <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Bumblebees&quot;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>I personally am going to make a point to start using this in my code because I can never seem to spell the word &#8220;component&#8221; correctly in the createObject() method.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/04/16/embracing-new-in-coldfusion-9/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>My ColdFusion Anniversary</title>
		<link>http://www.tntechnohermit.com/2010/03/18/my-coldfusion-anniversary/</link>
		<comments>http://www.tntechnohermit.com/2010/03/18/my-coldfusion-anniversary/#comments</comments>
		<pubDate>Thu, 18 Mar 2010 12:41:33 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=383</guid>
		<description><![CDATA[Well, not quite yet, but since I&#8217;m going to be out of pocket the next several days, I wanted to put this out now. Monday, March 22 will mark 10 years since I began my &#8220;journey&#8221; with ColdFusion. That day in 2000 was my first day in a class called &#8220;Fast Track to ColdFusion&#8221;. The [...]]]></description>
			<content:encoded><![CDATA[<p>Well, not quite yet, but since I&#8217;m going to be out of pocket the next several days, I wanted to put this out now.  Monday, March 22 will mark 10 years since I began my &#8220;journey&#8221; with ColdFusion.  That day in 2000 was my first day in a class called &#8220;Fast Track to ColdFusion&#8221;. </p>
<p>The class was taught by <a href="http://www.linkedin.com/in/seanhedenskog" target="_blank">Sean Hedenskog</a> in San Jose, CA where the headquarters for the company I was working for at the time was located.  That company had decided on Allaire Spectra 1.0 as the basis for an enterprise content management system so several of us went through the Fast Track to ColdFusion course in preparation for Spectra training some weeks later.<br />
<span id="more-383"></span></p>
<p>I know there are are a lot of people out there who have more time with ColdFusion than I do. I started with version 4.5 and, if memory serves, our company was one of the first to deploy ColdFusion and Spectra onto Solaris-based servers. Even so, I feel like I&#8217;m somewhat of an old-timer these days. That&#8217;s a good thing however, since it means we&#8217;re getting more and more new people using ColdFusion.</p>
<p>A lot has changed in the 10 years since I started that class. Coming from a strictly HTML background with a little bit of classic ASP thrown in, even the beginner class posed quite a challenge for me. Simple things we don&#8217;t give second thoughts to such as calling a custom tag (there were no UDFs or CFCs then remember) were hard for me to get my head around. I remember having an especially difficult time trying to figure out how arrays and structures worked</p>
<p>Along the way I&#8217;ve been privileged to associate with some very talented and helpful folks. Not long after we started the Spectra project, my company brought in some folks from the Allaire consulting group. <a href="http://www.linkedin.com/in/mattstevanus" target="_blank">Matt Stevanus</a> was one of those folks and quickly became a great friend and mentor. We kept in touch periodically after that project was over and a little over 3 years ago I got the opportunity to work with Matt again when I started consulting with <a href="http://www.universalmind.com" target="_blank">Universal Mind</a>.</p>
<p>A couple years ago I met another guy who would help shape my professional career&#8211;<a href="http://www.nodans.com" target="_blank">Dan Wilson</a>. Dan is widely known these days as a driving force behind the <a href="http://www.model-glue.com" target="_blank">ModelGlue</a> project. Dan and I had an opportunity to work on a long-term project together and he and I&#8217;ve enjoyed working with him on various things ever since. It was Dan that really got me over the &#8220;OO hump&#8221;, convinced me that I needed to start blogging more and to submit topics to various conferences to speak on. </p>
<p>Finally, there are dozens of people out in the ColdFusion community doing blog posts, open source projects, MeetUps and more that have contributed to my success. To everyone, I say a hearty &#8220;THANKS!&#8221; (and my mortgage company loves you too).</p>
<p>So, here&#8217;s looking back at a great 10 years while looking forward to many more ahead!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/03/18/my-coldfusion-anniversary/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Be careful with the &#8216;local&#8217; scope when migrating from CF8 to CF9</title>
		<link>http://www.tntechnohermit.com/2010/02/08/be-careful-with-the-local-scope-when-migrating-from-cf8-to-cf9/</link>
		<comments>http://www.tntechnohermit.com/2010/02/08/be-careful-with-the-local-scope-when-migrating-from-cf8-to-cf9/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 14:24:15 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Javascript]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=355</guid>
		<description><![CDATA[One of the really nice &#8220;fixes&#8221; included in ColdFusion 9 from a developer&#8217;s perspective is the inclusion of an implicit &#8220;local&#8221; variable scope into which variables created within the body of a &#60;cffunction&#62; tag are placed by default. Previously, developers had to manually add a &#8220;var&#8221; keyword to variables that should only exist within the [...]]]></description>
			<content:encoded><![CDATA[<p>One of the really nice &#8220;fixes&#8221; included in ColdFusion 9 from a developer&#8217;s perspective is the inclusion of an implicit &#8220;local&#8221; variable scope into which variables created within the body of a &lt;cffunction&gt; tag are placed by default. Previously, developers had to manually add a &#8220;var&#8221; keyword to variables that should only exist within the confines of the function.</p>
<p>One of the ways of simplifying this that gained some traction among various developers prior to the release of ColdFusion 9 was to &#8220;var&#8221; a single variable at the top of the function as an empty structure then store any additional variables needed in the function inside it. Many folks, myself included, named this structure &#8220;local&#8221; so that it would be readily apparent that the values inside were local to that function. This approach worked fine and dandy on ColdFusion 8 and below.<br />
<span id="more-355"></span></p>
<p>I recently migrated one of my clients to ColdFusion 9 and not long after the client started getting isolated reports from his people having javascript errors in a data management application that uses AJAX-driven forms talking to CFCs.  At first these were very isolated and we weren&#8217;t able to reproduce the error, but, as time went on, the reports became more widespread. As I was troubleshooting this over the weekend, I discovered that we were getting javascript errors when trying to interact with this RemoteFacade CFC about 40% of the time.</p>
<p>Using <a href="http://www.getfirebug.com" target="_blank">Firebug</a>, I was able to watch the results come back from ColdFusion and noticed a very odd trend. Approximately 60% of the time, the JSON returned from the remote CFC call was as expected. In the other 40%, one of the main data structure names was an arbitrary, machine-generated name instead of the name we had specified in the code.</p>
<p>Here is an example of what we were expecting in the JSON returned from the RemoteFacade.cfc method:</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">{&quot;DATA&quot;:{&quot;CANEDIT&quot;:true,&quot;RECORDDATA&quot;:{&quot;Field1&quot;:&quot;value1&quot;} } }</pre></div></div>

<p>This is an example of what we would get back from the same request when we would see the javascript errors</p>

<div class="wp_syntax"><div class="code"><pre class="json" style="font-family:monospace;">{&quot;___IMPLICITARRYSTRUCTVAR5&quot;:{&quot;CANEDIT&quot;:true,&quot;RECORDDATA&quot;:{&quot;Field1&quot;:&quot;value1&quot;} } }</pre></div></div>

<p>See the difference?  Our &#8220;DATA&#8221; key was named completely differently which caused javascript to throw some error saying that variableName.DATA did not exist.</p>
<p>After looking over the ColdFusion code for quite a while and doing some step debugging with <a href="http://www.fusion-debug.com" target="_blank">FusionDebug</a> I had an idea.  I changed all the function-specific structures I had been using from:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> local <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">structNew</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
   ....
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfreturn</span> local <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>to:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> <span style="color: #000000; font-weight: bold;">var</span> ret <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">structNew</span><span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
   ....
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfreturn</span> ret <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>Once I changed those throughout the code base and reinitialized my application, all the javascript errors that we&#8217;d been experiencing across multiple request types went completely away.</p>
<p>I have an unconfirmed theory that in using the name &#8220;local&#8221; for my structure, ColdFusion was sometimes getting &#8220;confused&#8221; on what to return&#8211;ColdFusion&#8217;s built-in local scope or the method-specific variable I had named local. I don&#8217;t really have any way to prove that beyond a shadow of a doubt, but when I made the change, all my errors went away, so I decided chalk it up as a lesson learned for future development and move on to the next problem.  Needless to say the client was happy that the issue was fixed and I can say I learned something that day.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/02/08/be-careful-with-the-local-scope-when-migrating-from-cf8-to-cf9/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>ColdFusion 9 caching settings to watch out for</title>
		<link>http://www.tntechnohermit.com/2010/01/31/coldfusion-9-caching-settings-to-watch-out-for/</link>
		<comments>http://www.tntechnohermit.com/2010/01/31/coldfusion-9-caching-settings-to-watch-out-for/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 15:14:09 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ModelGlue]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=340</guid>
		<description><![CDATA[Like a lot of developers, I&#8217;ve got this pet project I&#8217;m working on in whatever spare time I can find between client engagements, home maintenance, family obligations, etc. I&#8217;m using it as an opportunity to work with some of the new features of ColdFusion 9 (ORM mainly), ColdFusion Builder Beta and features in development for [...]]]></description>
			<content:encoded><![CDATA[<p>Like a lot of developers, I&#8217;ve got this pet project I&#8217;m working on in whatever spare time I can find between client engagements, home maintenance, family obligations, etc.  I&#8217;m using it as an opportunity to work with some of the new features of ColdFusion 9 (ORM mainly), ColdFusion Builder Beta and features in development for the next release of <a href="http://www.model-glue.com" target="_blank">ModelGlue 3</a>.</p>
<p>Recently, <a href="http://www.silverwareconsulting.com/" target="_blank">Bob Silverburg</a> has been working on a significant overhaul of the scaffolding feature used by ModelGlue to automatically create CRUD forms for the various data objects in your application. Particularly exciting to me is that you can now override the built-in code templates with your own. Bob wrote a proof-of-concept application that uses the excellent <a href="http://cfuniform.riaforge.org/" target="_blank">cfUniform</a> custom tag library to build standardized forms and validations (see my <a href="http://www.tntechnohermit.com/2009/04/29/standardizing-html-forms-with-the-cfuniform-custom-tag-library/">previous post</a> on cfUniform if you&#8217;re not familiar with it). Since I&#8217;m pretty particular about how my project files are arranged, I proceeded to place the css, javascript and image assets into the folders where I wanted them and use ColdSpring to create a configuration bean to pass to cfUniform when I called it. That&#8217;s where the trouble began.</p>
<p>I had to make a couple of changes to the code generated in the custom scaffold CFC in order to have cfUniform see the custom configuration that I had set up. No matter what I did, when the scaffolding engine generated the code for the view and the XML fragment for the event-handler, the changes I made inside the CFC weren&#8217;t included. I spent a couple hours scratching my head, tracing the request cycle, restarting my local ColdFusion instance and always got the exact same code that was in Bob&#8217;s original example CFC. Finally, I decided to change the name of the CFC and update the associated bean configuration in ColdSpring. On the next refresh, I saw my changes reflected in the code generated by the scaffold!</p>
<p>With that in mind, I checked the settings on the Caching page of that instance&#8217;s CF Administrator. Sure enough, the Cache Template In Request,  Component cache, and Save class files options were checked.  I cleared those check boxes, pressed the Clear Template Cache Now and Clear Component Cache Now buttons below and have had no trouble since. Obviously there are situations where you want these enabled, but rarely ever should they be needed on a local system being used for development.</p>
<p>So, the moral of my painful story&#8211;if you&#8217;re making changes to code that&#8217;s not being reflected when you test browse your application, don&#8217;t forget to check the settings on the Caching page in CF Admin. It just might save you a couple hours and a few gray hairs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.tntechnohermit.com/2010/01/31/coldfusion-9-caching-settings-to-watch-out-for/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

