<?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>existdissolve.com &#187; ColdFusion</title>
	<atom:link href="http://existdissolve.com/category/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://existdissolve.com</link>
	<description>the singularity of being and nothingness</description>
	<lastBuildDate>Wed, 16 May 2012 12:54:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Gloss Updated with ColdFusion 10 Documentation</title>
		<link>http://existdissolve.com/2012/05/gloss-updated-with-coldfusion-10-documentation/</link>
		<comments>http://existdissolve.com/2012/05/gloss-updated-with-coldfusion-10-documentation/#comments</comments>
		<pubDate>Wed, 16 May 2012 12:54:03 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion 10]]></category>
		<category><![CDATA[Gloss]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2413</guid>
		<description><![CDATA[On the heels of yesterdays&#8217;s official release of ColdFusion 10, I&#8217;ve updated Gloss with support for both ColdFusion 10 AND ColdFusion 9 reference guides. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>On the heels of <a href="http://blogs.coldfusion.com/post.cfm/adobe-coldfusion-10-is-now-available">yesterdays&#8217;s official release of ColdFusion 10</a>, I&#8217;ve updated <a href="http://cfgloss.com/">Gloss</a> with support for both ColdFusion 10 AND ColdFusion 9 reference guides.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/05/gloss-updated-with-coldfusion-10-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Bug? EntityToQuery() and Unknown Data Type</title>
		<link>http://existdissolve.com/2012/05/coldfusion-bug-entitytoquery-and-unknown-data-type/</link>
		<comments>http://existdissolve.com/2012/05/coldfusion-bug-entitytoquery-and-unknown-data-type/#comments</comments>
		<pubDate>Thu, 03 May 2012 04:10:37 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Bug]]></category>
		<category><![CDATA[EntityToQuery]]></category>
		<category><![CDATA[ORM]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2408</guid>
		<description><![CDATA[I ran into an interesting issue today. To make a long story a little less uninteresting, I was basically trying to go from an array of ORM entities to an Excel dump of the data in those entities. Obviously, the easiest way to accomplish this is to first convert the array of entities to a&#8230;]]></description>
			<content:encoded><![CDATA[<p>I ran into an interesting issue today. To make a long story a little less uninteresting, I was basically trying to go from an array of ORM entities to an Excel dump of the data in those entities. Obviously, the easiest way to accomplish this is to first convert the array of entities to a query, and then pass the query result set off to the built-in CF Excel manipulation functions.</p>
<p>Easy enough. With one little line of code, you can very simply convert ORM entities to a ColdFusion query&#8230;just like so:</p>
<pre>// get the orm entities
ormstuff = <strong>EntityLoad</strong>( "Art" );
// convert the orm goodness to a CF query
anicequery = <strong>EntityToQuery</strong>( ormstuff );</pre>
<p>Cake, right? If I were to hand this query off to CF&#8217;s spreadsheet functions, I could easily prepare and export a nice Excel file full of the data I just converted. But of course, nothing is that simple&#8230;and that&#8217;s where the potential bug announced itself.</p>
<h2>A Dark Foreboding</h2>
<p>You see, instead of simply dumping all the data for all the columns of the query-which-was-once-an-entity, I wanted to pare down the list of columns that would be output in the Excel export. Since I already had a query handy, I figured passing a list of column names to a Query-of-Queries would make short work of this. However, the moment I tried this&#8230;</p>
<p><strong>BOOM!</strong></p>
<p>I received the following error:</p>
<blockquote><p>Query Of Queries runtime error. Unsupported SQL type java.sql.Types.UNKNOWN</p></blockquote>
<h2>The Weirdness Begins</h2>
<p>So what happened? Turns out that one of my columns (a BIT column on the database) was being converted to an &#8220;UNKNOWN&#8221; data type in the query result. You can see this easily by viewing the metadata of the query object (notice the &#8220;ISSOLD&#8221; column):</p>
<pre>writedump( <strong>getMetaData</strong>( anicequery ) );</pre>
<p><a href="http://existdissolve.com/wp-content/uploads/2012/05/dump.png"><img class="alignleft size-full wp-image-2409" title="dump" src="http://existdissolve.com/wp-content/uploads/2012/05/dump.png" alt="" width="164" height="296" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>The Weirdness Grows</h2>
<p>As strange as this is, it gets weirder.</p>
<ul>
<li>If I do a non-entity query of the database and the dump the result, the data type for &#8220;ISSOLD&#8221; is not UNKNOWN, but the correct data type.</li>
<li>If I pass a &#8220;*&#8221; in the Q-of-Q instead of a list containing the offending column&#8217;s name, no error occurs</li>
<li>CAST() the column, you say? Yep, tried that. No dice.</li>
<li>Changing the &#8220;type&#8221; and &#8220;ormtype&#8221; attributes of the BIT column&#8217;s properties in the ORM mapping don&#8217;t help. I tried a number of combinations, but could not get the &#8220;TypeName&#8221; to ever NOT be &#8220;UNKNOWN&#8221;</li>
<ul>
<li>Ok, that&#8217;s not 100% true. if I leave those attributes off, the TypeName is set to &#8220;JAVA_OBJECT&#8221;, and the QofQ is able to execute without error. Of course, <em><strong>this is only for MySQL</strong></em>&#8230;in SQL Server, I couldn&#8217;t get it to change, even with the same settings as what &#8220;worked&#8221; for MySQL. Ugh.</li>
</ul>
</ul>
<h2>The Weirdness Ends</h2>
<p>After several unfruitful experiments and dozens of minutes Googling to no avail, I put an end to the madness by simply writing my own version of <strong>EntitytoQuery()</strong>. It&#8217;s ugly and still a work in progress, but it at least by-passes the issue I encountered.</p>
<blockquote><p>If you&#8217;re interested in seeing this issue in action, check out the demo pages I put up (each page has a dump of the code for the entities):</p>
<ul>
<li><a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/orm/sqlorm/">SQL Server 2008</a></li>
<li><a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/orm/mysqldump.cfm">MySQL</a></li>
</ul>
<p><span style="line-height: 20px;">I&#8217;ve also <a href="https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3180344">submitted a bug for this</a>, so if you think it&#8217;s crazy, feel free to vote!</span></p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/05/coldfusion-bug-entitytoquery-and-unknown-data-type/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Bug: SerializeJSON() and ORM Entities</title>
		<link>http://existdissolve.com/2012/04/coldfusion-bug-serializejson-and-orm-entities/</link>
		<comments>http://existdissolve.com/2012/04/coldfusion-bug-serializejson-and-orm-entities/#comments</comments>
		<pubDate>Thu, 26 Apr 2012 13:13:57 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Dump]]></category>
		<category><![CDATA[SerializeJSON]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2405</guid>
		<description><![CDATA[Recently, I&#8217;ve been messing around quite a bit with ORM in ColdFusion. I really like the benefits that it brings to developing applications. However, I noticed a very big bug yesterday while attempting to user serializeJSON() on a an entity using a one-to-many relationship. Some Context Let&#8217;s say that you have two entities that are related&#8230;]]></description>
			<content:encoded><![CDATA[<p>Recently, I&#8217;ve been messing around quite a bit with ORM in ColdFusion. I really like the benefits that it brings to developing applications. However, I noticed a very big bug yesterday while attempting to user serializeJSON() on a an entity using a one-to-many relationship.</p>
<h2>Some Context</h2>
<p>Let&#8217;s say that you have two entities that are related via a one-to-many relationship (Artists and Art, for example). You can easily create this relationship in your model by doing something like the following:</p>
<pre>property name="art" fieldtype="one-to-many" fkcolumn="artistid" cfc="Art" remotingfetch="true";</pre>
<p>If we were to dump the result of an EntityLoad() of &#8220;Artists&#8221;, we&#8217;d see a nice structured relationship: First, an array of all Artist entities, and then an array of all Art entities related to the particular ArtistID. Additionally, I&#8217;ve specified remotingfetch=true, which will force CF to load the Art entities for each Artist.</p>
<h2>The Bug</h2>
<p>The bug, however, comes into play when you try to serialize the result of EntityLoad(). While it properly composes the relationships, it represents the first two entities in the &#8220;art&#8221; array; any subsequent entities in the given array are returned simply as &#8220;{}&#8221;.  Whether you have 3 &#8220;Art&#8221; entities for an artists, or 20, only the first 2 will ever be serialized properly.</p>
<blockquote><p>See this happening in CF10:</p>
<ul>
<li>Regular, correct composition of entities via straight CFDUMP &#8211; <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/orm/dump.cfm">LINK</a></li>
<li>&#8220;First two&#8221; problem via dump of serializeJSON() &#8211; <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/orm/">LINK</a></li>
</ul>
</blockquote>
<h2>It Gets Worse</h2>
<p>The worst part about this is that it is a relatively old bug. It was <a href="https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3042650">first submitted </a>for CF9 back in October 2010, was deferred, and was <a href="https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3175667">apparently not fixed</a> for the public beta of CF10.</p>
<p>I think this is a huge issue, and should be a priority to be fixed. Until it is (or a suitable workaround is devised), it will be incredibly difficult to create applications of any complexity that depend upon serialization of entities.</p>
<h2>Vote, Vote, Vote</h2>
<p>The best way to get it fixed, of course, is to make your voice heard and vote up the bug. Here are some links for that:</p>
<p><strong>Bug Report &#8211; CF 9: </strong>https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3042650</p>
<p><strong>Bug Report &#8211; CF 10:</strong> https://bugbase.adobe.com/index.cfm?event=bug&amp;id=3175667</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/04/coldfusion-bug-serializejson-and-orm-entities/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion 10 Beta Examples are Live</title>
		<link>http://existdissolve.com/2012/02/coldfusion-10-beta-examples-are-live/</link>
		<comments>http://existdissolve.com/2012/02/coldfusion-10-beta-examples-are-live/#comments</comments>
		<pubDate>Sat, 25 Feb 2012 13:26:18 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion 10 Beta]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2383</guid>
		<description><![CDATA[I recently created a free ColdFusion 10 Beta hosting account with Hostek.com. It&#8217;s pretty awesome, so you should create one too! Anyway, with that in place, I&#8217;ve uploaded my examples of ArrayEach(), StructEach(), and ArrayFilter(). I&#8217;ve also put them out on GitHub, so feel free to take a look if it suits you. Enjoy!]]></description>
			<content:encoded><![CDATA[<p>I recently created a <strong><a href="https://cp.hostek.com/cart.php?a=confproduct&amp;i=0">free ColdFusion 10 Beta hosting account</a></strong> with Hostek.com. It&#8217;s pretty awesome, so you should create one too!</p>
<p>Anyway, with that in place, I&#8217;ve uploaded my examples of <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/each/array.cfm">ArrayEach()</a>, <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/each/struct.cfm">StructEach()</a>, and <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/filter/">ArrayFilter().</a> I&#8217;ve also <a href="https://github.com/existdissolve/CF10">put them out on GitHub</a>, so feel free to take a look if it suits you.</p>
<p>Enjoy!</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/02/coldfusion-10-beta-examples-are-live/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ColdFusion 10: Filter Functions</title>
		<link>http://existdissolve.com/2012/02/coldfusion-10-filter-functions/</link>
		<comments>http://existdissolve.com/2012/02/coldfusion-10-filter-functions/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 04:14:51 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[ArrayFilter]]></category>
		<category><![CDATA[ListFilter()]]></category>
		<category><![CDATA[StructFilter()]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2376</guid>
		<description><![CDATA[In the vein of my last post on ColdFusion 10&#8242;s new ArrayEach() and StructEach() functions, there are some other related functions that help with the very common task of filtering arrays, structs, and list. The new functions are ArrayFilter(), ListFilter(), and StructFilter(). Like ArrayEach() and StructEach(), the new filter methods have a &#8220;function&#8221; parameter (which&#8230;]]></description>
			<content:encoded><![CDATA[<p>In the vein of my <a title="ColdFusion 10: ArrayEach and StructEach, Hooray!" href="http://existdissolve.com/2012/02/coldfusion-10-arrayeach-and-structeach-hooray/">last post on ColdFusion 10&#8242;s new <strong>ArrayEach()</strong> and <strong>StructEach()</strong> functions,</a> there are some other related functions that help with the very common task of filtering arrays, structs, and list. The new functions are <strong>ArrayFilter()</strong>, <strong>ListFilter()</strong>, and <strong>StructFilter()</strong>.</p>
<p>Like <strong>ArrayEach()</strong> and <strong>StructEach()</strong>, the new filter methods have a &#8220;function&#8221; parameter (which can also be either an inline function or a named function). However, unlike <strong>ArrayEach()</strong> and <strong>StructEach()</strong> which return nothing, the new filter functions return a <strong>new</strong> array, list, or struct, respectively.</p>
<p>To accomplish this, you need to return a boolean from the function parameter. If the current array element, list item, or structure value matches some criteria and returns &#8220;true&#8221;, it will be added to the new returned array/list/structure. Conversely, if it fails the criteria and returns &#8220;false,&#8221; it will be excluded from what is returned.</p>
<blockquote><p><strong>NOTE:</strong>  The array/list/struct filter() functions return <strong>NEW</strong> arrays/lists/structures. The original arrays/lists/structs against which the filter() functions are called are unaffected.</p></blockquote>
<h2>An Example</h2>
<p>Let&#8217;s say that we have a simple set of &#8220;circles&#8221; for a <a title="Add Me :)" href="https://plus.google.com/u/0/104753668904759400057" target="_blank">Google+ account</a> which includes a circle for friends, one for co-workers, and another for family. We might model this data like so:</p>
<pre>'circles' = {
    'friends': ['Lucas','Phil','Dave','Brian','Dillon'],
    'coworkers': ['Tyler','Mike','Doug'],
    'family': ['Dean','Jared','Jason']
};</pre>
<p>Now, let&#8217;s imagine that for some reason, we want to filter all of the people in our circles, and return all the contacts (regardless of circle) whose names start with the letter &#8220;D&#8221;.  One approach might be as so:</p>
<pre>// create an array to hold all the names
allDnames = [];
// use structeach() to evaluate each "circle" 
structeach(circles,function(key,value) {
     // "matched" names will be the new array returned from the arrayfilter()
     // which is applied to each circle in the structeach() loop
     matchednames = <strong>arrayfilter</strong>(value,function(obj) {
         // if the first letter is a "D", return true; otherwise, return false;
         return left(obj,1)=='D';
     });
     // now let's add each filtered name to our master array of "D" names 
     arrayeach(matchednames,function(obj) {
          arrayappend(allDnames,obj);
     });
});</pre>
<blockquote><p><strong>See the <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/filter/">live example</a> or grab the code from <a href="https://github.com/existdissolve/CF10/tree/master/filter">GitHub</a></strong></p></blockquote>
<h2>Wrapping Up</h2>
<p>As you can see, using CF10&#8242;s new <strong>ArrayFilter()</strong> function is pretty simple, and the <strong>ListFilter()</strong> and <strong>StructFilter()</strong> functions work exactly the same, just with slightly different parameters and return types.</p>
<p>But perhaps more importantly, this example shows how functions like <strong>StructEach()</strong> and <strong>ArrayFilter()</strong> can make processing of complex data structures a snap. Instead of bothering with messy for-loops in which it would be incredibly easy to lose our place, this approach feels much more sane and easy to follow.</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/02/coldfusion-10-filter-functions/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>ColdFusion 10: ArrayEach and StructEach, Hooray!</title>
		<link>http://existdissolve.com/2012/02/coldfusion-10-arrayeach-and-structeach-hooray/</link>
		<comments>http://existdissolve.com/2012/02/coldfusion-10-arrayeach-and-structeach-hooray/#comments</comments>
		<pubDate>Mon, 20 Feb 2012 02:58:36 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[ArrayEach]]></category>
		<category><![CDATA[StructEach]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2373</guid>
		<description><![CDATA[Earlier today, I was looking through the &#8220;New Functions in ColdFusion 10&#8221; doc, and noticed a few gems: ArrayEach() and StructEach(). These are huge, because until now, there has been something of a disconnect between dealing with arrays and structures in CF, and their counterparts in other languages, like JavaScript. All JS libraries (like ExtJS)&#8230;]]></description>
			<content:encoded><![CDATA[<p>Earlier today, I was looking through the &#8220;<a href="http://help.adobe.com/en_US/ColdFusion/10.0/CFMLRef/WS890819DC-DE4D-4b24-A237-6E3483E9D6A1.html">New Functions in ColdFusion 10</a>&#8221; doc, and noticed a few gems: <strong>ArrayEach()</strong> and <strong>StructEach()</strong>. These are huge, because until now, there has been something of a disconnect between dealing with arrays and structures in CF, and their counterparts in other languages, like JavaScript. All JS libraries (<a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext-method-each">like ExtJS</a>) have &#8220;each&#8221; methods attached to basic objects which allows you to treat collections of the same kind of thing in a bulk way. Fortunately, CF10 introduces two very handy new methods to apply an &#8220;each&#8221;-like process to both arrays and structures.</p>
<blockquote><p><strong>NOTE</strong>: The ArrayEach() and StructEach() functions act on the original array/struct. Therefore, if you make changes to the array/struct within these functions (as in the ArrayEach() example below), the original array/struct will be affected (thanks Andy!).</p></blockquote>
<h2>ArrayEach()</h2>
<p>So, for example, let&#8217;s say you have an array of friends&#8217; names, and you want to make the list all uppercase. Pre-CF10, you might approach this by looping over the array, and executing a function at each iteration. Fine, easy enough, and it works. However, with <strong>ArrayEach()</strong>, you can ditch the clunkiness of the for-loop, and keep everything self-contained to the array. And, you can execute either an &#8220;inline&#8221; function, or call a named function. The two examples (which produce the same results) are below:</p>
<pre>names = ['John','mary','JOseph','Glenda','Mike'];

// named function
// notice that the function takes one argument, the value of the current iteration of the array
function makeLowercase(obj) {
    names[arrayfind(names,obj)] = lcase(obj);
}

<strong>//  run arrayeach() with an inline function</strong>
arrayeach(names,function(obj) {
    names[arrayfind(names,obj)] = lcase(obj);
});
writedump(names);

<strong>// run arrayeach() with a named function</strong>
arrayeach(myarray,makeLowercase);
writedump(myarray);</pre>
<blockquote><p><strong>See the <a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/each/array.cfm">live example</a> or grab the code from <a href="https://github.com/existdissolve/CF10/blob/master/each/array.cfm">GitHub</a></strong></p></blockquote>
<h2>StructEach()</h2>
<p>Not to be outdone, structures get some each() lovin&#8217; in CF10 as well. But instead of iterating over an array, the <strong>StructEach()</strong> function executes for every key-value pair in the structure. As with ArrayEach(), you can use either use an inline function or a named function.</p>
<p>In this example, we have a simple collection of &#8220;favorites,&#8221; which we want to print to the screen.</p>
<pre>favs = {color: 'blue', food: 'pizza', sport: 'basketball'};

// named function
// notice that the function takes two arguments, the key and value pair of the current iteration of the structure's key-value pairs
function getFavorites(key, value) {
    writeoutput('My favorite ' &amp; key &amp; ' is ' &amp; value);
} 
<strong>// run structeach() with a named function</strong>
structeach(favs,getFavorites);
<strong>// run structeach() with an inline function</strong>
structeach(favs, function(key,value) { 
    writeoutput('My favorite ' &amp; key &amp; ' is ' &amp; value);
});</pre>
<blockquote><p><strong>See the<a href="http://existdissolve-cf10beta.securecb1cf10.ezhostingserver.com/each/struct.cfm"> live example</a> or grab the code from <a href="https://github.com/existdissolve/CF10/blob/master/each/struct.cfm">GitHub</a></strong></p></blockquote>
<h2>Wrapping Up</h2>
<p>While these two functions probably won&#8217;t garner the attention that other additions will, I think they&#8217;re pretty dang awesome. Not only are they a long time coming (honestly, how often do you loop over an array&#8230;like 20 times every hour!!), but they help to make developing with these basic data types just a bit easier as they more closely align methodologies in CF with those you&#8217;d find elsewhere.</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/02/coldfusion-10-arrayeach-and-structeach-hooray/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Grouping in CFLoop&#8230;Finally!</title>
		<link>http://existdissolve.com/2012/02/grouping-in-cfloop-finally/</link>
		<comments>http://existdissolve.com/2012/02/grouping-in-cfloop-finally/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 18:06:45 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Cool Stuff]]></category>
		<category><![CDATA[CFLoop]]></category>
		<category><![CDATA[ColdFusion 10]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2368</guid>
		<description><![CDATA[With the public release of ColdFusion 10 Beta yesterday, I thought I&#8217;d play around a bit with some of the new capabilities. One of the features added in this release is the ability to group in query loops using &#60;cfloop&#62;. As expected, this is pretty straightforward, and has the same capabilities as the &#60;cfoutput&#62; corollary. Here&#8217;s&#8230;]]></description>
			<content:encoded><![CDATA[<p>With the public release of <strong><a href="http://labs.adobe.com/technologies/coldfusion10/">ColdFusion 10 Beta</a></strong> yesterday, I thought I&#8217;d play around a bit with some of the new capabilities. One of the features added in this release is the ability to <strong>group</strong> in query loops using &lt;cfloop&gt;.</p>
<p>As expected, this is pretty straightforward, and has the same capabilities as the &lt;cfoutput&gt; corollary. Here&#8217;s a quick example:</p>
<pre>&lt;cfquery name="qproducts" datasource="somedatasource"&gt;
     select *
     from   products
     order by category,subcategory,product
&lt;/cfquery&gt;

&lt;cfoutput&gt;
     &lt;cfloop query="qproducts" group="category"&gt;
          &lt;h1&gt;#category#&lt;/h1&gt;
          &lt;cfloop group="subcategory" groupcasesensitive="true" &gt;
               &lt;h2&gt;#subcategory#&lt;/h2&gt;
               &lt;cfloop&gt;
                    #product#&lt;br /&gt;
              &lt;/cfloop&gt;
          &lt;/cfloop&gt;
     &lt;/cfloop&gt;
&lt;/cfoutput&gt;</pre>
<p>Pretty simple, but something which I know a lot of people have wanted for quite a while. Well, now you have it!</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/02/grouping-in-cfloop-finally/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Queries to ExtJS Data Models</title>
		<link>http://existdissolve.com/2012/01/coldfusion-queries-to-extjs-data-models/</link>
		<comments>http://existdissolve.com/2012/01/coldfusion-queries-to-extjs-data-models/#comments</comments>
		<pubDate>Sun, 08 Jan 2012 13:55:09 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[Model]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2312</guid>
		<description><![CDATA[I love data Models in ExtJS. They are extremely simple to use, but are amazingly powerful for driving robust JavaScript applications. In fact, I&#8217;ve gotten to the point where I use them in just about everything I do, and they are fast becoming an indispensible part of my JavaScript development approach. A big part of&#8230;]]></description>
			<content:encoded><![CDATA[<p>I love data Models in ExtJS. They are extremely simple to use, but are amazingly powerful for driving robust JavaScript applications. In fact, I&#8217;ve gotten to the point where I use them in just about everything I do, and they are fast becoming an indispensible part of my JavaScript development approach.</p>
<p>A big part of the appeal of ExtJS data Models is their flexibility. While some data &#8220;plugins&#8221; in other JS frameworks certainly allow you mimic some of the behaviors of a data model, ExtJS&#8217; data Model wins hands down because of its extreme flexibility. With a ExtJS <a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Model">Model</a>, you can quickly and easily create powerful definitions of data objects (fields, data types, associations, validations, etc.) in your application. These models can then in turn be used to craft a data <a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.Store">Store</a>, which can themselves be plugged into many of ExtJS&#8217; data components (DataView, Grid, Chart). What you end up with is a super-powerful, deeply-data-driven application in a ridiculously small number of lines of code.</p>
<p>Of course, the perfect complement to the simplicity and grace of ExtJS&#8217;s data Model is to &#8220;feed&#8221; it using ColdFusion. Below, I&#8217;ll outline how to retrieve data from CF, as well an extremely easy way (there are obviously more!) to format data from a ColdFusion query directly into an ExtJS data Model.</p>
<blockquote><p><strong>Note: For these examples, I am using ColdFusion 9 and ExtJS 4.0.7</strong></p></blockquote>
<h2>ExtJS Models</h2>
<p>As mentioned above, the ExtJS data Model allows you to create pretty powerful&#8211;and flexible&#8211;definitions for data objects in your application. The beautiful part about this is that you can create a Model out of pretty much any data structure that is presented to your application. This allows you to spend your time making your JavaScript application work the way you want it to, without being enslaved to a particular requirement for data formatting (or type, for that matter). So whether you&#8217;re consuming XML, JSON, JSONP, etc., the ExtJS Model is flexible and configurable enough to normalize the incoming data structure into what you ultimately want (and need) your data objects to be for your application.</p>
<h2>ColdFusion Query to JSON</h2>
<p>How does this relate to ColdFusion? Well, let&#8217;s say that you have an existing, remotely-accessible component that returns a query result. In ColdFusion 8 and above, you can specify the &#8220;returnformat=json&#8221; argument in your method invocation, and ColdFusion wil serialize the query object into a JSON-formatted string, and return it to your JavaScript application.</p>
<pre>remote any function getqueryarrays() {
    fauxquery = querynew('id,name,age');
    queryaddrow(fauxquery,4);
    querysetcell(fauxquery,"id","1",1);
    querysetcell(fauxquery,"name","Joel",1);
    querysetcell(fauxquery,"age","31",1);
    querysetcell(fauxquery,"id","2",2);
    querysetcell(fauxquery,"name","Jason",2);
    querysetcell(fauxquery,"age","31",2);
    querysetcell(fauxquery,"id","3",3);
    querysetcell(fauxquery,"name","Godzilla",3);
    querysetcell(fauxquery,"age","100000",3);
    querysetcell(fauxquery,"id","4",4);
    querysetcell(fauxquery,"name","Batman",4);
    querysetcell(fauxquery,"age","0",4);
    return fauxquery;
}</pre>
<p>The one downside of this approach is that you don&#8217;t have a lot of control over how ColdFusion formats the JSON that it returns. It looks something like this:</p>
<p><a href="http://existdissolve.com/wp-content/uploads/2012/01/array.png"><img class="size-full wp-image-2316" style="display: block;" title="array" src="http://existdissolve.com/wp-content/uploads/2012/01/array.png" alt="" width="389" height="561" /></a></p>
<p>As you can see, ColdFusion&#8217;s JSON-encoding has done a few things:</p>
<ul>
<li>To represent the data, it has created two arrays: one for the column definitions, and one for the data. I would prefer an array of objects, but this is CF&#8217;s default behavior&#8230;</li>
<li>Perhaps worse, all of the &#8220;keys&#8221; have been uppercased, regardless of the original case of the columns</li>
</ul>
<p>In other JS libraries, you might have to do some pre-processing of the JSON in order to get the data into something more like an array of structures, and/or even re-work the casing on the keys (or modify the requirements in your app to account for the casing). This all, of course, assumes that you have control over the source generating the JSON. Good luck if you don&#8217;t!</p>
<h2>Making the Model</h2>
<p>With ExtJS&#8217;s data Model, the JSON formatting&#8211;and even the ultimate structure of the source data&#8211;just doesn&#8217;t matter. The Model is flexible enough to adapt, and you can easily configure it to consume just about any incoming structure/format that you can think of.</p>
<p>Here&#8217;s what we can do for our example data:</p>
<pre>Ext.define('Person', {
    extend: 'Ext.data.Model',
    fields: [
        {name:"ID", type:'int'},
        {name:"NAME", type:"string"},
        {name:"AGE", type:"number"}
    ],
    proxy: {
        type: 'ajax',
        url: 'remote.cfc?method=getqueryarrays&amp;returnformat=json',
        reader: {
             type: 'array',
             root: 'DATA'
        }
    }
})</pre>
<p>Seriously, it&#8217;s that simple. We just tell the Model that we&#8217;d like to define a data object with a certain number of fields, and it&#8217;s smart enough to automatically find and create an association with the incoming data. Here&#8217;s how we did it:</p>
<ul>
<li>The &#8220;fields&#8221; config option allows us to tell ExtJS what we want our data object to look like. Notice that in this example, the &#8220;name&#8221; attribute is upper-case. This matches the upper-case keys being returned from CF.</li>
<li>The &#8220;proxy&#8221; config allows us to tell the Model how we&#8217;ll retrieve the data that will build the Model. In this case, we&#8217;re using the <a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.proxy.Ajax">AjaxProxy.</a></li>
<li>In the proxy, we&#8217;ve also defined a &#8220;reader.&#8221; This is where the flexibility really comes into play. For the reader type, &#8220;array&#8221; has been specified. This tells ExtJS, at the very least, that our data is in an array format. Next, we&#8217;ve specified a &#8220;root&#8221; of &#8220;DATA.&#8221; This tell ExtJS that the &#8220;DATA&#8221; array will contain the values for the field definitions that we&#8217;ve already created.</li>
</ul>
<p>And with that, our Model is complete. We can now hook this up to a data store, and we&#8217;ll be able to use the store on any number of data-driven ExtJS components.</p>
<h2>A Bit of Tweaking</h2>
<p>Even though that&#8217;s pretty simple, we&#8217;re still a bit tied to the formatting that ColdFusion has returned&#8211;after all, we used the uppercase column names in our field definitions. But what if we don&#8217;t want uppercase field definitions in our Model?</p>
<p>While we can certainly leave it as is, the ExtJS Model allows us to alternatively map field definitions using the &#8220;mapping&#8221; attribute. For the <a href="http://docs.sencha.com/ext-js/4-0/#!/api/Ext.data.reader.Array">ArrayReader</a>, the mapping can be the position in the data structure, rather than the explicit field name. So with just a slight modification, we can easily map our fields as before, but also create arbitrary field names in our Model field definitions:</p>
<pre>Ext.define('Person', {   
     extend: 'Ext.data.Model',   
     fields: [       
        {name:"theid", type:'int',mapping:0},       
        {name:"myname", type:"string",mapping:1},       
        {name:"myage", type:"number",mapping:2}   
     ]
})</pre>
<h2>Wrapping Up</h2>
<p>As we&#8217;ve, ExtJS&#8217;s data Model is an extremely powerful and versatile way of creating robust data objects for JavaScript applications. Not only do they serve as a great foundation for ExtJS&#8217; data-driven components, but they (perhaps more importantly) are flexible enough to suit just about any requirement for incoming data. So instead of having to craft your application around the arbitrary data definitions which come from systems over which you may not have any control, you can easily leverage ExtJS data Models to take back the reins and define data objects based on the needs of your application alone. Pretty awesome <img src='http://existdissolve.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/01/coldfusion-queries-to-extjs-data-models/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Resolutions and Stuff</title>
		<link>http://existdissolve.com/2012/01/resolutions-and-stuff/</link>
		<comments>http://existdissolve.com/2012/01/resolutions-and-stuff/#comments</comments>
		<pubDate>Mon, 02 Jan 2012 14:26:21 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[2012]]></category>
		<category><![CDATA[Resolutions]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2300</guid>
		<description><![CDATA[I&#8217;m not big on resolutions. When I&#8217;ve made them in the past, I typically last about 3 whole days before they&#8217;re broken and forgotten. Besides, there&#8217;s something a bit odd about resolutions anyway. After all, why would we wait until a New Year to do something (lose weight, exercise more, etc.), when it makes a&#8230;]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not big on resolutions. When I&#8217;ve made them in the past, I typically last about 3 whole days before they&#8217;re broken and forgotten. Besides, there&#8217;s something a bit odd about resolutions anyway. After all, why would we wait until a New Year to do something (lose weight, exercise more, etc.), when it makes a lot more sense to do these things *before* the year begins so that we have the benefit of whatever change for the whole year?</p>
<p>Ah, but that&#8217;s the neurosis of the Western mind; what can be done about it? Nothing <img src='http://existdissolve.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>But even though I&#8217;m reticent about making resolutions, I have been thinking about the year that lies ahead, particularly from a professional standpoint. Over the last year, I&#8217;ve been very productive in my professional development. Particularly in relation to ColdFusion, JavaScript and SQL, I have tremendously expanded my competency, and I feel quite comfortable with where I am as a developer.</p>
<p>However, as we all know, complacency can be a silent killer. While it may not immediately harm a person in relation to their employment prospects, it can be detrimental in the long-term, if nothing else than by souring them to the prospects of learning new skills, exploring new technologies, etc.</p>
<p>I don&#8217;t want this to ever happen. I don&#8217;t feel like it&#8217;s a particular danger right now; I&#8217;m a naturally inquisitive person, so exploring new technologies, improving skills, etc. is just something I like to do. However, I do see this problem manifest in others, and I don&#8217;t like what it looks like. So, in my pre-emptive attempts to ward off such a fate, I&#8217;ve come up with a resolution (or two) of sorts for 2012.</p>
<h2>Becoming &#8220;Expert&#8221;</h2>
<p>When it comes to ColdFusion and JavaScript development, I feel very confident in my abilities. For any task, no matter the complexity, I am more than capable of crafting a solution that utilizes these technologies. I don&#8217;t say that in arrogance; it&#8217;s simply a fact. Ater so many years of using each, I can accomplish many things&#8230;and very quickly at that.</p>
<p>But while I am fully capable of using these technologies, I am also keenly aware of the extent (and limitations) of my competency. I have no delusions about my understanding of CF and JS. Yes, I can <strong><em>use</em></strong> them quite capably to do just about anything that is proposed. However, in regard to a more fundamental knowledge about the technology <em>qua</em> technology, I find many gaps in my understanding.</p>
<p>Therefore, one of the things that I want to pursue in 2012 is to begin a journey of becoming &#8220;expert&#8221; in ColdFusion and JavaScript. To me, the &#8220;expert&#8221; part that I&#8217;m missing is precisely this deeper understanding of how each technology *works* apart from the day-to-day grind of *using* them to accomplish discreet tasks. So this will mean that I will probably be doing a lot more reading about the technologies than actually using them. And you know what? I think that&#8217;s okay. The school of &#8220;learning by doing&#8221; has gotten me a VERY long way in my career. However, I think the next step wil come only by a very deep commitment to learning the bits that won&#8217;t necessarily come by trial and error.</p>
<p>You&#8217;ll notice I said &#8220;begin a journey.&#8221; I don&#8217;t expect to become &#8220;expert&#8221; by the end of 2012. However, I do want to determine a path that will get me where I intend to go. If I can accomplish just that, 2012 will have been a success.</p>
<h2>Explore New Frontiers</h2>
<p>One of the biggest keys to professional development, especially when it comes to web development, is to have an expansive portfolio of skills. This doesn&#8217;t mean, of course, that one needs to be &#8220;expert&#8221; in 7 different languages; that would probably be impossible for most people. However, it does mean that one is open to actively pursuing an understanding of how different technologies work and how each can be leveraged in various situations to accomplish particular goals.</p>
<p>In the coming year, there are a lot of technologies that I want to explore. In order to not get completely overwhelmed, I&#8217;m going to take a dual approach.</p>
<p>First, I&#8217;ve selected a handful that I want to do more of a &#8220;deep dive&#8221; into; these will require several weeks/months of exploration each. By the end of the year, I&#8217;d like to be able to say that I have a base-level competency with each technology&#8211;not something on the basis of which you&#8217;d hire me, but a working knowledge expansive enough to be able to accomplish <em>something</em>, and a solid foundation upon which I can build in the future. Here are the targets:</p>
<ul>
<li>Ruby</li>
<li>Node.js</li>
<li>jQuery</li>
<li>Python</li>
<li>ORM</li>
<li>Git</li>
</ul>
<p>Second, I want to build time into each week to take an hour or two to make a surface exploration of new technologies/snippets/etc. that I come across in the course of my daily blog trolling. So for example, if a new JavaScript framework is highlighted in one of the blogs I read, I want to explore that. My intention is, at the very most, to devote enough time to make a surface exploration. While this will not by any means make me competent in this or that technology, I think the practice will help to expand my skill set, simply by seeing how other people do things. I don&#8217;t have a discreet list for these, as I hope to leave time open for exploration as opportunities present themselves.</p>
<h2>Avoiding Blackhole Projects</h2>
<p>Over the last year, I found myself buried in blackhole projects. These were projects that I came up with on my own that didn&#8217;t have particular goals, or defined execution plans. With each of them, I started with the *intention* of learning/doing something new. However, I dreamed way too big, never accomplished whatever I had set out to do, and wasted a ton of time and effort for nothing except frustration.</p>
<p>In 2012, I&#8217;m going to make a concerted effort to avoid projects altogether. I&#8217;ve found that projects tend to devour an inordinate amount of time, simply because I end up spending a lot of effort on things that aren&#8217;t even central to the project itself (like getting the design pixel perfect, abstracting the 20 lines of JavaScript being used, etc.). So instead of using projects as a way of exploring this or that technology, I&#8217;m going to try to focus on simply executing very small, manageable development tasks. Whether this is simply creating a nice &#8220;Hello world&#8221; or developing some extension/module/whatever, keeping the scope tiny and defined will hopefully help me be much more productive in my learning and exploration.</p>
<h2>Blogging</h2>
<p>My blogging output in 2011 was a little underwhelming. While I did add some fairly in-depth posts, the number of posts was a bit disappointing. While quantity doesn&#8217;t really mean anything, it does reiterate to me the project blackhole problem I had during the year. So one of the things I really want to focus on in 2012 is becoming a better blogger. For me, I think this means being more intentional about regularly positing my experiences, while also not being quite so concerned with feeling like I have to write a novel each time.</p>
<h2>Wrapping Up</h2>
<p>So, it&#8217;s an ambitious plan for 2012. However, I&#8217;ve already made one important step: today, I officially abandoned a blackhole project that I had started last week. I&#8217;m beginning with a clean slate, and am looking forward to a great year of leaning, improving, and expansion of my development skills.</p>
<p>If anyone has any constructive thoughts/suggestions, I&#8217;d love to hear them!</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2012/01/resolutions-and-stuff/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Gotcha: Switch Statement in CFScript</title>
		<link>http://existdissolve.com/2011/08/coldfusion-gotcha-switch-statement-in-cfscript/</link>
		<comments>http://existdissolve.com/2011/08/coldfusion-gotcha-switch-statement-in-cfscript/#comments</comments>
		<pubDate>Tue, 30 Aug 2011 12:07:39 +0000</pubDate>
		<dc:creator>existdissolve</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[CFCase]]></category>
		<category><![CDATA[CFScript]]></category>
		<category><![CDATA[CFSwitch]]></category>

		<guid isPermaLink="false">http://existdissolve.com/?p=2208</guid>
		<description><![CDATA[The other day, I was reworking a bit of tag-based code to use my preference of &#60;cfscript&#62; syntax. While doing this, I ran across something like this: &#60;cfswitch expression="#img.extension#"&#62; &#60;cfcase value=".gif,.jpg"&#62; Not transparent &#60;/cfcase&#62; &#60;cfcase value=".png"&#62; Transparent &#60;/cfcase&#62; &#60;/cfswitch&#62; No rocket-science here, just a simple switch statement which just so happens to have a &#8220;case&#8221;&#8230;]]></description>
			<content:encoded><![CDATA[<p>The other day, I was reworking a bit of tag-based code to use my preference of &lt;cfscript&gt; syntax. While doing this, I ran across something like this:</p>
<pre>&lt;cfswitch expression="#img.extension#"&gt;
	&lt;cfcase value=".gif,.jpg"&gt;
		Not transparent
	&lt;/cfcase&gt;
	&lt;cfcase value=".png"&gt;
		Transparent
	&lt;/cfcase&gt;
&lt;/cfswitch&gt;</pre>
<p>No rocket-science here, just a simple switch statement which just so happens to have a &#8220;case&#8221; which evaluates a list of values. Honestly, I&#8217;m not sure I had ever done a list of values in a &lt;case&gt;, but it just works.</p>
<p>Thinking nothing of it, I quickly converted it to &lt;cfscript&gt; syntax:</p>
<pre>&lt;cfscript&gt;
	switch(img.extension) {
		case ".gif,.jpg":
			writeoutput("Not transparent");
			break;
		case ".png":
			writeoutput("Transparent");
			break;
	}
&lt;/cfscript&gt;</pre>
<p>At first, I thought it was working. But as I tested a bit more, I noticed that it wasn&#8217;t. No error, <em>per se</em>, but the &#8220;case&#8221; was not evaluating as it did in the tag-based equivalent.</p>
<p>Turns out you have to <a href="http://livedocs.adobe.com/coldfusion/8/htmldocs/CFScript_04.html">do something a bit different with &lt;cfscript&gt;</a>. Here&#8217;s an alternative that will replicate the tag-based functionality:</p>
<pre>&lt;cfscript&gt;
	switch(img.extension) {
		case ".gif": case ".jpg":
			writeoutput("Not transparent");
			break;
		case ".png":
			writeoutput("Transparent");
			break;
	}
&lt;/cfscript&gt;</pre>
<p>According to the docs,</p>
<blockquote><p>Multiple <samp><strong>case</strong></samp><strong> <em>constant:</em></strong> statements can precede the statement or statements to execute if any of the cases are true. This lets you specify several matches for one code block.</p></blockquote>
<p>Ah, so it&#8217;s a &#8220;feature.&#8221; Hmm, personally, I think this feels kind of clunky. I imagine there is a good reason for why it&#8217;s done this way, but I&#8217;d love to know why&#8211;anyone?</p>
]]></content:encoded>
			<wfw:commentRss>http://existdissolve.com/2011/08/coldfusion-gotcha-switch-statement-in-cfscript/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

