<?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>ShinyLight Development &#187; ColdFusion</title>
	<atom:link href="http://www.shinylight.com/category/languages/coldfusion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shinylight.com</link>
	<description>Web Development and Other Goodness in the World of a Software Engineer.</description>
	<lastBuildDate>Mon, 09 Jan 2012 00:18:47 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>ErrorDetail I/O Exception: peer not authenticated</title>
		<link>http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/</link>
		<comments>http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/#comments</comments>
		<pubDate>Tue, 07 Jun 2011 23:10:37 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=1056</guid>
		<description><![CDATA[Similar to this page, I was getting the following error:
ErrorDetail I/O Exception: peer not authenticated
Filecontent Connection Failure
Mimetype Unable to determine MIME type of file.
Statuscode Connection Failure. Status code unavailable.
Which you get when the JVM has an old version of an SSL certificate. More specifically, I was having problems connecting to ConstantContact, after noticing that they [...]]]></description>
			<content:encoded><![CDATA[<p>Similar to this <a href="http://coldfusion-archive.robgonda.com/blog/index.cfm/2007/10/29/ErrorDetail-IO-Exception-peer-not-authenticated/">page</a>, I was getting the following error:</p>
<blockquote><p>ErrorDetail I/O Exception: peer not authenticated<br />
Filecontent Connection Failure<br />
Mimetype Unable to determine MIME type of file.<br />
Statuscode Connection Failure. Status code unavailable.</p></blockquote>
<p>Which you get when the JVM has an old version of an SSL certificate. More specifically, I was having problems connecting to ConstantContact, after noticing that they had just renewed their certificate:</p>
<p><a href="http://www.shinylight.com/wp-content/uploads/2011/06/1.png"><img class="alignnone size-full wp-image-1057" title="1" src="http://www.shinylight.com/wp-content/uploads/2011/06/1.png" alt="" width="409" height="354" /></a></p>
<p>Cracking my head open, and trying every solution in the world along what the people posted <a href="http://www.talkingtree.com/blog/index.cfm/2004/7/1/keytool">here</a>, we just decided to reboot the server. This flushed the cache and it worked.</p>
<p>If you can afford to do this, then I recommend it if you want to go for the fastest solution. ConstantContact later provided other <a href="http://community.constantcontact.com/t5/Authentication-and-Access-ie-401/New-Certificate-Installation-may-affect-some-when-trying-to/td-p/30835">possible solutions</a>.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;submitHeadline=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;title=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;title=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;title=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;bm_description=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;T=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;title=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;title=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated+@+http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/&amp;t=ErrorDetail+I%2FO+Exception%3A+peer+not+authenticated" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2011/06/08/errordetail-io-exception-peer-not-authenticated/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Implementing the Strategy Pattern in ColdFusion</title>
		<link>http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/</link>
		<comments>http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/#comments</comments>
		<pubDate>Sun, 02 May 2010 03:27:18 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=949</guid>
		<description><![CDATA[In spirit of the amazing book Head First Design Patterns, I wanted to put together a ColdFusion example that depicts the Strategy pattern. Essentially, the Strategy Pattern lets you group related algorithms together so that an object is able to select which algorithm to run at runtime. 
So let&#8217;s say for example you had a [...]]]></description>
			<content:encoded><![CDATA[<p>In spirit of the amazing book <a href="http://www.amazon.com/gp/product/0596007124/">Head First Design Patterns</a>, I wanted to put together a ColdFusion example that depicts the Strategy pattern. Essentially, the Strategy Pattern lets you group related algorithms together so that an object is able to select which algorithm to run at runtime. </p>
<p>So let&#8217;s say for example you had a parent class that has two properties and two methods. You now create a subclass that inherits the parent class, meaning that it will gobble up all the properties and methods (whether you like it or not) from the parent class. You can&#8217;t choose, for example, what methods you subclass needs, even if some methods don&#8217;t make sense for your subclass. It&#8217;s an all-or-nothing solution. Yes, you can override, but what if there were 10 methods to override? Also, what if you had to create other types of subclasses &#8211; you&#8217;ll have to override those as well. Things can get a little sloppy at the end. That&#8217;s where the strategy pattern comes in.</p>
<p>With this pattern, you first think about related methods and algorithms. (One method can have various algorithms; different implementations for doing the same thing.) For this blog post&#8217;s example, we&#8217;ll think of different ways a SuperHero can punch. To keep things simple, let&#8217;s give him two ways (two different algorithms for punching) he can punch. He can punch normally, or he can punch you, which freezes you as well. Let&#8217;s UML this to make things clearer.</p>
<p>First what the lines mean:</p>
<div align="center"><img src="/wp-content/uploads/2010/04/Lines.png"></div>
<p> <br/></p>
<p>Here&#8217;s the UML diagram for our SuperHero scenerio:</p>
<div align="center"><img src="/wp-content/uploads/2010/04/punchonly.png"></div>
<p> <br/></p>
<p>From the diagram, you can see that the SuperHero abstract class is able to choose a punch set of algorithms (a strategy). We also see that Punch and PunchFreeze are implementation classes (classes that serve to implement an interface). Both of them have a punch() method that return void (nothing) &#8211; in this example, they&#8217;ll do stuff, and not return anything. </p>
<p>To make things a little more interesting, and to follow closer the example in the Strategy Pattern chapter of the book, we&#8217;re going to also create a subclass called Freezer that inherits the SuperHero class. Also, we&#8217;ll create another strategy for kicking. Here&#8217;s what the UML for that looks like: </p>
<div align="center"><img src="/wp-content/uploads/2010/04/full.png"></div>
<p> <br/></p>
<p>Here&#8217;s the CF code:</p>
<p><strong>SuperHero.cfc</strong></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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- This is our abstract class. Responsibility to implement is delegated to ---&gt;</span>
<span style="color: #808080; font-style: italic;">&lt;!--- classes that implement interfaces. ---&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;init&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;SuperHero&quot;</span><span style="color: #0000FF;">&gt;</span></span>  
  <span style="color: #808080; font-style: italic;">&lt;!--- Some other init code goes here.  ---&gt;</span>  
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;name&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&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;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;gender&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&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;">name</span> <span style="color: #0000FF;">=</span> arguments.<span style="color: #0000FF;">name</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.gender <span style="color: #0000FF;">=</span> arguments.gender <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> this <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;setPunchAlgorithm&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #808080; font-style: italic;">&lt;!--- The next two lines are key. It's where you set the implementation ---&gt;</span>
  <span style="color: #808080; font-style: italic;">&lt;!--- of punch from an object that's being passed in. ---&gt;</span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;PunchAlgorithm&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;IPunchAlgorithm&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&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.punchAction <span style="color: #0000FF;">=</span> PunchAlgorithm.punch <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;setKickAlgorithm&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&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;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;KickAlgorithm&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;IKickAlgorithm&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&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.kickAction <span style="color: #0000FF;">=</span> KickAlgorithm.kick <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: #808080; font-style: italic;">&lt;!--- This function will be overridden.  ---&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;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;energyProject&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;SuperHero&quot;</span> <span style="color: #0000FF;">&gt;</span></span>  
  You have been pointed at by a weak flash light.  
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfreturn</span> this <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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p><strong>IPunchAlgorithm.cfc</strong></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>cfinterface<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;punch&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span>cfinterface<span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p><strong>Punch.cfc</strong></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;">cfcomponent</span> implements<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;IPunchAlgorithm&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;punch&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  You have been punched normally. Ouch.
<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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p><strong>PunchFreeze.cfc</strong></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;">cfcomponent</span> implements<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;IPunchAlgorithm&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;punch&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  You have been punched and are now frozen, stuck. Good luck thawing!
<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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p><strong>IKickAlgorithm.cfc</strong></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>cfinterface<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;kick&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span>cfinterface<span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p><strong>Kick.cfc</strong></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;">cfcomponent</span> implements<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;IKickAlgorithm&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;kick&quot;</span> <span style="color: #0000FF;">access</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;public&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  You have been kicked in the gut. Yummy.
<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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p><strong>Freezer.cfc</strong></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;">cfcomponent</span> extends<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;SuperHero&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- We are overriding the energyProject from Freezer's parent class.  ---&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;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;energyProject&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  You have been snowed on. 
<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;">cfcomponent</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Now let&#8217;s actually use these the pattern: </p>
<p><strong>run.cfm</strong></p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--- Create context object.  ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> IceMan <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;SuperHero&quot;</span> <span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span> <span style="color: #0000FF;">Name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;Iceman&quot;</span>, Gender <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;Male&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Create a strategy #1 for punching.  ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> PunchStrategy_1 <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;Punch&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Create a different strategy for punching.  ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> PunchStrategy_2 <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;PunchFreeze&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Tell the IceMan object that you'll be using the Punch Strategy #2, NOT #1.  ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> IceMan.setPunchAlgorithm<span style="color: #0000FF;">&#40;</span> PunchStrategy_2 <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Now let's create a kicking strategy... ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> KickStrategy <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;Kick&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- ... and now let's tell the IceMan object that you'll be using the Kick Strategy.  ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> IceMan.setKickAlgorithm<span style="color: #0000FF;">&#40;</span> KickStrategy <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Now let's see some action!  ---&gt;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Punch, using the strategy chosen! ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> IceMan.punchAction<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;!--- Punch, using the strategy chosen! ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> IceMan.kickAction<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Let's create another SuperHero object. ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> Frosty <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;SuperHero&quot;</span> <span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span> <span style="color: #0000FF;">Name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;Frosty the Snowman&quot;</span>, Gender <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;Unknown&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Let's inspect the objects ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">p</span><span style="color: #0000FF;">&gt;</span></span>Notice that both objects have different number of methods - only the methods they need. <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">p</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;">cfdump</span> <span style="color: #000000; font-weight: bold;">var</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#IceMan#&quot;</span> <span style="color: #0000FF;">/&gt;</span></span><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">hr</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;">cfdump</span> <span style="color: #000000; font-weight: bold;">var</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#Frosty#&quot;</span> <span style="color: #0000FF;">/&gt;</span></span><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">hr</span> <span style="color: #0000FF;">/&gt;</span></span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Let's create another SuperHero object. ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> Frostman <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;Freezer&quot;</span> <span style="color: #0000FF;">&#41;</span>.init<span style="color: #0000FF;">&#40;</span> <span style="color: #0000FF;">Name</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;Calvin Hobbes&quot;</span>, Gender <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;Male&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;">cfset</span> Frostman.energyProject<span style="color: #0000FF;">&#40;</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>You can <a href="/wp-content/uploads/2010/04/strategy-pattern-cf.zip"><strong>download all the CF code</strong></a> here with the original Visio diagram source.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;submitHeadline=Implementing+the+Strategy+Pattern+in+ColdFusion&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;title=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;title=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;title=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;bm_description=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;T=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;title=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;title=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Implementing+the+Strategy+Pattern+in+ColdFusion+@+http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/&amp;t=Implementing+the+Strategy+Pattern+in+ColdFusion" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2010/05/02/implementing-strategy-pattern-coldfusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TSQL Functions Inspired By ColdFusion&#8217;s Lists Functions</title>
		<link>http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/</link>
		<comments>http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 00:08:43 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=944</guid>
		<description><![CDATA[In my last project, there was a bit of data scrubbing on the database side (SQL Server 2008) that I decided to create a few UDF&#8217;s that function similar to ColdFusion&#8217;s Lists function. The one that varies a little bit is ListLen(), since I needed to take into account empty tokens. The ChopIf() was inspired [...]]]></description>
			<content:encoded><![CDATA[<p>In my last project, there was a bit of data scrubbing on the database side (SQL Server 2008) that I decided to create a few UDF&#8217;s that function similar to ColdFusion&#8217;s Lists function. The one that varies a little bit is ListLen(), since I needed to take into account empty tokens. The ChopIf() was inspired by Perl&#8217;s chop() function. These UDFs should be SQL Server 2005-compatible. </p>
<p>I should say though, that some of these functions depend on each other. ListLen(), GetToken(), and ChopIf() are independent.</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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Functions similarly like ColdFusion ListSort() function,</span>
<span style="color: #008080;">-- except it currently only sorts strings. </span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example 1:</span>
<span style="color: #008080;">--    dbo.ListSort( 'dan is so mega awesome that he rules all the time', 'ASC', ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    all awesome dan he is mega rules so that the time</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example 2:</span>
<span style="color: #008080;">--    dbo.ListSort( 'dan is so mega awesome that he rules all the time', 'DESC', ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    time the that so rules mega is he dan awesome all</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>ListSort<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string    <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,  
  @sort_type <span style="color: #0000FF;">CHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">3</span><span style="color: #808080;">&#41;</span>       <span style="color: #808080;">=</span> <span style="color: #FF0000;">'ASC'</span>,
  @delimiter <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">','</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">500</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
&nbsp;
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
  <span style="color: #0000FF;">DECLARE</span> @position <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">INT</span>
  <span style="color: #0000FF;">DECLARE</span> @token <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">VARCHAR</span> <span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
  <span style="color: #0000FF;">DECLARE</span> @counter   <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">INT</span>
  <span style="color: #0000FF;">DECLARE</span> @sortedList <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">500</span><span style="color: #808080;">&#41;</span>
&nbsp;
  <span style="color: #0000FF;">DECLARE</span> @sortTempTable <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#40;</span> token <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">500</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span>
  <span style="color: #0000FF;">DECLARE</span> @sortedTable   <span style="color: #0000FF;">TABLE</span> <span style="color: #808080;">&#40;</span> token <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">500</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span>  
&nbsp;
  <span style="color: #0000FF;">SELECT</span> @string   <span style="color: #808080;">=</span> @string <span style="color: #808080;">+</span> @delimiter,
         @counter  <span style="color: #808080;">=</span> <span style="color: #000;">1</span>,
         @position <span style="color: #808080;">=</span> <span style="color: #000;">0</span>,
         @token    <span style="color: #808080;">=</span> <span style="color: #FF0000;">''</span>
&nbsp;
  <span style="color: #0000FF;">WHILE</span> <span style="color: #808080;">&#40;</span> <span style="color: #FF00FF;">PATINDEX</span><span style="color: #808080;">&#40;</span> <span style="color: #FF0000;">'%'</span> <span style="color: #808080;">+</span> @delimiter <span style="color: #808080;">+</span> <span style="color: #FF0000;">'%'</span> , @string <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&lt;&gt;</span> <span style="color: #000;">0</span> <span style="color: #808080;">&#41;</span> 
  <span style="color: #0000FF;">BEGIN</span>
    <span style="color: #0000FF;">SELECT</span> @position <span style="color: #808080;">=</span> <span style="color: #FF00FF;">PATINDEX</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%'</span> <span style="color: #808080;">+</span> @delimiter <span style="color: #808080;">+</span> <span style="color: #FF0000;">'%'</span> , @string <span style="color: #808080;">&#41;</span>,
           @token    <span style="color: #808080;">=</span> <span style="color: #0000FF;">LEFT</span><span style="color: #808080;">&#40;</span> @string, @position <span style="color: #808080;">-</span> <span style="color: #000;">1</span> <span style="color: #808080;">&#41;</span>,
           @string   <span style="color: #808080;">=</span> <span style="color: #FF00FF;">STUFF</span><span style="color: #808080;">&#40;</span> @string, <span style="color: #000;">1</span>, @position, <span style="color: #808080;">NULL</span> <span style="color: #808080;">&#41;</span>,
           @counter  <span style="color: #808080;">=</span> @counter <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
&nbsp;
    <span style="color: #0000FF;">INSERT</span> @sortTempTable<span style="color: #808080;">&#40;</span> token <span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">VALUES</span><span style="color: #808080;">&#40;</span> @token <span style="color: #808080;">&#41;</span>     
  <span style="color: #0000FF;">END</span>
&nbsp;
  <span style="color: #0000FF;">SET</span> @sortedList <span style="color: #808080;">=</span> <span style="color: #FF0000;">''</span>
&nbsp;
  <span style="color: #008080;">-- Let's sort the table and put it into @sortedTable</span>
  <span style="color: #008080;">-- Because of nature of Rank(), we can't set @sortedList in this statement.</span>
  <span style="color: #008080;">-- Have to separate it into another select clause.</span>
  <span style="color: #0000FF;">INSERT</span> <span style="color: #0000FF;">INTO</span> @sortedTable
    <span style="color: #0000FF;">SELECT</span> <span style="color: #FF00FF;">LTRIM</span><span style="color: #808080;">&#40;</span> token <span style="color: #808080;">&#41;</span>
    <span style="color: #0000FF;">FROM</span>   @sortTempTable
    <span style="color: #0000FF;">ORDER</span>  <span style="color: #0000FF;">BY</span> <span style="color: #0000FF;">CASE</span> <span style="color: #0000FF;">WHEN</span> @sort_type <span style="color: #808080;">=</span> <span style="color: #FF0000;">'ASC'</span>  <span style="color: #0000FF;">THEN</span> <span style="color: #808080;">&#40;</span> RANK<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">OVER</span> <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> <span style="color: #FF00FF;">LTRIM</span><span style="color: #808080;">&#40;</span>token<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">ASC</span> <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span>
                   <span style="color: #0000FF;">WHEN</span> @sort_type <span style="color: #808080;">=</span> <span style="color: #FF0000;">'DESC'</span> <span style="color: #0000FF;">THEN</span> <span style="color: #808080;">&#40;</span> RANK<span style="color: #808080;">&#40;</span><span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">OVER</span> <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">ORDER</span> <span style="color: #0000FF;">BY</span> <span style="color: #FF00FF;">LTRIM</span><span style="color: #808080;">&#40;</span>token<span style="color: #808080;">&#41;</span> <span style="color: #0000FF;">DESC</span> <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span>
              <span style="color: #0000FF;">END</span>  
&nbsp;
  <span style="color: #0000FF;">SELECT</span> @sortedList <span style="color: #808080;">=</span> @sortedList <span style="color: #808080;">+</span> token <span style="color: #808080;">+</span> @delimiter
  <span style="color: #0000FF;">FROM</span>   @sortedTable
&nbsp;
  <span style="color: #0000FF;">RETURN</span> dbo.<span style="color: #202020;">ChopIf</span><span style="color: #808080;">&#40;</span> @sortedList, @delimiter <span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">END</span>
GO</pre></td></tr></table></div>


<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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Functions sort of like ColdFusion's ListLen() method, but it</span>
<span style="color: #008080;">-- takes into account empty tokens. </span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example 1:</span>
<span style="color: #008080;">--    dbo.ListLen( 'Dan is cool', ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    3</span>
<span style="color: #008080;">-- </span>
<span style="color: #008080;">-- Example 2:</span>
<span style="color: #008080;">--    dbo.ListLen( 'dan,,very,,,,awesome,', ',' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    8</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>ListLen<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,
  @delimiter <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">','</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">INT</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
  <span style="color: #0000FF;">DECLARE</span> @loopCount <span style="color: #0000FF;">INT</span>, 
          @tokenCount <span style="color: #0000FF;">INT</span>
&nbsp;
  <span style="color: #0000FF;">SELECT</span> @loopCount <span style="color: #808080;">=</span> <span style="color: #000;">0</span>, 
         @tokenCount <span style="color: #808080;">=</span> <span style="color: #000;">0</span>
&nbsp;
  <span style="color: #008080;">-- If it's an empty string, the list length is 0</span>
  <span style="color: #0000FF;">IF</span> DATALENGTH<span style="color: #808080;">&#40;</span> @string <span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #000;">0</span>
    <span style="color: #0000FF;">BEGIN</span>
      <span style="color: #0000FF;">SET</span> @tokenCount <span style="color: #808080;">=</span> <span style="color: #000;">0</span>
    <span style="color: #0000FF;">END</span>
  <span style="color: #0000FF;">ELSE</span>
    <span style="color: #0000FF;">BEGIN</span>
      <span style="color: #008080;">-- Count tokens, including empty ones like dan,,very,,,,awesome,</span>
      <span style="color: #0000FF;">SET</span> @tokenCount <span style="color: #808080;">=</span> @tokenCount <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
      <span style="color: #0000FF;">WHILE</span> <span style="color: #808080;">&#40;</span> @loopCount <span style="color: #808080;">&lt;</span> DATALENGTH<span style="color: #808080;">&#40;</span> @string <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span>
      <span style="color: #0000FF;">BEGIN</span>
        <span style="color: #0000FF;">IF</span> <span style="color: #FF00FF;">SUBSTRING</span><span style="color: #808080;">&#40;</span> @string, @loopCount, DATALENGTH<span style="color: #808080;">&#40;</span> @delimiter <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> @delimiter
          <span style="color: #0000FF;">BEGIN</span>
            <span style="color: #0000FF;">SET</span> @tokenCount <span style="color: #808080;">=</span> @tokenCount <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
          <span style="color: #0000FF;">END</span>
        <span style="color: #0000FF;">SET</span> @loopCount <span style="color: #808080;">=</span> @loopCount <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
      <span style="color: #0000FF;">END</span>
    <span style="color: #0000FF;">END</span>
&nbsp;
  <span style="color: #008080;">-- Handle extra count from space being delimiter</span>
  <span style="color: #0000FF;">IF</span> @delimiter <span style="color: #808080;">=</span> <span style="color: #FF0000;">' '</span>
    <span style="color: #0000FF;">SET</span> @tokenCount <span style="color: #808080;">=</span> @tokenCount <span style="color: #808080;">-</span> <span style="color: #000;">1</span>
&nbsp;
  <span style="color: #008080;">-- If there's no token to the right of the last delimiter, then count that</span>
  <span style="color: #008080;">-- as an empty token.</span>
  <span style="color: #0000FF;">IF</span> <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">RIGHT</span><span style="color: #808080;">&#40;</span> @string, <span style="color: #000;">1</span> <span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> @delimiter <span style="color: #808080;">&#41;</span> 
  <span style="color: #0000FF;">BEGIN</span>
    <span style="color: #0000FF;">SET</span> @tokenCount <span style="color: #808080;">=</span> @tokenCount <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
  <span style="color: #0000FF;">END</span>
&nbsp;
  <span style="color: #0000FF;">RETURN</span> @tokenCount
&nbsp;
<span style="color: #0000FF;">END</span>
GO</pre></td></tr></table></div>


<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
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Functions like ColdFusion's ListLast()</span>
<span style="color: #008080;">-- Gets token value that's been separated by a delimiter.</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example:</span>
<span style="color: #008080;">--    dbo.ListLast( 'Dan is cool', ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    cool</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>ListLast<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,
  @delimiter <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">','</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
  <span style="color: #0000FF;">RETURN</span> dbo.<span style="color: #202020;">ListGetAt</span><span style="color: #808080;">&#40;</span> @string, dbo.<span style="color: #202020;">ListLen</span><span style="color: #808080;">&#40;</span> @string, @delimiter <span style="color: #808080;">&#41;</span> , @delimiter  <span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">END</span>
GO</pre></td></tr></table></div>


<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
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Wrapper for GetToken() Function</span>
<span style="color: #008080;">-- Gets token value that's been separated by a delimiter.</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example:</span>
<span style="color: #008080;">--    dbo.ListGetAt( 'Dan is cool', 2, ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    is</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>ListGetAt<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,
  @token <span style="color: #0000FF;">INT</span>,
  @delimiter <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">BEGIN</span>
  <span style="color: #0000FF;">RETURN</span> dbo.<span style="color: #202020;">GetToken</span><span style="color: #808080;">&#40;</span> @string, @token, @delimiter <span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">END</span>
GO</pre></td></tr></table></div>


<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
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Returns the first item in a tokenized list.</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example:</span>
<span style="color: #008080;">--    dbo.ListFirst( 'Dan is cool', ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    Dan</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>ListFirst<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,
  @delimiter <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> <span style="color: #FF0000;">','</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
  <span style="color: #0000FF;">RETURN</span> dbo.<span style="color: #202020;">ListGetAt</span><span style="color: #808080;">&#40;</span> @string, <span style="color: #000;">1</span>, @delimiter <span style="color: #808080;">&#41;</span>
&nbsp;
<span style="color: #0000FF;">END</span>
GO</pre></td></tr></table></div>


<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
32
33
34
35
36
37
38
39
40
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Functions similarly like ColdFusion GetToken() Function.</span>
<span style="color: #008080;">-- Gets token value that's been separated by a delimiter.</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example:</span>
<span style="color: #008080;">--    dbo.GetToken( 'Dan is cool', 2, ' ' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    is</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>GetToken<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,
  @tokenPosition <span style="color: #0000FF;">INT</span>,
  @delimiter <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
  <span style="color: #0000FF;">DECLARE</span> @position <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">INT</span>
  <span style="color: #0000FF;">DECLARE</span> @token <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">VARCHAR</span> <span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
  <span style="color: #0000FF;">DECLARE</span> @counter <span style="color: #0000FF;">AS</span> <span style="color: #0000FF;">INT</span>
&nbsp;
  <span style="color: #0000FF;">SELECT</span> @string <span style="color: #808080;">=</span> @string <span style="color: #808080;">+</span> @delimiter,
         @counter <span style="color: #808080;">=</span> <span style="color: #000;">1</span>,
         @position <span style="color: #808080;">=</span> <span style="color: #000;">0</span>,
         @token <span style="color: #808080;">=</span> <span style="color: #FF0000;">''</span>
&nbsp;
  <span style="color: #0000FF;">WHILE</span> <span style="color: #808080;">&#40;</span> <span style="color: #FF00FF;">PATINDEX</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%'</span> <span style="color: #808080;">+</span> @delimiter <span style="color: #808080;">+</span> <span style="color: #FF0000;">'%'</span> , @string <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&lt;&gt;</span> <span style="color: #000;">0</span><span style="color: #808080;">&#41;</span> <span style="color: #808080;">AND</span> <span style="color: #808080;">&#40;</span> @tokenPosition <span style="color: #808080;">+</span> <span style="color: #000;">1</span> <span style="color: #808080;">&lt;&gt;</span> @counter <span style="color: #808080;">&#41;</span>
  <span style="color: #0000FF;">BEGIN</span>
    <span style="color: #0000FF;">SELECT</span> @position <span style="color: #808080;">=</span> <span style="color: #FF00FF;">PATINDEX</span><span style="color: #808080;">&#40;</span><span style="color: #FF0000;">'%'</span> <span style="color: #808080;">+</span> @delimiter <span style="color: #808080;">+</span> <span style="color: #FF0000;">'%'</span> , @string<span style="color: #808080;">&#41;</span>,
           @token    <span style="color: #808080;">=</span> <span style="color: #0000FF;">LEFT</span><span style="color: #808080;">&#40;</span>@string, @position<span style="color: #808080;">-</span><span style="color: #000;">1</span><span style="color: #808080;">&#41;</span>,
           @string   <span style="color: #808080;">=</span> <span style="color: #FF00FF;">STUFF</span><span style="color: #808080;">&#40;</span>@string, <span style="color: #000;">1</span>, @position, null<span style="color: #808080;">&#41;</span>,
           @counter  <span style="color: #808080;">=</span> @counter <span style="color: #808080;">+</span> <span style="color: #000;">1</span>
  <span style="color: #0000FF;">END</span>
&nbsp;
  <span style="color: #0000FF;">RETURN</span> @token
<span style="color: #0000FF;">END</span></pre></td></tr></table></div>


<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
</pre></td><td class="code"><pre class="tsql" style="font-family:monospace;"><span style="color: #008080;">------------------------------------------------------------------</span>
<span style="color: #008080;">-- Chops the last character if it's @chopped</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Example:</span>
<span style="color: #008080;">--    dbo.ChopIf( 'Dan is cool!', '!' )</span>
<span style="color: #008080;">--</span>
<span style="color: #008080;">-- Returns: </span>
<span style="color: #008080;">--    Dan is cool</span>
<span style="color: #008080;">------------------------------------------------------------------</span>
&nbsp;
<span style="color: #0000FF;">CREATE</span> <span style="color: #0000FF;">FUNCTION</span> <span style="color: #808080;">&#91;</span>dbo<span style="color: #808080;">&#93;</span>.<span style="color: #808080;">&#91;</span>ChopIf<span style="color: #808080;">&#93;</span>
<span style="color: #808080;">&#40;</span>
  @string <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>,
  @chopped <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">RETURNS</span> <span style="color: #0000FF;">VARCHAR</span><span style="color: #808080;">&#40;</span><span style="color: #000;">2000</span><span style="color: #808080;">&#41;</span>
<span style="color: #0000FF;">AS</span>
<span style="color: #0000FF;">BEGIN</span>
&nbsp;
  <span style="color: #0000FF;">IF</span> <span style="color: #808080;">&#40;</span> <span style="color: #0000FF;">RIGHT</span><span style="color: #808080;">&#40;</span> @string, DATALENGTH<span style="color: #808080;">&#40;</span>@chopped<span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span> <span style="color: #808080;">=</span> @chopped <span style="color: #808080;">&#41;</span>
  <span style="color: #0000FF;">BEGIN</span>
    <span style="color: #0000FF;">SET</span> @string <span style="color: #808080;">=</span> <span style="color: #0000FF;">LEFT</span><span style="color: #808080;">&#40;</span> @string, DATALENGTH<span style="color: #808080;">&#40;</span> @string <span style="color: #808080;">&#41;</span> <span style="color: #808080;">-</span> DATALENGTH<span style="color: #808080;">&#40;</span> @chopped <span style="color: #808080;">&#41;</span> <span style="color: #808080;">&#41;</span> 
  <span style="color: #0000FF;">END</span> 
&nbsp;
  <span style="color: #0000FF;">RETURN</span> @string
&nbsp;
<span style="color: #0000FF;">END</span>
GO</pre></td></tr></table></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;submitHeadline=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;title=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;title=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;title=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;bm_description=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;T=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;title=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;title=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions+@+http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/&amp;t=TSQL+Functions+Inspired+By+ColdFusion%26%238217%3Bs+Lists+Functions" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2010/04/27/tsql-functions-inspired-by-coldfusions-lists-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>IsNumericList() Function</title>
		<link>http://www.shinylight.com/2010/04/03/isnumericlist-function/</link>
		<comments>http://www.shinylight.com/2010/04/03/isnumericlist-function/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 22:59:41 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=912</guid>
		<description><![CDATA[Whipped up this UDF while working on a project. It checks to see if the list is valid to use in a TSQL WHERE IN Clause. I wanted to check for a list of valid positive integers (including 0), ignoring spaces.

&#60;cffunction name=&#34;isNumericList&#34; returntype=&#34;boolean&#34; hint=&#34;Check for either single positive number or a set of positive numbers. [...]]]></description>
			<content:encoded><![CDATA[<p>Whipped up this UDF while working on a project. It checks to see if the list is valid to use in a TSQL WHERE IN Clause. I wanted to check for a list of valid positive integers (including 0), ignoring spaces.</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;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;isNumericList&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;boolean&quot;</span> <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Check for either single positive number or a set of positive numbers. Spaces ignored.&quot;</span> <span style="color: #0000FF;">&gt;</span></span>
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!--- Useful when inserting into an &quot;IN&quot; TSQL list in the WHERE clause.  ---&gt;</span>
&nbsp;
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;list&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&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;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;delimiter&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000FF;">default</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> <span style="color: #000000; font-weight: bold;">var</span> isNumericList <span style="color: #0000FF;">=</span> false <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;">cfif</span> <span style="color: #0000FF;">REFind</span><span style="color: #0000FF;">&#40;</span> <span style="color: #009900;">&quot;^(<span style="color: #000099; font-weight: bold;">\d</span>+)$|^(([<span style="color: #000099; font-weight: bold;">\d</span><span style="color: #000099; font-weight: bold;">\s</span>]+#Arguments.delimiter#)+<span style="color: #000099; font-weight: bold;">\s</span>*<span style="color: #000099; font-weight: bold;">\d</span>+)$&quot;</span>, <span style="color: #0000FF;">Trim</span><span style="color: #0000FF;">&#40;</span>Arguments.<span style="color: #0000FF;">list</span><span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">&#41;</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;">cfreturn</span> true <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;">cfif</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;">cfreturn</span> isNumericList <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></div></div>

<p>Now let&#8217;s test it!</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--- Dummy Data ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> dataList <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">ArrayNew</span><span style="color: #0000FF;">&#40;</span><span style="color: #FF0000;">1</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;">cfset</span> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">1</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;456c&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">2</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;456&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">3</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;45c,&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">4</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;5,,,&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">5</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;565,651,34,643232,45&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">6</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;454,c,45,5454,32&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">7</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;121.45,43,565,1,1,2&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">8</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;43,54,65,1,&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">9</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;67,54,73,436,&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">10</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;,6565,656,77,32,3&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">11</span><span style="color: #0000FF;">&#93;</span> <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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">12</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;,43656&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> dataList<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">13</span><span style="color: #0000FF;">&#93;</span> <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;4365,  55,31,24,   5,   5  ,1,      34&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>Now let&#8217;s use it!</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--- Use it! ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfoutput</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> array<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#dataList#&quot;</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;i&quot;</span><span style="color: #0000FF;">&gt;</span></span>  
      [<span style="color: #0000FF;">#i#</span>] =&gt; <span style="color: #0000FF;">#isNumericList<span style="color: #0000FF;">&#40;</span>i<span style="color: #0000FF;">&#41;</span>#</span><span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">br</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>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Results!</p>

<div class="wp_syntax"><div class="code"><pre class="txt" style="font-family:monospace;">[456c] =&gt; false
&nbsp;
[456] =&gt; true
&nbsp;
[45c,] =&gt; false
&nbsp;
[5,,,] =&gt; false
&nbsp;
[565,651,34,643232,45] =&gt; true
&nbsp;
[454,c,45,5454,32] =&gt; false
&nbsp;
[121.45,43,565,1,1,2] =&gt; false
&nbsp;
[43,54,65,1,] =&gt; false
&nbsp;
[67,54,73,436,] =&gt; false
&nbsp;
[,6565,656,77,32,3] =&gt; false
&nbsp;
[] =&gt; false
&nbsp;
[,43656] =&gt; false
&nbsp;
[4365,  55,31,24,   5,   5  ,1,      34] =&gt; true</pre></div></div>

<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;submitHeadline=IsNumericList%28%29+Function&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;title=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;title=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2010/04/03/isnumericlist-function/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;title=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;bm_description=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;T=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;title=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;title=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2010/04/03/isnumericlist-function/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2010/04/03/isnumericlist-function/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+IsNumericList%28%29+Function+@+http://www.shinylight.com/2010/04/03/isnumericlist-function/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2010/04/03/isnumericlist-function/&amp;t=IsNumericList%28%29+Function" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2010/04/03/isnumericlist-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert Relative URLs to Absolute</title>
		<link>http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/</link>
		<comments>http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 04:29:02 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=874</guid>
		<description><![CDATA[I put this ColdFusion UDF together the other day to turn relative URLs to Absolute. Code is pretty straightforward.

&#60;cffunction name=&#34;URLRelativeToAbsolute&#34; returntype=&#34;string&#34;
  hint=&#34;Converts relative URLs in an element and converts to absolute. It includes the http:// protocol prefix.&#34;&#62;  
&#160;
  &#60;cfargument name=&#34;content&#34; type=&#34;string&#34; required=&#34;true&#34; hint=&#34;HTML content that will be scanned and replaced.&#34; /&#62;
&#160;
  [...]]]></description>
			<content:encoded><![CDATA[<p>I put this ColdFusion UDF together the other day to turn relative URLs to Absolute. Code is pretty straightforward.</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;">cffunction</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;URLRelativeToAbsolute&quot;</span> returntype<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span></span>
<span style="color: #333333;">  <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Converts relative URLs in an element and converts to absolute. It includes the http:// protocol prefix.&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;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;content&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;HTML content that will be scanned and replaced.&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;">cfargument</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;domain&quot;</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000FF;">required</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000FF;">hint</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;Add domain name to relative links.&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> 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> 
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!--- The following regexp handles the following elements: link, a, img, script, form, frame. ---&gt;</span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> local.contentFixed <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">REReplaceNoCase</span><span style="color: #0000FF;">&#40;</span> Arguments.<span style="color: #0000FF;">content</span>, <span style="color: #009900;">&quot;(href|src|action)=&quot;</span><span style="color: #009900;">&quot;/?((<span style="color: #000099; font-weight: bold;">\.</span>/)|(<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\.</span>/)+|)(?=[^http])&quot;</span>, <span style="color: #009900;">&quot;<span style="color: #000099; font-weight: bold;">\1</span>=&quot;</span><span style="color: #009900;">&quot;http://&quot;</span> <span style="color: #0000FF;">&amp;</span> domain <span style="color: #0000FF;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span>, <span style="color: #009900;">&quot;all&quot;</span> <span style="color: #0000FF;">&#41;</span> <span style="color: #0000FF;">/&gt;</span></span>  
&nbsp;
  <span style="color: #808080; font-style: italic;">&lt;!--- The following regexp handles the url() attribute of the background CSS property. ---&gt;</span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfset</span> local.contentFixed <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">REReplaceNoCase</span><span style="color: #0000FF;">&#40;</span> local.contentFixed, <span style="color: #009900;">&quot;url<span style="color: #000099; font-weight: bold;">\(</span>(<span style="color: #000099; font-weight: bold;">\s</span>)?(')?/?((<span style="color: #000099; font-weight: bold;">\.</span>/)|(<span style="color: #000099; font-weight: bold;">\.</span><span style="color: #000099; font-weight: bold;">\.</span>/)+|)(?=[^http])&quot;</span>, <span style="color: #009900;">&quot;url(<span style="color: #000099; font-weight: bold;">\2</span>http://&quot;</span> <span style="color: #0000FF;">&amp;</span> domain <span style="color: #0000FF;">&amp;</span> <span style="color: #009900;">&quot;/&quot;</span>, <span style="color: #009900;">&quot;all&quot;</span> <span style="color: #0000FF;">&#41;</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;">cfreturn</span> local.contentFixed <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></div></div>

<p>Usage:</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;">cfsavecontent</span> variable<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;htmlContent&quot;</span><span style="color: #0000FF;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">textarea</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;data&quot;</span> <span style="color: #0000FF;">rows</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;20&quot;</span> <span style="color: #0000FF;">cols</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;60&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">style</span><span style="color: #0000FF;">&gt;</span></span>
    body { 
      background-image:url('stars.png');
      background-image:url('../stars.png');
      background-image:url('/stars.png');
      background-image:url('/../../../stars.png');
    }
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">style</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">a</span> <span style="color: #0000FF;">href</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;../../../images/shiny.jpg&quot;</span><span style="color: #0000FF;">&gt;</span></span>Shiny<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">a</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">a</span> <span style="color: #0000FF;">href</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;http://www.google.com&quot;</span><span style="color: #0000FF;">&gt;</span></span>This should not be touched<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">a</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">img</span> <span style="color: #0000FF;">border</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;0&quot;</span> <span style="color: #0000FF;">src</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;/images/cool.png&quot;</span> <span style="color: #0000FF;">/&gt;</span></span> 
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">link</span> <span style="color: #0000FF;">rel</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;index&quot;</span> <span style="color: #0000FF;">href</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;../../index.asp&quot;</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">form</span> <span style="color: #0000FF;">method</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;POST&quot;</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;cgi/processing.cgi&quot;</span><span style="color: #0000FF;">&gt;</span></span><span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">form</span><span style="color: #0000FF;">&gt;</span></span>  
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">textarea</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;">cfsavecontent</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;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
  <span style="color: #0000FF;">#htmlContent#</span>
  #URLRelativeToAbsolute( htmlContent, &quot;www.shinylight.com&quot; )#
&nbsp;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>Result:</p>
<p><img src="http://www.shinylight.com/wp-content/uploads/2010/02/before-after1.png" /></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;submitHeadline=Convert+Relative+URLs+to+Absolute&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;title=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;title=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;title=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;bm_description=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;T=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;title=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;title=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Convert+Relative+URLs+to+Absolute+@+http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/&amp;t=Convert+Relative+URLs+to+Absolute" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2010/02/19/convert-relative-urls-to-absolute/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read OPML File</title>
		<link>http://www.shinylight.com/2010/01/03/read-opml-file/</link>
		<comments>http://www.shinylight.com/2010/01/03/read-opml-file/#comments</comments>
		<pubDate>Sat, 02 Jan 2010 17:26:36 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=644</guid>
		<description><![CDATA[Whipped out this little script to read an OPML file from Google Reader. Thought it may be handy.

&#60;cfset GoogleOPMLFile = &#34;C:/google-reader-subscriptions.xml&#34; /&#62;
&#160;
&#60;cffile action=&#34;READ&#34; variable=&#34;xml&#34; file=&#34;#GoogleOPMLFile#&#34; /&#62; 
&#160;
&#60;cfset xmlDoc = XMLParse&#40;xml&#41; /&#62; 
&#160;
&#60;cfset StartingDataNode = 2 /&#62;
&#160;
&#60;cfset Categories = ArrayLen&#40; xmlDoc.opml.xmlChildren&#91;2&#93;.XmlChildren &#41; /&#62;
&#160;
&#60;cfoutput&#62;
&#160;
&#60;cfloop index=&#34;i&#34; from=&#34;2&#34; to=&#34;#Categories#&#34;&#62;
&#160;
  &#60;strong&#62;#xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlAttributes.Title#&#60;/strong&#62;
  &#60;ul&#62;
  &#60;cfloop index=&#34;j&#34; from=&#34;1&#34; to=&#34;#ArrayLen( xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlChildren [...]]]></description>
			<content:encoded><![CDATA[<p>Whipped out this little script to read an OPML file from Google Reader. Thought it may be handy.</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> GoogleOPMLFile <span style="color: #0000FF;">=</span> <span style="color: #009900;">&quot;C:/google-reader-subscriptions.xml&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;">cffile</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;READ&quot;</span> variable<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;xml&quot;</span> file<span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#GoogleOPMLFile#&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> xmlDoc <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">XMLParse</span><span style="color: #0000FF;">&#40;</span>xml<span style="color: #0000FF;">&#41;</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> StartingDataNode <span style="color: #0000FF;">=</span> <span style="color: #FF0000;">2</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> Categories <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">ArrayLen</span><span style="color: #0000FF;">&#40;</span> xmlDoc.opml.xmlChildren<span style="color: #0000FF;">&#91;</span><span style="color: #FF0000;">2</span><span style="color: #0000FF;">&#93;</span>.XmlChildren <span style="color: #0000FF;">&#41;</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;">cfoutput</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;">cfloop</span> <span style="color: #0000FF;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;i&quot;</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;2&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#Categories#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
&nbsp;
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">strong</span><span style="color: #0000FF;">&gt;</span></span>#xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlAttributes.Title#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">strong</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">ul</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;">index</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;j&quot;</span> <span style="color: #0000FF;">from</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;1&quot;</span> <span style="color: #0000FF;">to</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#ArrayLen( xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlChildren )#&quot;</span><span style="color: #0000FF;">&gt;</span></span>      	    
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">li</span><span style="color: #0000FF;">&gt;</span></span>
      <span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">a</span> <span style="color: #0000FF;">href</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlChildren[j].XmlAttributes.htmlURL#&quot;</span><span style="color: #0000FF;">&gt;</span></span>
      #xmlDoc.opml.xmlChildren[StartingDataNode].XmlChildren[i].XmlChildren[j].XmlAttributes.title#<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">a</span><span style="color: #0000FF;">&gt;</span></span>
    <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">li</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>
  <span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #000000; font-weight: bold;">ul</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;">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;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>The code will display as follows:</p>
<p><a href="http://www.shinylight.com/wp-content/uploads/2010/01/map.jpg"><img src="http://www.shinylight.com/wp-content/uploads/2010/01/map.jpg" alt="" title="map" width="417" height="439" class="alignnone size-full wp-image-652" /></a></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;submitHeadline=Read+OPML+File&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;title=Read+OPML+File" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;title=Read+OPML+File" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2010/01/03/read-opml-file/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;title=Read+OPML+File" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;bm_description=Read+OPML+File" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;T=Read+OPML+File" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;title=Read+OPML+File" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;title=Read+OPML+File" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2010/01/03/read-opml-file/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2010/01/03/read-opml-file/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Read+OPML+File+@+http://www.shinylight.com/2010/01/03/read-opml-file/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2010/01/03/read-opml-file/&amp;t=Read+OPML+File" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2010/01/03/read-opml-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Asynchronous Upload to Amazon S3 (S3)</title>
		<link>http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/</link>
		<comments>http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 23:25:50 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Databases]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Virtualization]]></category>
		<category><![CDATA[Web Browsers]]></category>
		<category><![CDATA[Web Design]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=1115</guid>
		<description><![CDATA[Requirements
Make sure you have an Amazon S3 Account (get it from tech). JavaScript is mandatory for this to work (to be able to POST to two different domains) upon user submission.
Summary of Problem
This is a summary outlining the solution used in a video uploader. It entailed a form that would leverage the user of our [...]]]></description>
			<content:encoded><![CDATA[<h3>Requirements</h3>
<p>Make sure you have an Amazon S3 Account (get it from tech). JavaScript is mandatory for this to work (to be able to POST to two different domains) upon user submission.</p>
<h3>Summary of Problem</h3>
<p>This is a summary outlining the solution used in a video uploader. It entailed a form that would leverage the user of our Amazon S3 (S3) account. In addition, because the video files could be large (and to avoid CF limitations), a critical requirement was to upload to that page S3 directly. At the same time, the form field information had to be saved to our database. This meant doing a double post – one to the XYZ domain, and the other to s3.amazon.com. This cross-domain POST could only be done via AJAX.</p>
<p>Here’s visualization:</p>
<p style="text-align: center;"><img class="size-full wp-image-1117 aligncenter" title="image001" src="http://www.shinylight.com/wp-content/uploads/2011/07/image0011-e1312062873641.png" alt="" width="500" height="268" /></p>
<p>As you can see, once the user clicks “Submit”, there’s an AJAX HTTP POST to XZY server to save the fields to the database, and then the JavaScript runs a form.submit() on the current form to submit the file via POST to S3.</p>
<h3>Introducing Amazon S3</h3>
<p>Amazon S3 (Simple Storage Service) is a cloud service whose sole purpose is to store files. To store files into it, one can use its REST API or Admin Web Console (AWS).</p>
<p style="text-align: center;"><img class="size-full wp-image-1119 aligncenter" title="image002" src="http://www.shinylight.com/wp-content/uploads/2011/07/image002-e1312063033864.png" alt="" width="550" height="320" /></p>
<p>Screenshot of the AWS console, with Amazon S3 tab selected.</p>
<p>One gets to the AWS console via an account (can get it from tech) and going to <a href="http://aws.amazon.com/s3/">http://aws.amazon.com/s3/</a> and clicking “Sign in.”</p>
<p>While S3 has many advantages, there are a set of drawbacks as well. To summarize, here’s a list:</p>
<p><strong>Benefits:</strong></p>
<ul>
<li>The max upload size for a file is 5GB. Plenty.</li>
<li>For all the times I’ve tested, uploads of different file sizes, everything has gone super smoothly – like butter – so definitely reliable.</li>
<li>Amazon is super scalable (as you may already know), so parallel uploading from one or many users is really no problem.</li>
<li>Would not affect performance of our servers &#8211; there could be many uploads, and they would go fast, without slowing down any other web sites on servers.</li>
<li>The speed of the upload is limited to the user’s computer’s specs and internet provider – much faster than our servers.</li>
<li>Files can be made secure and unreadable, not just through obscurity – this is sometimes tricky to implement in ColdFusion.</li>
</ul>
<p><strong>Drawbacks:</strong></p>
<p>To summarize, the reason for some of the drawbacks, is because it’s doing a POST request directly from one domain (us) to another (s3.amazonaws.com). It’s not being channeled through our CF servers.</p>
<p>There are two ways to interact with S3: the REST API, and doing a direct POST. With the REST API, the upload data has to be channeled through a server first before sending to Amazon – this was not what we were looking for, since our servers have issues with large files. So we looked into removing ourselves as the middleman and sending the data directly to S3 – via POST.</p>
<p>Here are the drawbacks, mainly three:</p>
<ul>
<li><strong>If S3 detected an error in the upload</strong>, e.g. if the file is too large, there’s no default error page, just a redirect to an XML document hosted on s3.amazonaws.com. There’s no way to set an error page – it’s on Amazon’s to-do list for future release. One can’t even customize the look and feel of the XML document you’re redirected to. Side note: if the upload was successful, it gets redirected to a page you specify (at least there’s some control here).</li>
<li><strong>Progress bar reusable code is scare</strong>. There’s tons of code out there to do this, however, I could not find one that could cross-domain post. With traditional AJAX, you’re only allowed to do a POST/GET if the URL you’re using is the same domain as the caller page. One could get the code for a progress bar plugin (as there are tons out there) and rewrite it to do a POST and work with Amazon S3 – but that would take a considerate amount of work.</li>
<li><strong>Lack of documentation</strong>. There’s not enough documentation for handling POST requests in the official Amazon Developer docs, which makes troubleshooting difficult. Doing POST submits is a relatively new feature of Amazon S3, compared to the rest of their APIs.</li>
</ul>
<p>So the <strong>largest hurdle is to code functionality to get around the error page</strong>, since some JavaScript magic has to be put in place. That would be another day or so of work just for that, I believe. I already have some code in place that I put together while testing. If we left it as-is, when the user uploads, and if there was an error, the user would see something like this:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image003.png"><img class="size-full wp-image-1120 aligncenter" title="image003" src="http://www.shinylight.com/wp-content/uploads/2011/07/image003-e1312063292511.png" alt="" width="550" height="101" /></a></p>
<p>Which would, of course, be nonsensical. If the file was too large, they would see a message that the file was too large within the message tags. The user would then have to hit back to return to the form.</p>
<p><strong>We can try another way, probably the easiest.</strong> When the user hits submits, it starts showing the animated spinner as it’s uploading. Also, we can tell the user that if he encounters an error page, just hit the back button. Also, keep in mind that there’ll be validation in place before the upload to check for file extension, at the very least. The only edge case to seeing that XML error message is if the file they submitted is over the limit *AND*  they have JavaScript turned off (that overrides the JavaScript file extension validation).</p>
<h3>Creating a Basic HTML that POSTs a File to Amazon</h3>
<p><strong>Step 1 – Create a Bucket / Folder / Object:</strong><br />
The first thing we need to do a is create a Bucket on S3. To do this the easy way, go to the AWS: <a href="https://console.aws.amazon.com/s3/home">https://console.aws.amazon.com/s3/home</a> and create a bucket:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image004.png"><img class="size-full wp-image-1121 aligncenter" title="image004" src="http://www.shinylight.com/wp-content/uploads/2011/07/image004.png" alt="" width="323" height="293" /></a></p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image005.png"><img class="size-full wp-image-1122 aligncenter" title="image005" src="http://www.shinylight.com/wp-content/uploads/2011/07/image005.png" alt="" width="355" height="290" /></a></p>
<p>Buckets are where you store your objects (i.e. your files of any format). You can create a folder for further organization:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image006.png"><img class="size-full wp-image-1123 aligncenter" title="image006" src="http://www.shinylight.com/wp-content/uploads/2011/07/image006.png" alt="" width="323" height="235" /></a></p>
<p>As you can see here, there are 4 folders here. We can double-click on step1_new_submissions folder and see the objects that are contained within this:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image007.png"><img class="size-full wp-image-1126 aligncenter" title="image007" src="http://www.shinylight.com/wp-content/uploads/2011/07/image007-e1312064739309.png" alt="" width="550" height="323" /></a></p>
<p>You can right-click on one of those objects (files) and click “Properties”:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image008.png"><img class="size-full wp-image-1127 aligncenter" title="image008" src="http://www.shinylight.com/wp-content/uploads/2011/07/image008.png" alt="" width="358" height="368" /></a></p>
<p>Notice that a Properties panel will expand below. To the right, you have three tabs: Details, Permissions, Metadata.</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image009.png"><img class="size-full wp-image-1128 aligncenter" title="image009" src="http://www.shinylight.com/wp-content/uploads/2011/07/image009-e1312064944102.png" alt="" width="570" height="242" /></a></p>
<p>If you click on the Permissions Tab you’ll notice that by default the file that was selected has following permissions set by user USERNAME:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image010.png"><img class="size-full wp-image-1129 aligncenter" title="image010" src="http://www.shinylight.com/wp-content/uploads/2011/07/image010.png" alt="" width="471" height="117" /></a></p>
<p>Go back to the details tab and click on the Link:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image011.png"><img class="size-full wp-image-1130 aligncenter" title="image011" src="http://www.shinylight.com/wp-content/uploads/2011/07/image011-e1312065059548.png" alt="" width="550" height="108" /></a></p>
<p>You’ll notice that you’ll be taken to an XML document in your browser that has the following:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image012.png"><img class="size-full wp-image-1131 aligncenter" title="image012" src="http://www.shinylight.com/wp-content/uploads/2011/07/image012.png" alt="" width="554" height="168" /></a></p>
<p>It’s because you have not let it public access. To give it public access, you click on the Permissions tab again, and click “Add more permissions” , set the Grantee to “Everyone” and choose Open/Download and Save.</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image013.png"><img class="size-full wp-image-1132 aligncenter" title="image013" src="http://www.shinylight.com/wp-content/uploads/2011/07/image013-e1312065139338.png" alt="" width="550" height="172" /></a></p>
<p>You can also set the make multiple objects public. Select an object, hold the SHIFT key, then select the other object to select the objects in between. Select “Make Public”:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image014.png"><img class="size-full wp-image-1133 aligncenter" title="image014" src="http://www.shinylight.com/wp-content/uploads/2011/07/image014.png" alt="" width="407" height="347" /></a></p>
<p>You can also upload an object manually via the “Upload” button:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image015.png"><img class="size-full wp-image-1134 aligncenter" title="image015" src="http://www.shinylight.com/wp-content/uploads/2011/07/image015.png" alt="" width="319" height="65" /></a></p>
<p>Then click “Add more files”</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image016.png"><img class="size-full wp-image-1135 aligncenter" title="image016" src="http://www.shinylight.com/wp-content/uploads/2011/07/image016.png" alt="" width="541" height="381" /></a></p>
<p>As the file starts uploading, you’ll see the bottom panel show details about the file transfer:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image017.png"><img class="size-full wp-image-1136 aligncenter" title="image017" src="http://www.shinylight.com/wp-content/uploads/2011/07/image017.png" alt="" width="484" height="131" /></a></p>
<h3>Step 2: Setting up the HTML Form</h3>
<p>The S3 REST API is very flexible, as long as you execute the proper method from your application, while at the same time sending the file over from your server to S3 (via a REST method with the correct URI). Traditionally, it would look like this:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image018.png"><img class="size-full wp-image-1137 aligncenter" title="image018" src="http://www.shinylight.com/wp-content/uploads/2011/07/image018.png" alt="" width="205" height="437" /></a></p>
<p>Notice how there’s a middle-man that serves as the captor of the data submitted by the form and the file. Then, it sends it long to S3. The middle-man here is crucial. Double the total bandwidth is spent here – the bandwidth to go from the user’s machine to the web server (in this case CF), and then the bandwidth spent transferring the file to S3.</p>
<p>The advantage to this layout is that because the web server acts as a middle-man server, it can modify the data, change its filename, and slice-and-dice anything within the file because the file submitted has to go through it first. Once the middle-man is done, then it sends it to the S3. Drawback is that there’s wasted resources from the middle-man, not to mention there may be limitations on the middle-man to handle large files &gt; 1GB .</p>
<p>As a solution, S3 has a POST method solution where you can POST the file directly to S3:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image019.png"><img class="size-full wp-image-1138 aligncenter" title="image019" src="http://www.shinylight.com/wp-content/uploads/2011/07/image019.png" alt="" width="241" height="443" /></a></p>
<h3>Setting up the Form tag</h3>
<p>Let’s see how we can cross-domain (a domain other than ours) to S3. Rather than doing the following (to post to the same domain):</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span>”#CGI.SCRIPT_NAME#” <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span>”post” <span style="color: #000066;">enctype</span><span style="color: #66cc66;">=</span>”multipart<span style="color: #66cc66;">/</span>form-<span style="color: #000066;">data</span>”&gt;</span></pre></div></div>

<p>We do the following:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">form</span> <span style="color: #000066;">action</span><span style="color: #66cc66;">=</span>”http:<span style="color: #66cc66;">//</span>s3.amazonaws.com<span style="color: #66cc66;">/</span>PastaVideos” <span style="color: #000066;">method</span><span style="color: #66cc66;">=</span>”post” <span style="color: #000066;">enctype</span><span style="color: #66cc66;">=</span>”multipart<span style="color: #66cc66;">/</span>form-<span style="color: #000066;">data</span>”&gt;</span></pre></div></div>

<p>Where “PastaVideos” is the name of the bucket.</p>
<p>The format of the object URI is as follows:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image020.png"><img class="size-full wp-image-1139 aligncenter" title="image020" src="http://www.shinylight.com/wp-content/uploads/2011/07/image020-e1312065390896.png" alt="" width="550" height="127" /></a></p>
<h3>Step 3: Setting up the Other Form Fields</h3>
<p>This is where things get interesting. In order to set up an HTML form that can upload straight to S3, there’s a set of required input fields in the form. They are as follows:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/11.png"><img class="size-full wp-image-1154 aligncenter" title="1" src="http://www.shinylight.com/wp-content/uploads/2011/07/11-e1312066815159.png" alt="" width="550" height="827" /></a><br />
<a href="http://www.shinylight.com/wp-content/uploads/2011/07/2.png"><img class="alignnone size-full wp-image-1155" title="2" src="http://www.shinylight.com/wp-content/uploads/2011/07/2-e1312066868306.png" alt="" width="550" height="390" /></a></p>
<h3>Optional Form Fields</h3>
<p><span style="text-decoration: underline;"><strong>IMPORTANT</strong></span>: If you add any other additional form fields, it will throw an error. If there is in fact a need to add extra form fields, which will be pasted to another server, then you must append the prefix “x-ignore-“. Let’s say for example I have three input fields I want S3 to ignore, then do as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;x-ignore-lastname&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;2&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;textfield&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;x-ignore-address1&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;3&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;textfield&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;x-ignore-address2&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;textfield&quot;</span>&gt;</span>
<span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">input</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text&quot;</span> <span style="color: #000066;">name</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;x-ignore-city&quot;</span> <span style="color: #000066;">tabindex</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;5&quot;</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;textfield&quot;</span>&gt;</span></pre></div></div>

<p>This is completely legal and will not throw errors.</p>
<h3>Grabbing x-ignore- fields in ColdFusion</h3>
<p>If you want to grab these form variables via ColdFusion, do something like</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;">Form.x-ignore-lastname</pre></div></div>

<p>Will not suffice <span style="text-decoration: underline;"><strong>because of the dashes</strong></span>. You’ll have use the bracket/quotes format:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;">Form[“x-ignore-lastname”]</pre></div></div>

<p>to grab them.</p>
<p>Also to check for existence or set a default value,</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;">cfparam</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span>”form.x-ignore-lastname” <span style="color: #0000FF;">default</span><span style="color: #0000FF;">=</span>”parker” <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>Or</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;">cfparam</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span>”form<span style="color: #0000FF;">&#91;</span>“x-ignore-lastname” <span style="color: #0000FF;">default</span><span style="color: #0000FF;">=</span>”parker” <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>will not work.</p>
<p>You’ll have to use StructKeyexists( Form, &#8220;x-ignore-termsagree&#8221; ) to check for existence.</p>
<h3>HTML Form Example</h3>
<p>Putting all variables together from the previous table, we get something something like as follows:</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: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;key&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;step1_new_submissions/9AAAAAAA-D633-0944-9FBCCCCC6CFB161B_${filename}&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>  
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;acl&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;private&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;AWSAccessKeyId&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;0N16468ABC47JDAQ2902&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;policy&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;eyJleHBpcmF0aW9uIjogIjIwMTgtMTAtMjFUMDA6MDA6MDBaIiwKICAiY29uZGl0aW9ucyI6IFsgCiAgICB7ImJ1Y2tldCI6lyZWN0IjogImh0dHA6Ly90ZXN0LXBhc3RhdmlkZW9zLm1pbGxlbm5pdW13ZWIuY29tL3RoYW5rcy5jZm0ifQogIF0KfQ==&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;signature&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;2AAAA/BhWMg4CCCCC32fzQ=&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;content-type&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;video/mov&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;success_action_redirect&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;http://XYZ.com/thanks.cfm&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>      
<span style="color: #808080; font-style: italic;">&lt;!--- Ignore All This Stuff... ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;text&quot;</span> <span style="color: #0000FF;">id</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;x-ignore-firstname&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;x-ignore-firstname&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;peter&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;text&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;x-ignore-lastname&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;parker&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<h3>Using Amazon’s HTML POST Form Generator</h3>
<p>Because setting up the above HTML for the form could be tricky, Amazon has a tool that easily generates the HTML for the above code.</p>
<p>The following is a screenshot of the tool. The form can be found at: <a href="http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html">http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html</a></p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image025.png"><img class="size-full wp-image-1144 aligncenter" title="image025" src="http://www.shinylight.com/wp-content/uploads/2011/07/image025-e1312065715112.png" alt="" width="550" height="411" /></a><br />
<a href="http://www.shinylight.com/wp-content/uploads/2011/07/image026.png"><img class="alignnone size-full wp-image-1145" title="image026" src="http://www.shinylight.com/wp-content/uploads/2011/07/image026-e1312065751389.png" alt="" width="550" height="518" /></a></p>
<p>So the first thing you do is:</p>
<p><span style="text-decoration: underline;"><strong>1.</strong></span> Fill out the IDs:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image027.png"><img class="size-full wp-image-1146 aligncenter" title="image027" src="http://www.shinylight.com/wp-content/uploads/2011/07/image027.png" alt="" width="439" height="221" /></a></p>
<p>Where AWS ID = Access Key ID   and AWS Key = Secret Access Key</p>
<p><span style="text-decoration: underline;"><strong>2. </strong></span>The next thing we’ll do is fill in the POST URL:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image028.png"><img class="size-full wp-image-1147 aligncenter" title="image028" src="http://www.shinylight.com/wp-content/uploads/2011/07/image028.png" alt="" width="459" height="51" /></a></p>
<p><span style="text-decoration: underline;"><strong>3. </strong></span>The third step is the trickiest step. This is a JSON document that must adhere to the JSON spec. By default, there’s already a default boilerplate JSON document there. Let’s analyze what it means:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image029.png"><img class="size-full wp-image-1148 aligncenter" title="image029" src="http://www.shinylight.com/wp-content/uploads/2011/07/image029-e1312065859753.png" alt="" width="550" height="211" /></a></p>
<p>Let’s use one a real one from the test-pastavideos.XYZweb.com page:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image030.png"><img class="size-full wp-image-1149 aligncenter" title="image030" src="http://www.shinylight.com/wp-content/uploads/2011/07/image030-e1312065922847.png" alt="" width="550" height="160" /></a></p>
<p>You’ll notice that it has content-length-range, which checks the max size, in this case being 1 GB, and it also redirects to the index.cfm page when successful.</p>
<p>After you copy and paste that JSON policy, press “Add Policy”. Notice how the fields in the section “Sample Form Based on the Above Fields” has been populated.</p>
<p><strong><span style="text-decoration: underline;">4. </span></strong>The fields may look something like this:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image031.png"><img class="size-full wp-image-1150 aligncenter" title="image031" src="http://www.shinylight.com/wp-content/uploads/2011/07/image031-e1312065971851.png" alt="" width="452" height="304" /></a></p>
<p><strong><span style="text-decoration: underline;">5.</span></strong> Now click on Generate HTML:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image032.png"><img class="size-full wp-image-1151 aligncenter" title="image032" src="http://www.shinylight.com/wp-content/uploads/2011/07/image032-e1312066036974.png" alt="" width="455" height="228" /></a></p>
<p>Note that with the HTML code above, whatever the user uploads will be renamed to “testfile.txt” on S3. To retain the user’s filename, you have to switch it to value=”${filename}”</p>
<p><span style="text-decoration: underline;"><strong>6.</strong></span> You then copy that generated HTML and paste it into your page. Add any necessary optional fields with the x-ignore-prefixes.</p>
<p>That should give you a basic template for uploading to S3.</p>
<p><span style="text-decoration: underline;"><strong>NOTE</strong></span>: You cannot change the values of any &lt;input&gt; fields except except the key. More about this in the next section.</p>
<h3>Assigning the a unique ID to the object</h3>
<p>Keep in mind of these items when assigning a unique filename:</p>
<ul>
<li>You cannot change the user’s filename in JavaScript – once the user selects a file from his computer, you cannot append a GUID because JavaScript will not let you set the value of a file textbox, you can only read.</li>
<li>You cannot change append the GUID prefix after the form is submitted, because the filename will go to S3’s server, and there’s no way to run conditional logic once it’s on S3.</li>
</ul>
<p>To get around these limitations, you generate the GUID or rather a ColdFusion UUID, then append it to your filename. Let’s take a look at an example of the pasta video form:</p>
<p>First let’s show the JSON policy document:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;expiration&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;2018-10-21T00:00:00Z&quot;</span><span style="color: #339933;">,</span>
  <span style="color: #3366CC;">&quot;conditions&quot;</span><span style="color: #339933;">:</span> 
  <span style="color: #009900;">&#91;</span> 
    <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;bucket&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;PastaVideos&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> 
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;starts-with&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;$key&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;step1_new_submissions/&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;acl&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;private&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;starts-with&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;$Content-Type&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;video/mov&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;content-length-range&quot;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10737774</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
    <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;success_action_redirect&quot;</span><span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;http://pastavideos.XYZ.com/index.cfm&quot;</span><span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#93;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>And now the HTML / ColdFusion code:</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: #0000FF;">Data</span>.videoUUID  <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">CreateUUID</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: #000000; font-weight: bold;">form</span> <span style="color: #0000FF;">id</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;videoform&quot;</span> <span style="color: #0000FF;">action</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;http://www.XYZ.com/index.cfm&quot;</span> <span style="color: #0000FF;">method</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;get&quot;</span> <span style="color: #0000FF;">enctype</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;multipart/form-data&quot;</span><span style="color: #0000FF;">&gt;</span></span> 
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--- Start of Amazon S3 specific variables. ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;key&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#Data.key##Data.videoUUIDXX#_${filename}&quot;</span> <span style="color: #0000FF;">/&gt;</span></span>   
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #000000; font-weight: bold;">input</span> <span style="color: #0000FF;">type</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;hidden&quot;</span> <span style="color: #0000FF;">name</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;acl&quot;</span> <span style="color: #0000FF;">value</span><span style="color: #0000FF;">=</span><span style="color: #009900;">&quot;#Data.acl#&quot;</span> <span style="color: #0000FF;">/&gt;</span></span></pre></div></div>

<p>In the code above, when the HTML is rendered, it will already have filename S3 will use when it’s finished uploading. <strong>Remember</strong>, this is not the value of the &lt;input type=”file” /&gt; box.  So the user uploads, it will look like this on the AWS Console:</p>
<p style="text-align: center;"><a href="http://www.shinylight.com/wp-content/uploads/2011/07/image033.png"><img class="size-full wp-image-1152 aligncenter" title="image033" src="http://www.shinylight.com/wp-content/uploads/2011/07/image033.png" alt="" width="497" height="208" /></a></p>
<p>Now why is the action set to http://www.XYZ.com/index.cfm and method set to get? The HTML has this set, but when the page is loaded, JavaScript immediately runs and changes action to http://s3.amazonaws.com/PastaVideos and method to post:</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;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span>
  <span style="color: #808080; font-style: italic;">&lt;!--- Only change the form variables if JavaScript is turned on.  ---&gt;</span>  
  $( &quot;##videoform&quot; ).attr( &quot;action&quot;, &quot;<span style="color: #0000FF;">#Variables.postURL#</span>&quot; ); 
  $( &quot;##videoform&quot; ).attr( &quot;method&quot;, &quot;post&quot; );     
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfoutput</span><span style="color: #0000FF;">&gt;</span></span></pre></div></div>

<p>This is so that if JavaScript is turned off, it doesn’t POST to S3.</p>
<h3>Other Sources of Information</h3>
<p><strong>Amazon S3 POST Example in HTML</strong></p>
<ul>
<li><a href="http://aws.amazon.com/code/Amazon%20S3/1093?_encoding=UTF8&amp;jiveRedirect=1">http://aws.amazon.com/code/Amazon%20S3/1093?_encoding=UTF8&amp;jiveRedirect=1</a></li>
</ul>
<p><strong>AWS</strong></p>
<ul>
<li><a href="http://aws.amazon.com/developertools/">http://aws.amazon.com/developertools/</a></li>
</ul>
<p><strong>Helpful Resources</strong></p>
<ul>
<li><a href="http://wiki.smartfrog.org/wiki/display/sf/Amazon+S3">http://wiki.smartfrog.org/wiki/display/sf/Amazon+S3</a></li>
<li><a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?AccessPolicyLanguage_UseCases_s3_a.html">http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?AccessPolicyLanguage_UseCases_s3_a.html</a></li>
<li><a href="http://docs.amazonwebservices.com/AmazonS3/latest/gsg/">http://docs.amazonwebservices.com/AmazonS3/latest/gsg/</a></li>
<li><a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?UsingHTTPPOST.html">http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?UsingHTTPPOST.html</a></li>
<li><a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?HTTPPOSTExamples.html">http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?HTTPPOSTExamples.html</a></li>
<li><a href="http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?Introduction.html#S3_ACLs">http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?Introduction.html#S3_ACLs</a></li>
</ul>
<p><strong>Test Form</strong></p>
<ul>
<li><a href="http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html">http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html</a></li>
</ul>
<p><strong>Documentation Home Page</strong></p>
<ul>
<li><a href="http://aws.amazon.com/documentation/s3/">http://aws.amazon.com/documentation/s3/</a></li>
</ul>
<p><strong>Workflow using WS3 policies</strong></p>
<ul>
<li><a href="http://docs.amazonwebservices.com/AmazonS3/latest/dev/">http://docs.amazonwebservices.com/AmazonS3/latest/dev/</a></li>
</ul>
<p><strong>Helpful Posts</strong></p>
<ul>
<li><a href="http://aws.amazon.com/articles/1434?_encoding=UTF8&amp;jiveRedirect=1">http://aws.amazon.com/articles/1434?_encoding=UTF8&amp;jiveRedirect=1</a></li>
<li><a href="https://forums.aws.amazon.com/message.jspa?messageID=89017">https://forums.aws.amazon.com/message.jspa?messageID=89017</a></li>
<li><a href="https://forums.aws.amazon.com/message.jspa?messageID=88188">https://forums.aws.amazon.com/message.jspa?messageID=88188</a></li>
</ul>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 2338px; width: 1px; height: 1px; overflow: hidden;">Asynchronous Upload to Amazon S3 (S3)</p>
<p>Last Updated: 11/29/2010</p>
<p>Author: Dan Romero</p>
<p>Table of Contents</p>
<p>Summary of Problem.. 2</p>
<p>Introducing Amazon S3. 2</p>
<p>Benefits: 3</p>
<p>Drawbacks: 3</p>
<p>Creating a Basic HTML that POSTs a File to Amazon. 5</p>
<p>Step 1 – Create a Bucket / Folder / Object: 5</p>
<p>Step 2: Setting up the HTML Form.. 9</p>
<p>Setting up the Form tag. 10</p>
<p>Step 3: Setting up the Other Form Fields. 11</p>
<p>Optional Form Fields. 13</p>
<p>Grabbing x-ignore- fields in ColdFusion. 13</p>
<p>HTML Form Example. 14</p>
<p>Using Amazon’s HTML POST Form Generator. 14</p>
<p>Assigning the a unique ID to the object. 18</p>
<p>Other Sources of Information. 19</p>
<p>Requirements</p>
<p>Make sure you have an Amazon S3 Account (get it from tech).</p>
<p>JavaScript is mandatory for this to work (to be able to POST to two different domains) upon user<br />
submission.</p>
<p>Summary of Problem</p>
<p>This is a summary outlining the solution used in a video uploader. It entailed a form that would leverage the user of our Amazon S3 (S3) account. In addition, because the video files could be large (and to avoid CF limitations), a critical requirement was to upload to that page S3 directly. At the same time, the form field information had to be saved to our database. This meant doing a double post – one to the XYZ domain, and the other to s3.amazon.com. This cross-domain POST could only be done via AJAX.</p>
<p>Here’s visualization:</p>
<p>As you can see, once the user clicks “Submit”, there’s an AJAX HTTP POST to<br />
XZY server to save the fields to the database, and then the JavaScript runs a<br />
form.submit() on the current form to submit the file via POST to S3.</p>
<p>Introducing Amazon S3</p>
<p>Amazon S3 (Simple Storage Service) is a cloud service whose sole purpose is to store files. To store files into it, one can use its REST API or Admin Web Console (AWS).</p>
<p>Screenshot of the AWS console, with Amazon S3 tab selected.</p>
<p>One gets to the AWS console via an account (can get it from tech) and going to http://aws.amazon.com/s3/ and clicking “Sign in.”</p>
<p>While S3 has many advantages, there are a set of drawbacks as well. To summarize, here’s a list:</p>
<p>Benefits:</p>
<p>The max upload size for a file is 5GB. Plenty.</p>
<p>For all the times I’ve tested, uploads of different file sizes, everything has gone super smoothly – like butter – so definitely reliable.</p>
<p>Amazon is super scalable (as you may already know), so parallel uploading from one or many users is really no problem.</p>
<p>Would not affect performance of our servers &#8211; there could be many uploads, and they would go fast, without slowing down any other web sites on servers.</p>
<p>The speed of the upload is limited to the user’s computer’s specs and internet provider – much faster than our servers.</p>
<p>Files can be made secure and unreadable, not just through obscurity – this is sometimes tricky to implement in ColdFusion.</p>
<p>Drawbacks:</p>
<p>To summarize, the reason for some of the drawbacks, is because it’s doing a POST request directly from one domain (us) to another (s3.amazonaws.com). It’s not being channeled through our CF servers.</p>
<p>There are two ways to interact with S3: the REST API, and doing a direct POST. With the REST API, the upload data has to be channeled through a server first before sending to Amazon – this was not what we were looking for, since our servers have issues with large files. So we looked into removing ourselves as the middleman and sending the data directly to S3 – via POST.</p>
<p>Here are the drawbacks, mainly three:</p>
<p>If S3 detected an error in the upload, e.g. if the file is too large, there’s no default error page, just a redirect to an XML document hosted on s3.amazonaws.com. There’s no way to set an error page – it’s on Amazon’s to-do list for future release. One can’t even customize the look and feel of the XML document you’re redirected to. Side note: if the upload was successful, it gets redirected to a page you specify (at least there’s some control here).</p>
<p>Progress bar reusable code is scare. There’s tons of code out there to do this, however, I could not find one that could cross-domain post. With traditional AJAX, you’re only allowed to do a POST/GET if the URL you’re using is the same domain as the caller page. One could get the code for a progress bar plugin (as there are tons out there) and rewrite it to do a POST and work with Amazon S3 – but that would take a considerate amount of work.</p>
<p>Lack of documentation. There’s not enough documentation for handling POST requests in the official Amazon Developer docs, which makes troubleshooting difficult. Doing POST submits is a relatively new feature of Amazon S3, compared to the rest of their APIs.</p>
<p>So the largest hurdle is to code functionality to get around the error page, since some JavaScript magic has to be put in place. That would be another day or so of work just for that, I believe. I already have some code in place that I put together while testing. If we left it as-is, when the user uploads, and if there was an error, the user would see something like this:</p>
<p>Which would, of course, be nonsensical. If the file was too large, they would see a message that the file was too large within the message tags. The user would then have to hit back to return to the form.</p>
<p>We can try another way, probably the easiest. When the user hits submits, it starts showing the animated spinner as it’s uploading. Also, we can tell the user that if he encounters an error page, just hit the back button. Also, keep in mind that there’ll be validation in place before the upload to check for file extension, at the very least. The only edge case to seeing that XML error message is if the file they submitted is over the limit *AND*  they have JavaScript turned off (that overrides the JavaScript file extension validation).</p>
<p>Creating a Basic HTML that POSTs a File to Amazon</p>
<p>Step 1 – Create a Bucket / Folder / Object:<br />
The first thing we need to do a is create a Bucket on S3. To do this the easy way, go to the AWS: https://console.aws.amazon.com/s3/home  and create a bucket:</p>
<p>Buckets are where you store your objects (i.e. your files of any format). You can create a folder for further organization:</p>
<p>As you can see here, there are 4 folders here. We can double-click on step1_new_submissions folder and see the objects that are contained within this:</p>
<p>You can right-click on one of those objects (files) and click “Properties”:</p>
<p>Notice that a Properties panel will expand below. To the right, you have three tabs: Details, Permissions, Metadata.</p>
<p>If you click on the Permissions Tab you’ll notice that by default the file that was selected has following permissions set by user USERNAME:</p>
<p>Go back to the details tab and click on the Link:</p>
<p>You’ll notice that you’ll be taken to an XML document in your browser that has the following:</p>
<p>It’s because you have not let it public access. To give it public access, you click on the Permissions tab again, and click “Add more permissions” , set the Grantee to “Everyone” and choose Open/Download and Save.</p>
<p>You can also set the make multiple objects public. Select an object, hold the SHIFT key, then select the other object to select the objects in between. Select “Make Public”:</p>
<p>You can also upload an object manually via the “Upload” button:</p>
<p>Then click “Add more files”</p>
<p>As the file starts uploading, you’ll see the bottom panel show details about the file transfer:</p>
<p>Step 2: Setting up the HTML Form</p>
<p>The S3 REST API is very flexible, as long as you execute the proper method from your application, while at the same time sending the file over from your server to S3 (via a REST method with the correct URI). Traditionally, it would look like this:</p>
<p>Notice how there’s a middle-man that serves as the captor of the data submitted by the form and the file. Then, it sends it long to S3. The middle-man here is crucial. Double the total bandwidth is spent here – the bandwidth to go from the user’s machine to the web server (in this case CF), and then the bandwidth spent transferring the file to S3.</p>
<p>The advantage to this layout is that because the web server acts as a middle-man server, it can modify the data, change its filename, and slice-and-dice anything within the file because the file submitted has to go through it first. Once the middle-man is done, then it sends it to the S3. Drawback is that there’s wasted resources from the middle-man, not to mention there may be limitations on the middle-man to handle large files &gt; 1GB .</p>
<p>As a solution, S3 has a POST method solution where you can POST the file directly to S3:</p>
<p>Setting up the Form tag</p>
<p>Let’s see how we can cross-domain (a domain other than ours) to S3. Rather than doing the following (to post to the same domain):</p>
<p>&lt;form action=”#CGI.SCRIPT_NAME#” method=”post” enctype=”multipart/form-data”&gt;</p>
<p>We do the following:</p>
<p>&lt;form action=”http://s3.amazonaws.com/PastaVideos” method=”post” enctype=”multipart/form-data”&gt;</p>
<p>Where “PastaVideos” is the name of the bucket.</p>
<p>The format of the object URI is as follows:</p>
<p>Step 3: Setting up the Other Form Fields</p>
<p>This is where things get interesting. In order to set up an HTML form that can upload straight to S3, there’s a set of required input fields in the form. They are as follows:</p>
<p>Tag<br />
Type<br />
Name<br />
Value</p>
<p>input<br />
hidden<br />
key<br />
The location of the object you’ll be uploading. You can consider it as the concatenation of the folder(s) and the filename (don’t use the bucket name):</p>
<p>step1_new_submissions/4059C3_${filename}</p>
<p>The ${filename} is the original filename of the file the user is uploading. The “4059C3_” is a made up ID that is concatenated to the ${filename} that will add uniqueness to the objects in the bucket, if multiple people are uploading to it.</p>
<p>input<br />
hidden<br />
acl<br />
The access control list. Can be set to:</p>
<p>private – Lets the public user upload a file, but not be able to access it once he uploads. To make it accessible, one has to go into the AWS console and change the rights.</p>
<p>public-read – Lets the public user see it after he has uploaded it or anyone else see it.</p>
<p>input<br />
hidden<br />
AWSAccessKeyId<br />
To get this key id, you need to access it by going to:</p>
<p>Then security credentials:</p>
<p>Get the Access Key ID. This id is also called the AWSAccessKeyId.</p>
<p>You should also grab the “Secret Access Key” by clicking on the “Show” on the adjacent column:</p>
<p>Keep the Secret Access Key private! Only the Access Key ID can be made public.</p>
<p>input<br />
hidden<br />
policy<br />
Policy is a Base64 encoded JSON document that outlines the privileges and details of the files being uploaded. More details about this in the next section.</p>
<p>input<br />
hidden<br />
signature<br />
The signature is the policy, HMAC-encrypted using the Secret Access Key.</p>
<p>input<br />
hidden<br />
content-type<br />
The content type is the what kind of mime content the file that will pass through the form will be.</p>
<p>input<br />
hidden<br />
success_action_redirect<br />
This is the URL of where to go when the upload succeeds. It could be any URL.  Also, when redirected, it will add the three additional URL variables:</p>
<p>bucket=PastaVideos</p>
<p>key=step1_new_submissions%2A192DCAE1-D625-0944-9FBCCD5C6CCB161B_ajax5-loader.mov</p>
<p>etag=%22356060aa56ce8955d38ed8c58661497a%22</p>
<p>Optional Form Fields</p>
<p>IMPORTANT: If you add any other additional form fields, it will throw an error. If there is in fact a need to add extra form fields, which will be pasted to another server, then you must append the prefix “x-ignore-“. Let’s say for example I have three input fields I want S3 to ignore, then do as follows:</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;x-ignore-lastname&#8221; tabindex=&#8221;2&#8243; class=&#8221;textfield&#8221;&gt;</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;x-ignore-address1&#8243; tabindex=&#8221;3&#8243; class=&#8221;textfield&#8221;&gt;</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;x-ignore-address2&#8243; tabindex=&#8221;4&#8243; class=&#8221;textfield&#8221;&gt;</p>
<p>&lt;input type=&#8221;text&#8221; name=&#8221;x-ignore-city&#8221; tabindex=&#8221;5&#8243; class=&#8221;textfield&#8221;&gt;</p>
<p>This is completely legal and will not throw errors.</p>
<p>Grabbing x-ignore- fields in ColdFusion</p>
<p>If you want to grab these form variables via ColdFusion, do something like</p>
<p>Form.x-ignore-lastname</p>
<p>Will not suffice because of the dashes. You’ll have use the bracket/quotes format:</p>
<p>Form[“x-ignore-lastname”]</p>
<p>to grab them.</p>
<p>Also to check for existence or set a default value,</p>
<p>&lt;cfparam name=”form.x-ignore-lastname” default=”parker” /&gt;</p>
<p>Or</p>
<p>&lt;cfparam name=”form[“x-ignore-lastname” default=”parker” /&gt;</p>
<p>will not work.</p>
<p>You’ll have to use StructKeyexists( Form, "x-ignore-termsagree" ) to check for existence.</p>
<p>HTML Form Example</p>
<p>Putting all variables together from the previous table, we get something something like as follows:</p>
<p>&lt;input type="hidden" name="key" value="step1_new_submissions/9AAAAAAA-D633-0944-9FBCCCCC6CFB161B_${filename}" /&gt;</p>
<p>&lt;input type="hidden" name="acl" value="private" /&gt;</p>
<p>&lt;input type="hidden" name="AWSAccessKeyId" value="0N16468ABC47JDAQ2902" /&gt;</p>
<p>&lt;input type="hidden" name="policy" value="eyJleHBpcmF0aW9uIjogIjIwMTgtMTAtMjFUMDA6MDA6MDBaIiwKICAiY29uZGl0aW9ucyI6IFsgCiAgICB7ImJ1Y2tldCI6lyZWN0IjogImh0dHA6Ly90ZXN0LXBhc3RhdmlkZW9zLm1pbGxlbm5pdW13ZWIuY29tL3RoYW5rcy5jZm0ifQogIF0KfQ==" /&gt;</p>
<p>&lt;input type="hidden" name="signature" value="2AAAA/BhWMg4CCCCC32fzQ=" /&gt;</p>
<p>&lt;input type="hidden" name="content-type" value="video/mov" /&gt;</p>
<p>&lt;input type="hidden" name="success_action_redirect" value="http://XYZ.com/thanks.cfm" /&gt;</p>
<p>&lt;!--- Ignore All This Stuff... ---&gt;<br />
&lt;input type="text" id="x-ignore-firstname" name="x-ignore-firstname" value="peter" /&gt;</p>
<p>&lt;input type="text" name="x-ignore-lastname" value="parker" /&gt;</p>
<p>Using Amazon’s HTML POST Form Generator</p>
<p>Because setting up the above HTML for the form could be tricky, Amazon has a tool that easily generates the HTML for the above code.</p>
<p>The following is a screenshot of the tool. The form can be found at: http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html</p>
<p>So the first thing you do is:</p>
<p>1.       Fill out the IDs:</p>
<p>Where AWS ID = Access Key ID   and AWS Key = Secret Access Key</p>
<p>2.       The next thing we’ll do is fill in the POST URL:</p>
<p>3.       The third step is the trickiest step. This is a JSON document that must adhere to the JSON spec. By default, there’s already a default boilerplate JSON document there. Let’s analyze what it means:</p>
<p>Let’s use one a real one from the test-pastavideos.XYZweb.com page:</p>
<p>You’ll notice that it has content-length-range, which checks the max size, in this case being 1 GB, and it also redirects to the index.cfm page when successful.</p>
<p>After you copy and paste that JSON policy, press “Add Policy”. Notice how the fields in the section “Sample Form Based on the Above Fields” has been populated.</p>
<p>4.       The fields may look something like this:</p>
<p>5.       Now click on Generate HTML:</p>
<p>Note that with the HTML code above, whatever the user uploads will be renamed to “testfile.txt” on S3. To retain the user’s filename, you have to switch it to value=”${filename}”</p>
<p>6.       You then copy that generated HTML and paste it into your page. Add any necessary optional fields with the x-ignore-prefixes.</p>
<p>That should give you a basic template for uploading to S3.</p>
<p>NOTE: You cannot change the values of any &lt;input&gt; fields except except the key. More about this in the next section.</p>
<p>Assigning the a unique ID to the object</p>
<p>Keep in mind of these items when assigning a unique filename:</p>
<p>You cannot change the user’s filename in JavaScript – once the user selects a file from his computer, you cannot append a GUID because JavaScript will not let you set the value of a file textbox, you can only read.</p>
<p>You cannot change append the GUID prefix after the form is submitted, because the filename will go to S3’s server, and there’s no way to run conditional logic once it’s on S3.</p>
<p>To get around these limitations, you generate the GUID or rather a ColdFusion UUID, then append it to your filename. Let’s take a look at an example of the pasta video form:</p>
<p>First let’s show the JSON policy document:</p>
<p>{"expiration": "2018-10-21T00:00:00Z",</p>
<p>"conditions": [</p>
<p>{"bucket": "PastaVideos"},</p>
<p>["starts-with", "$key", "step1_new_submissions/"],</p>
<p>{&#8220;acl&#8221;: &#8220;private&#8221;},</p>
<p>["starts-with", "$Content-Type", "video/mov"],</p>
<p>["content-length-range", 0, 10737774],</p>
<p>{&#8220;success_action_redirect&#8221;: &#8220;http://pastavideos.XYZ.com/index.cfm&#8221;}</p>
<p>]</p>
<p>}</p>
<p>And now the HTML / ColdFusion code:</p>
<p>&lt;cfset Data.videoUUID  = CreateUUID() /&gt;</p>
<p>&lt;form id=&#8221;videoform&#8221; action=&#8221;http://www.XYZ.com/index.cfm&#8221; method=&#8221;get&#8221; enctype=&#8221;multipart/form-data&#8221;&gt;</p>
<p>&lt;!&#8212; Start of Amazon S3 specific variables. &#8212;&gt;</p>
<p>&lt;input type=&#8221;hidden&#8221; name=&#8221;key&#8221;</p>
<p>value=&#8221;#Data.key## Data.videoUUIDXX#_${filename}&#8221; /&gt;</p>
<p>&lt;input type=&#8221;hidden&#8221; name=&#8221;acl&#8221; value=&#8221;#Data.acl#&#8221; /&gt;</p>
<p>In the code above, when the HTML is rendered, it will already have filename S3 will use when it’s finished uploading. Remember, this is not the value of the &lt;input type=”file” /&gt; box.  So the user uploads, it will look like this on the AWS Console:</p>
<p>Now why is the action set to http://www.XYZ.com/index.cfm and method set to get? The HTML has this set, but when the page is loaded, JavaScript immediately runs and changes action to http://s3.amazonaws.com/PastaVideos and method to post:</p>
<p>&lt;cfoutput&gt;</p>
<p>&lt;!&#8212; Only change the form variables if JavaScript is turned on.  &#8212;&gt;</p>
<p>$( &#8220;##videoform&#8221; ).attr( &#8220;action&#8221;, &#8220;#Variables.postURL#&#8221; );</p>
<p>$( &#8220;##videoform&#8221; ).attr( &#8220;method&#8221;, &#8220;post&#8221; );</p>
<p>&lt;/cfoutput&gt;</p>
<p>This is so that if JavaScript is turned off, it doesn’t POST to S3.</p>
<p>Other Sources of Information</p>
<p>Amazon S3 POST Example in HTML</p>
<p>http://aws.amazon.com/code/Amazon%20S3/1093?_encoding=UTF8&amp;jiveRedirect=1</p>
<p>AWS</p>
<p>http://aws.amazon.com/developertools/</p>
<p>Helpful Resources</p>
<p>http://wiki.smartfrog.org/wiki/display/sf/Amazon+S3</p>
<p>http://docs.amazonwebservices.com/AmazonS3/latest/dev/index.html?AccessPolicyLanguage_UseCases_s3_a.html</p>
<p>http://docs.amazonwebservices.com/AmazonS3/latest/gsg/</p>
<p>http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?UsingHTTPPOST.html</p>
<p>http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?HTTPPOSTExamples.html</p>
<p>http://docs.amazonwebservices.com/AmazonS3/2006-03-01/dev/index.html?Introduction.html#S3_ACLs</p>
<p>Test Form</p>
<p>http://s3.amazonaws.com/doc/s3-example-code/post/post_sample.html</p>
<p>Documentation Home Page</p>
<p>http://aws.amazon.com/documentation/s3/</p>
<p>Workflow using WS3 policies</p>
<p>http://docs.amazonwebservices.com/AmazonS3/latest/dev/</p>
<p>Helpful Posts</p>
<p>http://aws.amazon.com/articles/1434?_encoding=UTF8&amp;jiveRedirect=1</p>
<p>https://forums.aws.amazon.com/message.jspa?messageID=89017</p>
<p>https://forums.aws.amazon.com/message.jspa?messageID=88188</p>
</div>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;submitHeadline=Asynchronous+Upload+to+Amazon+S3+%28S3%29&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;title=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;title=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;title=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;bm_description=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;T=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;title=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;title=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Asynchronous+Upload+to+Amazon+S3+%28S3%29+@+http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/&amp;t=Asynchronous+Upload+to+Amazon+S3+%28S3%29" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2010/01/01/asynchronous-upload-to-amazon-s3-s3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>yUML and ColdFusion</title>
		<link>http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/</link>
		<comments>http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/#comments</comments>
		<pubDate>Tue, 29 Dec 2009 06:45:15 +0000</pubDate>
		<dc:creator>Dan</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://www.shinylight.com/?p=594</guid>
		<description><![CDATA[I just tried to write a quick script in Python that scans CFCs and generates a yUML URL to diagram. I pointed my script to my root CFC path and I got a 13K strlen URL. I pasted it in the address bar to see what happened and I got the following:

Request-URI Too Large
&#160;
The requested [...]]]></description>
			<content:encoded><![CDATA[<p>I just tried to write a quick script in Python that scans CFCs and generates a yUML URL to diagram. I pointed my script to my root CFC path and I got a 13K strlen URL. I pasted it in the address bar to see what happened and I got the following:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Request-URI Too Large
&nbsp;
The requested URL's length exceeds the capacity limit for this server.
Apache/2.2.3 (Debian) Phusion_Passenger/2.0.2 Server at Ess000235.gtcust.grouptelecom.net Port 80</pre></div></div>

<p>I wonder what the limitation is. I suppose I&#8217;ll have to do a CFC per diagram and then bind them together somehow. I&#8217;m choosing Python so this script can be part of my build script.</p>
<p>Here&#8217;s the code so far, which of course, could be optimized:</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;"><span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">re</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">os</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># UML Syntax</span>
<span style="color: #808080; font-style: italic;"># http://yuml.me/diagram/class/[User|Property1;Property2|Method1();Method2()]</span>
<span style="color: #808080; font-style: italic;"># http://yuml.me/diagram/class/</span>
<span style="color: #808080; font-style: italic;"># [</span>
<span style="color: #808080; font-style: italic;">#   User</span>
<span style="color: #808080; font-style: italic;">#   |</span>
<span style="color: #808080; font-style: italic;">#     Property1;</span>
<span style="color: #808080; font-style: italic;">#     Property2</span>
<span style="color: #808080; font-style: italic;">#   |</span>
<span style="color: #808080; font-style: italic;">#     Method1();</span>
<span style="color: #808080; font-style: italic;">#     Method2()</span>
<span style="color: #808080; font-style: italic;">#  ]</span>
&nbsp;
&nbsp;
<span style="color: #808080; font-style: italic;"># Master Path</span>
ROOT_PATH = <span style="color: #483d8b;">'C:<span style="color: #000099; font-weight: bold;">\\</span>temp<span style="color: #000099; font-weight: bold;">\\</span>cf-yuml'</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> SearchForFile<span style="color: black;">&#40;</span> rootpath, searchfor, includepath = <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span>:
&nbsp;
  <span style="color: #808080; font-style: italic;"># Search for a file recursively from a root directory.</span>
  <span style="color: #808080; font-style: italic;">#  rootpath  = root directory to start searching from.</span>
  <span style="color: #808080; font-style: italic;">#  searchfor = regexp to search for, e.g.:</span>
  <span style="color: #808080; font-style: italic;">#                 search for *.jpg : \.exe$                     </span>
  <span style="color: #808080; font-style: italic;">#  includepath = appends the full path to the file</span>
  <span style="color: #808080; font-style: italic;">#                this attribute is optional</span>
  <span style="color: #808080; font-style: italic;"># Returns a list of filenames that can be used to loop</span>
  <span style="color: #808080; font-style: italic;"># through.</span>
  <span style="color: #808080; font-style: italic;">#</span>
  <span style="color: #808080; font-style: italic;"># TODO: Use the glob module instead. Could be faster.  </span>
  names = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
  append = <span style="color: #483d8b;">&quot;&quot;</span>
  <span style="color: #ff7700;font-weight:bold;">for</span> root, dirs, files <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #dc143c;">os</span>.<span style="color: black;">walk</span><span style="color: black;">&#40;</span> rootpath <span style="color: black;">&#41;</span>: 
    <span style="color: #ff7700;font-weight:bold;">for</span> name <span style="color: #ff7700;font-weight:bold;">in</span> files:
      <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span> searchfor, name <span style="color: black;">&#41;</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> includepath == <span style="color: #ff4500;">0</span>:
          root = <span style="color: #483d8b;">&quot;&quot;</span>          
        <span style="color: #ff7700;font-weight:bold;">else</span>:          
          append = <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&quot;</span>
        names.<span style="color: black;">append</span><span style="color: black;">&#40;</span> root + append + name <span style="color: black;">&#41;</span>        
  <span style="color: #ff7700;font-weight:bold;">return</span> names  
&nbsp;
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> getCFCInfo <span style="color: black;">&#40;</span> FILE, path <span style="color: black;">&#41;</span>:
  FILE.<span style="color: black;">seek</span><span style="color: black;">&#40;</span> <span style="color: #ff4500;">0</span>, <span style="color: #ff4500;">0</span> <span style="color: black;">&#41;</span>  
  CFCLines = FILE.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
  CFCFunctions  = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
  CFCProperties = <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span>
  CFC           = <span style="color: black;">&#123;</span><span style="color: black;">&#125;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> CFCLines:
    <span style="color: #808080; font-style: italic;"># Get names of methods  </span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;^&lt;cffunction&quot;</span>, i , <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span> | <span style="color: #dc143c;">re</span>.<span style="color: black;">MULTILINE</span> <span style="color: black;">&#41;</span>:    
      CFCFunctions.<span style="color: black;">append</span><span style="color: black;">&#40;</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span> r<span style="color: #483d8b;">'name<span style="color: #000099; font-weight: bold;">\s</span>*=<span style="color: #000099; font-weight: bold;">\s</span>*&quot;([<span style="color: #000099; font-weight: bold;">\w</span>$-]+)&quot;'</span>, i, <span style="color: #dc143c;">re</span>.<span style="color: black;">DOTALL</span> | <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span><span style="color: black;">&#41;</span>.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>
&nbsp;
  <span style="color: #808080; font-style: italic;"># Get names of properties</span>
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span> <span style="color: #483d8b;">&quot;^&lt;cfproperty&quot;</span>, i , <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span> | <span style="color: #dc143c;">re</span>.<span style="color: black;">MULTILINE</span> <span style="color: black;">&#41;</span>:    
      CFCProperties.<span style="color: black;">append</span><span style="color: black;">&#40;</span> <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span> r<span style="color: #483d8b;">'name<span style="color: #000099; font-weight: bold;">\s</span>*=<span style="color: #000099; font-weight: bold;">\s</span>*&quot;([<span style="color: #000099; font-weight: bold;">\w</span>$-]+)&quot;'</span>, i, <span style="color: #dc143c;">re</span>.<span style="color: black;">DOTALL</span> | <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span><span style="color: black;">&#41;</span>.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span> <span style="color: black;">&#41;</span>     
&nbsp;
  CFC = <span style="color: black;">&#123;</span> <span style="color: #483d8b;">&quot;properties&quot;</span>:CFCProperties, <span style="color: #483d8b;">&quot;methods&quot;</span>:CFCFunctions <span style="color: black;">&#125;</span>  
&nbsp;
  <span style="color: #808080; font-style: italic;"># Generate URL</span>
  strFunctions  = <span style="color: #483d8b;">&quot;&quot;</span>
  strProperties = <span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> CFCFunctions:
    strFunctions  += i + <span style="color: #483d8b;">&quot;();&quot;</span>
&nbsp;
  <span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> CFCProperties:
    strProperties += i + <span style="color: #483d8b;">&quot;;&quot;</span>  
&nbsp;
  CFCFileName = <span style="color: #dc143c;">re</span>.<span style="color: black;">search</span><span style="color: black;">&#40;</span>r<span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>([<span style="color: #000099; font-weight: bold;">\w</span>-]+)<span style="color: #000099; font-weight: bold;">\.</span>cfc$&quot;</span>, path, <span style="color: #dc143c;">re</span>.<span style="color: black;">DOTALL</span> | <span style="color: #dc143c;">re</span>.<span style="color: black;">IGNORECASE</span><span style="color: black;">&#41;</span>.<span style="color: black;">group</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>  
  <span style="color: #ff7700;font-weight:bold;">return</span> <span style="color: #483d8b;">&quot;[&quot;</span> + CFCFileName + <span style="color: #483d8b;">&quot;|&quot;</span> + <span style="color: black;">&#40;</span> strProperties.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">&quot;|&quot;</span> <span style="color: #ff7700;font-weight:bold;">if</span> strProperties.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: #ff7700;font-weight:bold;">else</span> <span style="color: #483d8b;">&quot;&quot;</span> <span style="color: black;">&#41;</span> + strFunctions.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> + <span style="color: #483d8b;">&quot;]&quot;</span>  
&nbsp;
URL = <span style="color: #483d8b;">&quot;&quot;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> SearchForFile<span style="color: black;">&#40;</span> ROOT_PATH, <span style="color: #483d8b;">&quot;<span style="color: #000099; font-weight: bold;">\.</span>cfc$&quot;</span>, <span style="color: #ff4500;">1</span> <span style="color: black;">&#41;</span>:
  CFCFile = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span> i, <span style="color: #483d8b;">&quot;r&quot;</span> <span style="color: black;">&#41;</span>
  URL += getCFCInfo<span style="color: black;">&#40;</span> CFCFile, i <span style="color: black;">&#41;</span> + <span style="color: #483d8b;">&quot;,&quot;</span>
  CFCFile.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
&nbsp;
URL = URL<span style="color: black;">&#91;</span>:-<span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;http://yuml.me/diagram/class/&quot;</span> + URL</pre></div></div>

<p>I&#8217;ll keep working on this as time goes on. So far it just goes through all the CFC&#8217;s from the path you point to. It will crawl through all sub directories. There&#8217;s no relationship between classes, however. Not yet at least. </p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a><strong><em></em></strong></a>
<br />
<div class="d">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;submitHeadline=yUML+and+ColdFusion&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;title=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;title=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;title=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;bm_description=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;T=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;title=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;title=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+yUML+and+ColdFusion+@+http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/&amp;t=yUML+and+ColdFusion" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://www.shinylight.com/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
</div>
</div>
<!-- Social Bookmarks END -->
]]></content:encoded>
			<wfw:commentRss>http://www.shinylight.com/2009/12/29/yuml-and-coldfusion/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

