<?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>rabidGadfly &#187; coldFusion</title>
	<atom:link href="http://rabidgadfly.com/category/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://rabidgadfly.com</link>
	<description>Simple Solutions to Nagging Coding Problems</description>
	<lastBuildDate>Wed, 19 Oct 2011 13:43:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>ColdFusion Mappings and Hibernate</title>
		<link>http://rabidgadfly.com/2011/02/coldfusion-mappings-and-hibernate/</link>
		<comments>http://rabidgadfly.com/2011/02/coldfusion-mappings-and-hibernate/#comments</comments>
		<pubDate>Sat, 26 Feb 2011 03:20:38 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[hibernate]]></category>
		<category><![CDATA[orm]]></category>

		<guid isPermaLink="false">http://rabidgadfly.com/?p=489</guid>
		<description><![CDATA[Here’s a quick tip on an issue that set me back a couple of hours. ORM stands for Object/Relational Mapping, an object-based method of reducing the amount of code required to communicate with a database. Hibernate is an ORM Framework included in ColdFusion 9. I’m new to ORM so I started out by creating a [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-490" href="http://rabidgadfly.com/2011/02/coldfusion-mappings-and-hibernate/hibernate/"><img class="alignright size-thumbnail wp-image-490" title="hibernate" src="http://rabidgadfly.com/wp-content/uploads/2011/02/hibernate-150x150.jpg" alt="" width="150" height="150" /></a>Here’s a quick tip on an issue that set me back a couple of hours. ORM stands for Object/Relational Mapping, an object-based method of reducing the amount of code required to communicate with a database. Hibernate is an ORM Framework included in ColdFusion 9.</p>
<p>I’m new to ORM so I started out by creating a simple project with all components contained under the same application. It was a small struggle to get past the new terminology and occasional mistakes and/or omissions in the online documentation, but a few hours and several expletives later, I was up and running.</p>
<p><span id="more-489"></span><br />
My next step was to apply the method to an existing site. The major difference being that I wanted my ORM object definitions to be inaccessible externally. This required creating a ColdFusion mapping, which I created using the CF Administrator.</p>
<p>I set everything up and ran a test page which replied with an error: “Hibernate mapping for … component not found.”</p>
<p>After several hours of Googling, combined with a lot of trial and error, I discovered that in order to use Hibernate with a CF mapping, the mapping must application level. Once I deleted my mapping from CF Admin and added it to my Application.CFC, the error stopped and my results appeared.</p>
<p>One other note to keep in mind when configuring your ColdFusion application to use Hibernate: ORM settings must go in Application.CFC instead of the old-school Application.cfm.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2011/02/coldfusion-mappings-and-hibernate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdFusion Position Available &#8211; Northborough, MA</title>
		<link>http://rabidgadfly.com/2010/09/coldfusion-position-available-northborough-ma/</link>
		<comments>http://rabidgadfly.com/2010/09/coldfusion-position-available-northborough-ma/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 13:12:22 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[job posting]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=391</guid>
		<description><![CDATA[Pongo Resume in Northborough, MA is seeking a ColdFusion developer. Very casual working environment. Free caffeine all day long in the form of coffee, soda, or juice. Free lunches every Friday. If you&#8217;re interested send an e-mail to jobs-DEV@pongoresume.com and tell them you heard about it on this blog. Full description: Company: Pongo Resume Position [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.pongoresume.com">Pongo Resume</a> in <a href="http://maps.google.com/maps?f=q&#038;source=s_q&#038;hl=en&#038;geocode=&#038;q=44+Bearfoot+Rd,+Northborough,+MA+01532&#038;sll=37.0625,-95.677068&#038;sspn=48.019527,79.013672&#038;ie=UTF8&#038;hq=&#038;hnear=44+Bearfoot+Rd,+Northborough,+Worcester,+Massachusetts+01532&#038;t=h&#038;z=16">Northborough, MA</a> is seeking a ColdFusion developer. Very casual working environment. Free caffeine all day long in the form of coffee, soda, or juice. Free lunches every Friday. If you&#8217;re interested send an e-mail to jobs-DEV@pongoresume.com and tell them you heard about it on this blog.</p>
<p>Full description:</p>
<p><span style="color:#666633;font-weight:bold">Company:</span> Pongo Resume</p>
<p><span style="color:#666633;font-weight:bold">Position Title:</span> Development Specialist</p>
<p><span style="color:#666633;font-weight:bold">Type:</span> Full Time</p>
<p><span style="color:#666633;font-weight:bold">Overview:</span><br />
Pongo Resume is a premier, full-service online resource for job seekers. Privately held and headquartered in Northborough, Massachusetts, Pongo was honored in 2009 as one of the Inc. 5000 fastest growing private U.S. companies. Pongo Resume has more than 5 million registered users and averages well over a half-million unique visitors per month. The Pongo Resume web site provides users with all the tools, templates, and support needed to write professional resumes and cover letters, ace tough interviews, and secure a great job. Our users generate over 100,000 resumes per month.</p>
<p><span style="color:#666633;font-weight:bold">Responsibilities: </span><br />
We are seeking a bright, hard working, and self-motivated, mid to senior level Web Application Developer utilizing web technologies such as Flex, ColdFusion, jQuery and XML.  You will work closely with all members of the Pongo team.</p>
<p>•	Build and maintain highly scalable and dynamic web applications utilizing Flex, ColdFusion, jQuery and SQL Server.<br />
•	Develop reusable code and interaction with business logic database.<br />
•	Support and maintain existing application functionality through version releases and bug fixes.<br />
•	Adhere to rigid coding standards and best practices when developing applications.<br />
•	Brainstorm solutions and execute details to deliver end to end solutions.</p>
<p><span style="color:#666633;font-weight:bold">Minimum Qualifications:</span><br />
•	Proven experience developing dynamic applications that blend interactive GUIs developed in Flex, ColdFusion and jQuery with SQL Server databases.<br />
•	Solid understanding of object-oriented programming techniques.<br />
•	Experience with object-oriented and services-oriented architectures and methodologies.<br />
•	Experience with Flex and ColdFusion frameworks such as Mach II, Fusebox, Coldbox and Mate, a plus.<br />
•	Experience with Content Management Systems, such as Mura, a plus.<br />
•	Must be detailed-oriented and possess a strong drive to deliver quality, consistent results in a timely manner.<br />
•	Ability to handle multiple projects simultaneously.</p>
<p><span style="color:#666633;font-weight:bold">Contact: </span></p>
<p>Please send cover letter, resume, and salary requirements to:</p>
<p>jobs-DEV@pongoresume.com</p>
<p>Pongo Resume provides a friendly and collaborative working environment which encourages personal and professional growth.</p>
<p>Benefits include medical (HMO), dental, long -and short-term disability, free lunch Fridays, 401K, 15 PTO days, 10 paid holidays, closed between Christmas and New Year&#8217;s with pay.</p>
<p style="font-weight:bold;padding-top:25px;padding-bottom:25px;">Good Luck!<br/><br/>Glenn</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2010/09/coldfusion-position-available-northborough-ma/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Update ColdFusion Query Columns With JavaCast</title>
		<link>http://rabidgadfly.com/2009/10/update-coldfusion-query-columns-with-javacast/</link>
		<comments>http://rabidgadfly.com/2009/10/update-coldfusion-query-columns-with-javacast/#comments</comments>
		<pubDate>Fri, 09 Oct 2009 16:08:15 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[query]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=119</guid>
		<description><![CDATA[I recently found myself in need of a way to convert a Binary data column into Base64 encoded data when returning a query. After a quick Google, I was directed to Ben Nadel&#8217;s post &#8220;Updating Columns In An Existing ColdFusion Query Object&#8221; which details how to use javaCast to update a ColdFusion query. From there, [...]]]></description>
			<content:encoded><![CDATA[<p>I recently found myself in need of a way to convert a Binary data column into Base64 encoded data when returning a query. After a quick Google, I was directed to Ben Nadel&#8217;s post &#8220;<a href="http://www.bennadel.com/blog/1708-Ask-Ben-Updating-Columns-In-An-Existing-ColdFusion-Query-Object.htm">Updating Columns In An Existing ColdFusion Query Object</a>&#8221; which details how to use javaCast to update a ColdFusion query.</p>
<p>From there, I just needed to add the small extra step of Base64 encoding and my query was ready to go.</p>
<pre class="brush: coldfusion; title: ; notranslate">
&lt;cfloop  query=&quot;q&quot;&gt;
    &lt;cfset base64Data = toBase64(q.my_binary_data) /&gt;
    &lt;cfset q[&quot;my_binary_data&quot;][q.currentRow] = javaCast(&quot;string&quot;,'#base64Data#') /&gt;
&lt;/cfloop&gt;
</pre>
<p>This is not the first time I found a useful solution on Ben&#8217;s site. If you use ColdFusion, you should definitely <a href="http://www.bennadel.com/">check it out</a>. He has some great, easy-to-understand, posts on many useful topics.</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2009/10/update-coldfusion-query-columns-with-javacast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Easy Steps to set up Model-Glue 2: Unity on a Shared Host</title>
		<link>http://rabidgadfly.com/2009/04/10-easy-steps-to-set-up-model-glue-2-unity-on-a-shared-host/</link>
		<comments>http://rabidgadfly.com/2009/04/10-easy-steps-to-set-up-model-glue-2-unity-on-a-shared-host/#comments</comments>
		<pubDate>Wed, 08 Apr 2009 15:43:35 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[modelGlue]]></category>
		<category><![CDATA[coldspring]]></category>
		<category><![CDATA[model-glue]]></category>
		<category><![CDATA[shared hosting]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=110</guid>
		<description><![CDATA[Once I had it working, I was astounded by the simplicity. The only pre-requisite is that your server is running ColdFusion 8 or above. Here are the steps: Note that the following steps assume your site is already created Download ColdSpring. Unzip ColdSpring, rename the unzipped folder to &#8220;coldspring&#8221; and copy it into your site [...]]]></description>
			<content:encoded><![CDATA[<p>Once I had it working, I was astounded by the simplicity. The only pre-requisite is that your server is running ColdFusion 8 or above. Here are the steps:</p>
<p><em>Note that the following steps assume your site is already created</em></p>
<ol>
<li><a href="http://www.coldspringframework.org/" target="_blank">Download ColdSpring</a>.</li>
<li>Unzip ColdSpring, rename the unzipped folder to &#8220;coldspring&#8221; and copy it into your site root.</li>
<li><a href="http://www.model-glue.com/" target="_blank">Download Model-Glue</a>.</li>
<li>Unzip the Model-Glue archive into a temp folder.</li>
<li>Copy the Model-Glue folder into your site root.</li>
<li>Copy the <em>contents</em> of the /modelglueapplicationtemplate directory to your site root. Do NOT copy the folder itself.</li>
<li>From your site root, open /config/ColdSpring.xml and delete the two occurrences of &#8220;/modelglueapplicationtemplate&#8221; on lines 12 and 13. This should result in your viewMappings being &#8220;/views&#8221; and your generatedViewMapping being &#8220;/views/generated&#8221;</li>
<li>From your site root, open /config/ModelGlue.xml and delete &#8220;modelglueapplicationtemplate.&#8221; from line 3 making it &#8220;controller.Controller&#8221; instead of &#8220;modelglueapplicationtemplate.controller.Controller&#8221;.</li>
<li>Delete Application.cfm from your site root and replace it with the Application.cfc in <a href="http://www.rabidgadfly.com/misc/Application.zip">this zip file</a>.</li>
<li>Open Application.cfc and change the application name from <em>yourAppNameHere</em> to your application name. If you don&#8217;t know what to use, use your domain minus the dot, i.e., &#8220;myDomainCOM&#8221;.</li>
</ol>
<p>Providing your server is running ColdFusion 8 or above, you should now have a working Model-Glue site! To test it, open the site in your browser and you should see a message stating &#8220;Model-Glue is up and running!&#8221;</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2009/04/10-easy-steps-to-set-up-model-glue-2-unity-on-a-shared-host/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Use cf_sql_timestamp for MS SQL and MySQL date types</title>
		<link>http://rabidgadfly.com/2009/03/use-cf_sql_timestamp-for-mssql/</link>
		<comments>http://rabidgadfly.com/2009/03/use-cf_sql_timestamp-for-mssql/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:11:42 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[cfqueryparam]]></category>
		<category><![CDATA[cf_sql_date]]></category>
		<category><![CDATA[cf_sql_timestamp]]></category>
		<category><![CDATA[ms sql]]></category>
		<category><![CDATA[sql server]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=101</guid>
		<description><![CDATA[Hopefully, if you&#8217;re using ColdFusion, you&#8217;re already using cfqueryparam in your queries for better performance and security against SQL Injection attacks. If you&#8217;re not, you should read this. When using cfqueryparam you specify a value and an SQL type. Dates can be assigned two different types, cf_sql_date and cf_sql_timestamp. cf_sql_date is intended to be used [...]]]></description>
			<content:encoded><![CDATA[<p>Hopefully, if you&#8217;re using ColdFusion, you&#8217;re already using <a href="http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_p-q_18.html">cfqueryparam</a> in your queries for better performance and security against SQL Injection attacks. If you&#8217;re not, you should read <a href="http://www.forta.com/blog/index.cfm/2005/12/21/SQL-Injection-Attacks-Easy-To-Prevent-But-Apparently-Still-Ignored">this</a>.</p>
<p>When using cfqueryparam you specify a value and an SQL type. Dates can be assigned two different types, cf_sql_date and cf_sql_timestamp. cf_sql_date is intended to be used for date types in DB2 and Informix. If you&#8217;re using MS SQL Server, you should use cf_sql_timestamp.</p>
<p>cf_sql_timestamp maps  to the datetime and smalldatetime data types in MS SQL Server. Although cf_sql_date works in many instances, it does not work in all instances. I ran into this issue when evaluating whether a date equaled a certain date value. For example:</p>
<pre><code>
SELECT *
FROM myTable
WHERE create_dt = <cfqueryparam type="cf_sql_date" value="2099-12-31  23:59:59" />
</code></pre>
<p>When I ran the query in SQL Query Analyzer (minus the cfqueryparam of course), I received the expected results. When I ran it inside a ColdFusion page I received an empty result set. Once I changed to timestamp, I received my results.</p>
<pre><code>
SELECT *
FROM myTable
WHERE create_dt = <cfqueryparam type="cf_sql_timestamp" value="2099-12-31  23:59:59" />
</code></pre>
<p>I haven&#8217;t tested the code with mySQL, and mySQL isn&#8217;t listed in the livedocs cross-reference table so I don&#8217;t know what kind of effect can be seen there, though I&#8217;d be interested to find out.</p>
<p><strong>UPDATE:</strong> I got two great tips from comments. According to sebastiaan cf_sql_timestamp should be used with MySQL as well as MS SQL Server. And Ben Nadel adds that cf_sql_longvarchar should be used for text fields. Great info. Thank you both!</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2009/03/use-cf_sql_timestamp-for-mssql/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using CFAjaxProxy in a Shared Hosting Environment</title>
		<link>http://rabidgadfly.com/2008/09/using-cfajaxproxy-in-a-shared-hosting-environment/</link>
		<comments>http://rabidgadfly.com/2008/09/using-cfajaxproxy-in-a-shared-hosting-environment/#comments</comments>
		<pubDate>Wed, 10 Sep 2008 19:43:47 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[cfajax.js]]></category>
		<category><![CDATA[cfajaxproxy]]></category>
		<category><![CDATA[cfide]]></category>
		<category><![CDATA[cfmessage.js]]></category>
		<category><![CDATA[shared hosting]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=69</guid>
		<description><![CDATA[As I mentioned in my last post (Drag and Drop Sorting with CFAjaxProxy and Script.aculo.us) I&#8217;ve started to use CFAjaxProxy. It&#8217;s been very easy to integrate and I had no problems at all on my local machine. However, after posting my work to a live site my AJAX functionality ceased working. Thanks to Firebug, I [...]]]></description>
			<content:encoded><![CDATA[<p>As I mentioned in my last post (<a href="http://www.rabidgadfly.com/?p=68" alt="Read my post! (But finish this one first)">Drag and Drop Sorting with CFAjaxProxy and Script.aculo.us</a>) I&#8217;ve started to use CFAjaxProxy. It&#8217;s been very easy to integrate and I had no problems at all on my local machine. However, after posting my work to a live site my AJAX functionality ceased working.</p>
<p>Thanks to <a href="https://addons.mozilla.org/en-US/firefox/addon/1843" alt="Get Firebug for Firefox!">Firebug</a>, I was able to track down the issue pretty quickly. The cfajax.js and cfmessage.js libraries were failing to load. These files are located in subfolders under the CFIDE folder.</p>
<p>For those unfamiliar with the CFIDE folder, it contains central and core coldfusion files, custom tags, libraries and the ColdFusion administrator. The reason I wasn&#8217;t having the problem locally was because I wasn&#8217;t in a shared hosting environment so CFIDE was right where ColdFusion expected it to be.</p>
<p>In a shared hosting environment, however, ColdFusion looks for CFIDE in the root of the current domain. So, rather than looking in the web server root, it looks in the domain root. For example, if the site I&#8217;m working on is mysite.com, ColdFusion will look for CIDE in http://www.mysite.com/CFIDE/.</p>
<p>While I could make a virtual directory mapping to the existing CFIDE folder, I didn&#8217;t want to expose the ColdFusion Administrator. Instead, I created a new CFIDE folder and copied only the SCRIPTS subfolder into it. I then created a CFIDE virtual directory within the domain which pointed to the new CFIDE folder.</p>
<p>I know many developers have experienced a similar issue with CFFORM, however, that issue can be surmounted with the use of the <a href="http://tutorial157.easycfm.com/" alt="using CFFORM in a hosted environment">scriptsrc parameter</a> which isn&#8217;t available for CFAjaxProxy.</p>
<p>Admittedly, this solution feels a bit lame, but I&#8217;m unaware of any other way around it. If you know of a better way, please leave a comment!</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/09/using-cfajaxproxy-in-a-shared-hosting-environment/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Drag and Drop Sorting with CFAjaxProxy and Script.aculo.us</title>
		<link>http://rabidgadfly.com/2008/08/drag-and-drop-sorting-with-cfajaxproxy-and-scriptaculous/</link>
		<comments>http://rabidgadfly.com/2008/08/drag-and-drop-sorting-with-cfajaxproxy-and-scriptaculous/#comments</comments>
		<pubDate>Mon, 25 Aug 2008 03:39:52 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[ajax]]></category>
		<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[script.aculo.us]]></category>
		<category><![CDATA[cfajaxproxy]]></category>
		<category><![CDATA[drag and drop]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=68</guid>
		<description><![CDATA[I made a video player recently containing a list of videos. My client requested the ability to put them in a custom order. It didn&#8217;t take much research to find the functionality in the Script.aculo.us library. The question was, how do I implement it with ColdFusion? I knew I would need AJAX functionality and, up [...]]]></description>
			<content:encoded><![CDATA[<p>I made a video player recently containing a list of videos. My client requested the ability to put them in a custom order. It didn&#8217;t take much research to find the functionality in the <a href="http://script.aculo.us/">Script.aculo.us</a> library. The question was, how do I implement it with ColdFusion?</p>
<p>I knew I would need AJAX functionality and, up to this point, I had always used Rob Gonda&#8217;s AjaxCFC. With the release of ColdFusion 8, however, Adobe introduced <a href="http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_a-b_3.html">CFAjaxProxy</a>. I&#8217;d been looking for an opportunity to give it a try and this turned out to be a perfect fit.</p>
<p>Jake Munson of <a href="http://techfeed.net/blog/">Yacoblog</a> posted a <a href="http://techfeed.net/blog/index.cfm/2007/6/18/ColdFusion-8-CFAjaxProxy">great introduction to using CFAjaxProxy</a>. Simple and straight to the point. I had it working in no time.</p>
<p>My next stop was a <a href="http://www.lynchconsulting.com.au/blog/index.cfm/2007/7/15/JavaScript-Drag--Drop">post by Mohammed Irfaan</a> over at the <a href="http://www.lynchconsulting.com.au/blog/">Lynch Consulting Blog</a> which discusses a technique for using ColdFusion to update an underlying table after using Script.aculo.us&#8217;s Drag and Drop functionality.</p>
<p>Here&#8217;s how I put it all together:<br />
<span id="more-68"></span><br />
First, I created a table named videocenter to hold my video records. It looks something like this:<br />
video_uuid &#8211; Unique identifier for each video record<br />
video_title &#8211; Title for the video record<br />
sort_order &#8211; Integer reflecting the order in which the video should be displayed.</p>
<p>Next, I wrote my sortvideos CFC which will loop through the list of videos that my page will send to it, and update the sort_order column to reflect the order in which the video are currently displayed on the screen (more about that later):</p>
<pre><code>
<cfcomponent>
<cffunction name="updateVideoSort" access="remote" returntype="boolean">
	<cfargument name="sortStruct" type="any" required="yes">
	<cfset var q="" />
	<cfset var i=0 />
	<cfloop from="1" to="#ListLen(arguments.sortStruct)#" index="i">
	   <cfquery name="q" datasource="#application.dsn#">
	      UPDATE	videocenter
	      SET 		sort_order = <cfqueryparam value="#i#" cfsqltype="cf_sql_integer">
	      WHERE 	video_uuid = <cfqueryparam value="#trim(listGetAt(arguments.sortStruct, i))#" cfsqltype="cf_sql_varchar" />
	   </cfquery>
	</cfloop>
	<cfreturn true>
</cffunction>
</cfcomponent>
</code></pre>
<p>After downloading and installing the <a href="http://script.aculo.us/">Script.aculo.us</a> JavaScript library, I began to build my page.</p>
<p>I started off by defining the Ajax proxy. This line defines my ColdFusion component (sortvideos) and the JavaScript proxy class that represents the CFC (respond):</p>
<pre><code>
<cfajaxproxy cfc="sortvideos" jsclassname="respond">
</code></pre>
<p>I then included the necessary Script.aculo.us files and the JavaScript function that will call the Ajax method within my ColdFusion component. Note that you may have to alter the path to the JavaScript files depending on where yours are stored:</p>
<pre><code>
<script language="JavaScript" src="js/scriptaculous/lib/prototype.js"></script>
<script language="JavaScript" src="js/scriptaculous/src/scriptaculous.js"></script>

<script type="text/javascript">
function resort() {
	var r= new respond();
	var orderList = '';
	//call the echo function from the CFC
	orderedNodes = document.getElementById("sortable_list").getElementsByTagName("li");
	for (var i=0;i < orderedNodes.length;i++) {
		orderList += orderedNodes[i].getAttribute('recordid') + ', ';
	}
	r.updateVideoSort(orderList);
  }
</script>
</code></pre>
<p>When called, orderedNodes will become an array of the LI elements within the "sortable_list" UL element defined below. The elements in the array will be in the order in which the list appears on the page. This is the list that gets sent to the updateVideoSort method within my sortvideos CFC above.</p>
<p>Next, I loop through my video records and display the videos in an unordered list. I add an ID to the UL named "sortable_list" and I add a custom attribute to each LI element (recordid) containing video_uuid from my videos table. After that, I place a submit button that will call my resort() function when clicked.</p>
<pre><code>
<cfset qvideos = videosService.getVideos() />
<ul id="sortable_list" style="cursor: move; list-style:none;">
<cfoutput query="qvideos">
<li recordid="#video_uuid#">#video_title#</li>

</cfoutput>
</ul>
<input type="button" onclick="resort();" value="Submit new order" />
</code></pre>
<p>Finally, a last bit of required JavaScript to make the Script.aculo.us magic happen. Note that "sortable_list" is the id I gave to my UL element above.<br />
<script language="JavaScript">
	Sortable.create("sortable_list");
</script></p>
<p>Now I have a list of videos from my videocenter table which can be ordered using drag and drop functionality a la Netflix.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/08/drag-and-drop-sorting-with-cfajaxproxy-and-scriptaculous/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>CFQUERYPARAM with LIKE and IN Clauses</title>
		<link>http://rabidgadfly.com/2008/07/cfqueryparam-with-like-and-in-clauses/</link>
		<comments>http://rabidgadfly.com/2008/07/cfqueryparam-with-like-and-in-clauses/#comments</comments>
		<pubDate>Wed, 23 Jul 2008 12:44:57 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[cfqueryparam]]></category>
		<category><![CDATA[in clause]]></category>
		<category><![CDATA[like clause]]></category>
		<category><![CDATA[sql injection]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=67</guid>
		<description><![CDATA[ColdFusion&#8217;s CFQUERYPARAM tag is important for several reasons, most notably data type validation, improved query performance, and foiling SQL injection attacks. Basic usage is simple: SELECT * FROM tblCustomers WHERE customer_id = The cfsqltype parameter validates the passed value before it is sent to the database server. Once validated, the query is sent to the [...]]]></description>
			<content:encoded><![CDATA[<p>ColdFusion&#8217;s <a href="http://www.cfquickdocs.com/cf8/#cfqueryparam">CFQUERYPARAM</a> tag is important for several reasons, most notably data type validation, improved query performance, and foiling SQL injection attacks.</p>
<p>Basic usage is simple:</p>
<pre><code>
SELECT *
FROM tblCustomers
WHERE customer_id = <cfqueryparam value="#FORM.custID#" cfsqltype="cf_sql_integer">
</code></pre>
<p>The cfsqltype parameter validates the passed value before it is sent to the database server. Once validated, the query is sent to the database with a placeholder where the criteria would otherwise be. The criteria itself is passed separately and plugged in to the query where the placeholder exists. This allows the query to be cached by the database server, improving performance the next time the query is run.</p>
<p>CFQUERYPARAM also prevents SQL injection attacks that attempt to trick your code into running an extra query &#8220;injected&#8221; into the URL.  SQL Injection attacks can do anything from modifying data in your tables to dropping your tables entirely if you don&#8217;t take preventative measures.</p>
<p>For further detail on CFQUERYPARAM, check out <a href="http://coldfusion.sys-con.com/read/41712_p.htm">this post</a> by Ben Forta.</p>
<p>Now, back to the point of my post. I simply want an easy place to find the correct syntax for a couple of the trickier clauses, namely &#8220;IN&#8221; and &#8220;LIKE&#8221;. I find myself researching the syntax repeatedly and it always seems time-consuming to find a post describing the correct method when I need it. So here they are:</p>
<p><strong>IN Clause</strong><br />
The IN clause is used to find all of the records that match the criteria in a comma separated list of values. The SQL syntax is as follows:</p>
<pre><code>
SELECT *
FROM tblCustomers
WHERE customer_id IN (12345, 54321, 22222)
</code></pre>
<p>The query above will find customer records with IDs of 12345, 54321, or 22222.</p>
<p>To use cfqueryparam, place the parentheses outside the tag and use the &#8220;list&#8221; parameter:</p>
<pre><code>
<cfset IDLIST = "12345, 54321, 22222" >
<cfquery name="q" datasource="myDS">
SELECT *
FROM tblCustomers
WHERE customer_id IN ( <cfqueryparam value="#IDLIST#" cfsqltype="cf_sql_integer" list="yes">)
</cfquery>
</code></pre>
<p><strong>LIKE Clause</strong><br />
The LIKE clause uses % as a wildcard symbol to find records that contain a certain string of text. The SQL syntax for the LIKE clause is as follows:</p>
<pre><code>
SELECT *
FROM tblCustomers
WHERE customer_lastname LIKE '%ski'
</code></pre>
<p>This query will find all of the customers whose last name ends in &#8216;ski&#8217;.</p>
<p>To use cfqueryparam, you concatenate the percent sign to the tag, like this:</p>
<pre><code>
<cfquery name="q" datasource="myDS">
SELECT *
FROM tblCustomers
WHERE customer_lastname LIKE '%' + <cfqueryparam value="ski" cfsqltype="cf_sql_varchar">
</cfquery>
</code></pre>
<p>Note that, while my example uses the wildcard at the beginning of the text string, it can also be used on both sides, or at the end only.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/07/cfqueryparam-with-like-and-in-clauses/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Use &lt;CFIMAGE&gt; to Generate Temporary Thumbnails</title>
		<link>http://rabidgadfly.com/2008/06/use-cfimage-to-generate-temporary-thumbnails/</link>
		<comments>http://rabidgadfly.com/2008/06/use-cfimage-to-generate-temporary-thumbnails/#comments</comments>
		<pubDate>Fri, 20 Jun 2008 14:10:19 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[cfimage]]></category>
		<category><![CDATA[thumbnails]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=66</guid>
		<description><![CDATA[I&#8217;m wrapping up a sizable project that required 200&#215;200 thumbnails for about two thousand pieces of content. The agency I&#8217;m working with required properly-sized thumbnails to proceed with their testing. Unfortunately, thumbnails did not exist at that point. ColdFusion &#60;CFIMAGE&#62; to the rescue! By using &#60;CFIMAGE&#62;, I was able to generate thumbnails for every piece [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m wrapping up a sizable project that required 200&#215;200 thumbnails for about two thousand pieces of content. The agency I&#8217;m working with required properly-sized thumbnails to proceed with their testing. Unfortunately, thumbnails did not exist at that point.</p>
<p>ColdFusion &lt;CFIMAGE&gt; to the rescue!</p>
<p>By using &lt;CFIMAGE&gt;, I was able to generate thumbnails for every piece of content in under 30 seconds. To add a little variety into the mix I created five different base images named thumb1.jpg &#8211; thumb5.jpg and chose one at random for each record. As I looped through the table that contained the content records, I used the content record&#8217;s ID (an auto-generated integer) as the filename and updated the thumbnail field as I went along.</p>
<p>The code I used looks something like this:</p>
<pre><code>
<cfsetting requestTimeOut = "9999">

<cfquery name="qContent"  datasource="myDS">
	select *
	from content
</cfquery>

<cfset thumbpath= ExpandPath("/images/tempthumbs/") />

<cfoutput>

<cfloop query="qContent">

	<cfset thumbnum = RandRange( 1, 5, "SHA1PRNG" )>
	<cfset thumbname = "thumb#thumbnum#.jpg">

	<cfimage source="#thumbpath##thumbname#" name="contentThumb">
	<cfset ImageDrawText(contentThumb, "#content_name#", 5, 15)>
	<cfimage source="#contentThumb#" action="write" destination="#thumbpath##qContent.contentID#.jpg" overwrite="yes">

	<cfquery name="updContent" datasource="myDS">
		UPDATE	content
		SET	thumbnail_image='http://www.mydomain.com/images/tempthumbs/#qContent.contentID#.jpg'
		WHERE	contentID = '#contentID#'
	</cfquery>

</cfloop>

</cfoutput>
</code>

</code></pre>
<p>The &#8220;cfset imageDrawText&#8221; line is the one that adds the text contained in the content_name column to the image. It also places the caption 5px in and 15px down from the top left corner of the image.</p>
<p>When the code finishes I have unique thumbnails for each piece of content.</p>
<p>-rG</p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/06/use-cfimage-to-generate-temporary-thumbnails/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Is it possible to pass a structure to ColdFusion using Flash AS3 / Remoting</title>
		<link>http://rabidgadfly.com/2008/05/is-it-possible-to-pass-a-structure-to-coldfusion-using-flash-as3-remoting/</link>
		<comments>http://rabidgadfly.com/2008/05/is-it-possible-to-pass-a-structure-to-coldfusion-using-flash-as3-remoting/#comments</comments>
		<pubDate>Tue, 20 May 2008 14:57:15 +0000</pubDate>
		<dc:creator>rabidgadfly</dc:creator>
				<category><![CDATA[as3]]></category>
		<category><![CDATA[coldFusion]]></category>
		<category><![CDATA[remoting]]></category>
		<category><![CDATA[amf]]></category>
		<category><![CDATA[flash]]></category>
		<category><![CDATA[netconnection]]></category>
		<category><![CDATA[objectEncoding]]></category>

		<guid isPermaLink="false">http://www.rabidgadfly.com/?p=64</guid>
		<description><![CDATA[UPDATE: This problem has been solved. The solution is after the post. I&#8217;ve posted on a few forums now with no results so I&#8217;m resorting to my own blog. What I&#8217;m trying to do is pass a structure to a ColdFusion component from Flash. I&#8217;ve tried using Array, Object, and Dictionary types but it keeps [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE:</strong> This problem has been solved. The solution is after the post.</p>
<p>I&#8217;ve posted on a few forums now with no results so I&#8217;m resorting to my own blog. What I&#8217;m trying to do is pass a structure to a ColdFusion component from Flash. I&#8217;ve tried using Array, Object, and Dictionary types but it keeps failing with this error:</p>
<p>&#8220;Unknown object type tag (17)&#8221;</p>
<p>The error seems to be returned before the method is even reached suggesting that the cfc is rejecting the Remoting request altogether. I know the code is sound because I can change the structure to a string and get results back. I&#8217;ve also tried the Flash.Params method.</p>
<p>I&#8217;ve done a fair amount of research already, including studying <a href="http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=usingSalsaN_4.html">Adobe livedocs</a> which insists that it&#8217;s possible to do.</p>
<p>Here is my code:</p>
<pre><code>
loadData_btn.addEventListener(MouseEvent.MOUSE_DOWN, loadData)

var myService = new NetConnection()
myService.connect("http://localhost/flashservices/gateway/")

function loadData(evt:MouseEvent){
    var responder = new Responder(getTest_Result, onFault);
/* I've tried everything here including defining it as an Object and Dictionary. I also tried
defining it using dot notation and sending it as an object like so: {mystring:"hello"} */
	var mystruct:Array = new Array();
	mystruct["mystring"] = "hello";
	myService.call("com.mycomponent.test", responder, mystruct);
}

function getTest_Result(result){
    trace("success: "+ result);
}

function onFault( f){
	trace("There was a problem: " + f.description);
}
</code></pre>
<p>&#8230;and here&#8217;s my component function (I&#8217;ve tried with an argument type of &#8216;struct&#8217; as well as &#8216;any&#8217;):</p>
<pre><code>
<cffunction name="test" output="no" access="remote" returntype="string" >
	<cfargument name="argstruct" type="any" required="no" />
	<cfset mystr =arguments.argstruct["mystring"]>
	<cfreturn  mystr />
</cffunction>
</code></pre>
<p>Thanks in advance for any help!</p>
<p>rG</p>
<p><strong>SOLUTION:</strong> <em>After many hours of Googling, and much trial and error, I figured out how to make this work&#8230;and it&#8217;s a one line solution. Simply add myService.objectEncoding=0 before the myService.connect line at the top. It has to do with the way objects are serialized using AMF. </em></p>
]]></content:encoded>
			<wfw:commentRss>http://rabidgadfly.com/2008/05/is-it-possible-to-pass-a-structure-to-coldfusion-using-flash-as3-remoting/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

