<?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/"
	>

<channel>
	<title>Web Biz</title>
	<atom:link href="http://blog.brianflove.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.brianflove.com</link>
	<description>ColdFusion and Web Technologies</description>
	<pubDate>Tue, 02 Jun 2009 18:58:06 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.7</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Empty directories with cfdirectory and cfzip</title>
		<link>http://blog.brianflove.com/articles/2009/06/02/empty-directories-with-cfdirectory-and-cfzip/</link>
		<comments>http://blog.brianflove.com/articles/2009/06/02/empty-directories-with-cfdirectory-and-cfzip/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 18:56:17 +0000</pubDate>
		<dc:creator>brian</dc:creator>
		
		<category><![CDATA[Adobe]]></category>

		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[ColdFusion 8]]></category>

		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.brianflove.com/?p=229</guid>
		<description><![CDATA[Ever work with &#60;cfdirectory&#62; or &#60;cfzip&#62; and notice that they both ignore empty directories?  This might make sense with some business logic, where an empty directory can (and should) be ignored.  However, what if you want to ensure that empty directories are included in a zip file?]]></description>
			<content:encoded><![CDATA[<p>Ever work with &lt;cfdirectory&gt; or &lt;cfzip&gt; and notice that they both ignore empty directories?  This might make sense with some business logic, where an empty directory can (and should) be ignored.  However, what if you want to ensure that empty directories are included in a zip file?</p>
<p>Our first iteration involved using  to list the directories, loop over all directories, and determine if there are files within each directory.  If a directory is empty, we place a placeholder.txt empty file in the directory.  Here is what the code looked like:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p229code1'); return false;">View Code</a> COLDFUSION</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2291"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code" id="p229code1"><pre class="coldfusion" style="font-family:monospace;">&lt;cffunction name=&quot;_addPlaceholderFileToEmptyDirs&quot; access=&quot;private&quot; returntype=&quot;void&quot;&gt;
	&lt;cfargument name=&quot;file&quot; required=&quot;false&quot; default=&quot;#variables.pathToCourse#\ClassFiles&quot;&gt;
	&lt;cfset var dir = ''&gt;
	&lt;cfset var subdir = ''&gt;
	&lt;cfdirectory action=&quot;list&quot; directory=&quot;#pathToClassFilesDir#&quot; name=&quot;dir&quot; recurse=&quot;true&quot; type=&quot;dir&quot;&gt;
	&lt;ol&gt;
		&lt;cfloop query=&quot;dir&quot;&gt;
			&lt;cfif not ListFindNoCase('props,prop-base,text-base,.svn', dir.name)&gt;
				&lt;cfdirectory action=&quot;list&quot; directory=&quot;#dir.directory#&quot; name=&quot;subdir&quot;&gt;
				&lt;cfif not subdir.recordcount&gt;
					&lt;cffile action=&quot;copy&quot; source=&quot;#variables.dirWCWC#\placeHolder.txt&quot; destination=&quot;#dir.Directory#\placeholder.txt&quot;&gt;
					&lt;cfoutput&gt;&lt;li&gt;#Directory#\placeHolder.txt.&lt;/li&gt;&lt;/cfoutput&gt;
				&lt;/cfif&gt;
			&lt;/cfif&gt;
		&lt;/cfloop&gt;
	&lt;/ol&gt;
&lt;/cffunction&gt;</pre></td></tr></table></div>

<p>After (not so) quickly realizing that  is ignoring empty directories we moved to a second iteration.  This time, we used Java to get the list of directories, and recursively copy the placeholder file into empty directories.  Here is the code:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p229code2'); return false;">View Code</a> COLDFUSION</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2292"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
</pre></td><td class="code" id="p229code2"><pre class="coldfusion" style="font-family:monospace;">&lt;cffunction name=&quot;_addPlaceholderFileToEmptyDirs&quot; access=&quot;private&quot; returntype=&quot;void&quot;&gt;
	&lt;cfargument name=&quot;dirpath&quot; required=&quot;false&quot; type=&quot;string&quot; default=&quot;#variables.pathToCourse#\ClassFiles&quot;&gt;
	&lt;cfset var directory = CreateObject(&quot;java&quot;, &quot;java.io.File&quot;).init(dirpath)&gt;
	&lt;cfset var files = directory.listFiles()&gt;
	&lt;cfset var i = 0&gt;
	&lt;cfloop from=&quot;1&quot; to=&quot;#ArrayLen(files)#&quot; index=&quot;i&quot;&gt;
		&lt;cfif files[i].isDirectory() AND ArrayLen(files[i].listFiles())&gt;
			&lt;cfset _addPlaceholderFileToEmptyDirs(files[i].getAbsolutePath())&gt;
		&lt;cfelseif files[i].isDirectory()&gt;
			&lt;cffile action=&quot;copy&quot; source=&quot;#variables.dirWCWC#\placeHolder.txt&quot; destination=&quot;#files[i].getAbsolutePath()#\placeholder.txt&quot;&gt;
			&lt;cfoutput&gt;&lt;li&gt;Placeholder added to: #files[i].getName()#&lt;/li&gt;&lt;/cfoutput&gt;
		&lt;/cfif&gt;
	&lt;/cfloop&gt;
	&lt;/ol&gt;
&lt;/cffunction&gt;</pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.brianflove.com/articles/2009/06/02/empty-directories-with-cfdirectory-and-cfzip/feed/</wfw:commentRss>
		</item>
		<item>
		<title>YUI and the Dom</title>
		<link>http://blog.brianflove.com/articles/2009/03/25/yui-and-the-dom/</link>
		<comments>http://blog.brianflove.com/articles/2009/03/25/yui-and-the-dom/#comments</comments>
		<pubDate>Wed, 25 Mar 2009 20:15:56 +0000</pubDate>
		<dc:creator>brian</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://blog.brianflove.com/?p=211</guid>
		<description><![CDATA[In this next installment of the series on using YUI, we are going to learn about YUI and the Dom.  Generally speaking, scripting the DOM sucks.  That might even be an understatement.  Thankfully, we have innerHTML and a variety of tools provided by the YAHOO.util.Dom singleton class as well as the YAHOO.util.Element class.]]></description>
			<content:encoded><![CDATA[<p>I&#8217;d like to continue from my last post on using the Yahoo User Interface JavaScript library (or YUI for short) and talk about how nicely YUI makes working with the DOM.  My first post was on <a href="http://blog.brianflove.com/articles/2009/01/23/getting-started-with-yui/">getting started with YUI</a>, which got us up and running with the loader to get the necessary YUI JS files to the client, and then introduced the Event class.  We even took a look at using the scope correction features of the YUI Event class.</p>
<h2>The Dom sucks</h2>
<p>In this next installment of the series, we are going to learn about YUI and the Dom.  Generally speaking, scripting the DOM sucks.  That might even be an understatement.  Thankfully, we have innerHTML and a variety of tools provided by the <a href="http://developer.yahoo.com/yui/dom" target="_blank">YAHOO.util.Dom</a> singleton class as well as the <a href="http://developer.yahoo.com/yui/element" target="_blank">YAHOO.util.Element</a> class.</p>
<p>As a side note, for those of us out there that prefer the innerHTML route (not sure why you wouldn&#8217;t&#8230;) there is a good post by Steven Levithan on <a href="http://blog.stevenlevithan.com/archives/faster-than-innerhtml" target="_blank">speeding up innerHTML by using his replaceHTML method</a> &#8212; be sure to check this out of if you are continually using the innerHTML to inject returned HTML code from an Ajax call.</p>
<h2>The YUI solution</h2>
<p>The YAHOO.util.Dom class is a singleton (meaning, no need to instantiate it via new) that provides the following functionality:</p>
<ul>
<li>Accessing elements</li>
<li>Positioning of elements (and easy access to document positioning information)</li>
<li>Styling an element</li>
<li>Inserting elements</li>
</ul>
<h2>Accessing elements</h2>
<p>There are several approaches to finding and accessing elements in the Dom.  First, the YAHOO.util.Dom.get method is a convenience shortcut to the document.getElementById() function.  I like to create a shortcut function for this, coming from the Prototype world, the $() will do:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p211code3'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2113"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code" id="p211code3"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> $<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> myObj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//This function is called from the onSuccess method of my YUI loader</span>
	init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//create helper shortcuts</span>
		$ <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In the code above, we are using our sample myObj object that has an init() method.  This method is called from our onSuccess() handler for the YUI loader from the <a href="http://blog.brianflove.com/articles/2009/01/23/getting-started-with-yui/">getting started with YUI post</a>.  Its important that the init() method is called after I have loaded the &#8216;dom&#8217;  module.  When specifying the components you want to load, be sure to reference <a href="http://developer.yahoo.com/yui/yuiloader/#modulenames" target="_blank">the module names for the YUI loader</a>.</p>
<p>You can also access elements using the YAHOO.util.Dom.getElementsByClassName() function to retrieve an array of elements based on their class name.  You can also specify the type of tag (i.e. &#8216;div&#8217; or &#8216;form&#8217;) as the second argument, and a root element as the third argument to be more explicit about the elements that are returned.  Let&#8217;s look an example.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p211code4'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2114"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
</pre></td><td class="code" id="p211code4"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> $<span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> myObj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #006600; font-style: italic;">//This function is called from the onSuccess method of my YUI loader</span>
	init<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//create helper shortcuts</span>
		$ <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">attachEvents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	attachEvents<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #003366; font-weight: bold;">var</span> Dom <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span><span style="color: #339933;">;</span>
		<span style="color: #003366; font-weight: bold;">var</span> elements <span style="color: #339933;">=</span> Dom.<span style="color: #660066;">getElementsByClassName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'clickbutton'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span>elements<span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">activate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
	activate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		window.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'You clicked me'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In the example code above, I have the same object with an attachEvents() method.  This is an improved version from the last post in this series.  We are now using the YAHOO.util.Dom.getElementsByClassName() function to get the array of elements on the page that have the class &#8216;clickbutton&#8217;.  I can then pass this array of elements into the YAHOO.util.Event.addListener() function.  Here we simply call the activate() method to alert the user that they have clicked the button.</p>
<h2>Positioning elements</h2>
<p>The YUI library also enables us to get and set (regardless of the position CSS attribute set on the element) the positioning of elements.  These are simple get and set functions that require the element object or element&#8217;s id string as the first argument.  These functions include: getX(), getY(), getXY(), setX(), setY(), and setXY().</p>
<h2>Styling elements</h2>
<p>YUI offers a quick and easy solution for adding and removing classes on elements.   This can be accomplished using either the Element class, or the DOM singleton.  Using the DOM singleton is more efficient, unless you have already have an instance of the Element.  To add a class to an element using YUI, simply:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p211code5'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2115"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p211code5"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'elementid'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myclass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>You can remove a class from an element using:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p211code6'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2116"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p211code6"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'elementid'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myclass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>And, you can also test if the element already has a class applied to it:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p211code7'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2117"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p211code7"><pre class="javascript" style="font-family:monospace;"><span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">hasClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'elementid'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myclass'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'elementid'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'myclass'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>In conclusion, the YUI library give you a simply and intuitive interface to programming in the land of the DOM; and makes it a lot less painful.  In the next post, we&#8217;ll show how the Selector class enables you to access elements in the DOM via a XPath syntax.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianflove.com/articles/2009/03/25/yui-and-the-dom/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Introduction to Design Patterns in ColdFusion</title>
		<link>http://blog.brianflove.com/articles/2009/03/10/introduction-to-design-patterns-in-coldfusion/</link>
		<comments>http://blog.brianflove.com/articles/2009/03/10/introduction-to-design-patterns-in-coldfusion/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 20:01:44 +0000</pubDate>
		<dc:creator>brian</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<category><![CDATA[CFUG]]></category>

		<category><![CDATA[Object-Oriented Programming]]></category>

		<category><![CDATA[OOP]]></category>

		<guid isPermaLink="false">http://blog.brianflove.com/?p=219</guid>
		<description><![CDATA[As part of the ColdFusion User Group of Central NY CF Object Oriented Programming (OOP) series, I presented design patterns in ColdFusion.  The objective of the presentation is to inform people about the basic design pattern principles that guide good OOP Programming.]]></description>
			<content:encoded><![CDATA[<p>As part of the <a href="http://cfugcny.org/" target="_blank">ColdFusion User Group of Central NY</a> CF Object Oriented Programming (OOP) series, I presented design patterns in ColdFusion.  The objective of the presentation is to inform people about the basic design pattern principles that guide good OOP Programming:</p>
<ul style="margin-left: 1.5em;">
<li>Encapsulate what varies.</li>
<li>Program to the interface, not the implementation.</li>
<li>Favor composition over inheritance.</li>
<li>Strive for loosely coupled designs between objects that interact.</li>
</ul>
<p>We also learned about the Open-Closed Principle; and how following these guidelines can make for better code that is more adaptable to change.</p>
<p>The examples used are politely borrowed from Head First Design Patterns.  I had intended to create my own examples, but ran out of time and figured that their examples are great for showing the concepts.</p>
<p>To begin with, we talked about how we can use the Strategy Pattern to encapsulate the &#8220;HAS-A&#8221; behaviors via composition.  Following that, the Decorator Pattern was shown to highlight the Open-Closed Principle and how we can program to an interface (or super-class) instead of the implementation (or concrete class).  Lastly, we touched on the factory &#8220;pattern&#8221; (or programming idiom, you decide) and how we can further encapsulate our dependencies into a Simple Factory.</p>
<p>The next part in our CF OOP series is Inversion of Control, or in other words, using <a href="http://www.coldspringframework.org/" target="_blank">ColdSpring</a>.</p>
<p>Here are the links to the slides and resources used in the presentation:</p>
<ul>
<li><a href="http://docs.google.com/Presentation?id=dddsgszp_8d93wz9cf" target="_self">Introduction to Design Patterns Presentation</a></li>
<li>Example files: <a href="http://github.com/blove/cf-design-patterns/tree/master">http://github.com/blove/cf-design-patterns/tree/master</a></li>
<li><a href="http://argouml.tigris.org/">Argo UML</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianflove.com/articles/2009/03/10/introduction-to-design-patterns-in-coldfusion/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Creating a TinyUrl with CF</title>
		<link>http://blog.brianflove.com/articles/2009/02/05/creating-a-tinyurl-with-cf/</link>
		<comments>http://blog.brianflove.com/articles/2009/02/05/creating-a-tinyurl-with-cf/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 16:46:49 +0000</pubDate>
		<dc:creator>brian</dc:creator>
		
		<category><![CDATA[ColdFusion]]></category>

		<guid isPermaLink="false">http://blog.brianflove.com/?p=214</guid>
		<description><![CDATA[Creating a TinyURL using ColdFusion is super simple, but I thought I would share if you are wondering where to start.]]></description>
			<content:encoded><![CDATA[<p>Creating a TinyURL using ColdFusion is super simple, but I thought I would share if you are wondering where to start.   Its as easy as calling the api-create.php file and sending in the URL to shorten.  The service then responds with the new URL:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p214code8'); return false;">View Code</a> COLDFUSION</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2148"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p214code8"><pre class="coldfusion" style="font-family:monospace;">&lt;cfset urlToShorten = 'http://blog.brianflove.com/articles/2009/01/23/getting-started-with-yui/'&gt;
&nbsp;
&lt;cfhttp url=&quot;http://www.tinyurl.com/api-create.php?url=#urlencodedformat(urlToShorten)#&quot; method=&quot;GET&quot; result=&quot;response&quot;&gt;
&lt;cfif ucase(trim(response.StatusCode)) eq '200 OK'&gt;
	&lt;cfset tinyUrl = response.FileContent&gt;
&lt;/cfif&gt;</pre></td></tr></table></div>

<p>And that&#8217;s all there is to it <img src='http://blog.brianflove.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianflove.com/articles/2009/02/05/creating-a-tinyurl-with-cf/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Getting started with YUI</title>
		<link>http://blog.brianflove.com/articles/2009/01/23/getting-started-with-yui/</link>
		<comments>http://blog.brianflove.com/articles/2009/01/23/getting-started-with-yui/#comments</comments>
		<pubDate>Fri, 23 Jan 2009 18:21:46 +0000</pubDate>
		<dc:creator>brian</dc:creator>
		
		<category><![CDATA[Javascript]]></category>

		<category><![CDATA[Web2.0]]></category>

		<category><![CDATA[YUI]]></category>

		<guid isPermaLink="false">http://blog.brianflove.com/?p=203</guid>
		<description><![CDATA[The Yahoo User Interface is very extensive JavaScript library that enables a developer to easily create a next generation web application.  Why am I using YUI? Well, as you know I like the Ext library, which was originally built as an extension to the YUI library.  If you have worked with either Ext or YUI, you can pick up the other one pretty quickly.]]></description>
			<content:encoded><![CDATA[<p>The Yahoo User Interface is very extensive JavaScript library that enables a developer to easily create a next generation web application.  Why am I using YUI? Well, as you know I like the Ext library, which was originally built as an extension to the YUI library.  If you have worked with either Ext or YUI, you can pick up the other one pretty quickly.</p>
<p>Now, let me provide a little background with what I believe are the Pros and Cons of the YUI library.</p>
<p><strong>Pros</strong></p>
<ul>
<li>Fully documented, with a great API browser</li>
<li>Very consistent and reliable</li>
<li>Ease of widget interoperability</li>
<li>Supported in several &#8220;A-Grade&#8221; browsers</li>
<li>Unit testing framework</li>
</ul>
<p><strong>Cons</strong></p>
<ul>
<li>Heavy page weight</li>
<li>Verbose code (lengthy)</li>
<li>Very few utility or helper functions/methods</li>
</ul>
<p>Overall, I think that if you evaluate the yui library in the context of other libraries that I have used such as Prototype, jQuery, and Ext the 2.x generation of yui is lacking the coolness that the other libraries bring to the table.  For example, implementing a sortable list in Prototype is super simple &#8212; a one liner.  The equivalent code in YUI is several lines long (~100) to get similar behavior.  Yui also lacks the use of chaining methods together like jQuery provides.  Please don&#8217;t think I am bashing the yui library, its a fantastic javascript library that is very powerful, and the 3.x generation is looking like a nice improvement.</p>
<p>So, why use YUI?  Because you can easily create a great looking web application that works seamlessly without needing additional JS libraries and plugins.  Almost all the functionality you are looking to include in your next generation web application is right there.  No need to go looking on Google for a Grid plugin, or a calendar widget &#8212; everything is included, and works together beautifully.</p>
<h2><strong>Lets see some code</strong></h2>
<p>OK, lets get started with the YUI library now that we have a little background.</p>
<p>This post will get you started with the YUI loader (to get the necessary JS files to the client) and the YAHOO.util.Event class.</p>
<h2><strong>YUI Loader</strong></h2>
<p>If you plan on creating an application that will depend on several of the YUI components, then the loader will simplify your life.  The YUI loader handles dependencies, rolling-up the JS into a single file, and compression.  Here is an exammple of the YUI loader:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p203code9'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p2039"><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code" id="p203code9"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> loader <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">YUILoader</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
	base<span style="color: #339933;">:</span> <span style="color: #3366CC;">'http://ajax.googleapis.com/ajax/libs/yui/2.6.0/build/'</span><span style="color: #339933;">,</span>
	require<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">'yahoo'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'dom'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'event'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'logger'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'animation'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'autocomplete'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'button'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'container'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'datasource'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'datatable'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'element'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'json'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'selector'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'paginator'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'tabview'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
	combine<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	timeout<span style="color: #339933;">:</span><span style="color: #CC0000;">10000</span><span style="color: #339933;">,</span>
	loadOptional<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	onSuccess<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//create namespace</span>
		YAHOO.<span style="color: #003366; font-weight: bold;">namespace</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'webbiz'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">augmentObject</span><span style="color: #009900;">&#40;</span>YAHOO.<span style="color: #660066;">webbiz</span><span style="color: #339933;">,</span>webBizObj<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		YAHOO.<span style="color: #660066;">webbiz</span>.<span style="color: #660066;">init</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Above, I am specifying the YUI components to load from the Google Ajax APIs service.  You can see that the array of components is not order dependent, remember that the loader will handle all of that for us.  The <em>onSuccess </em>handler is the function you want to call after the necessary component have been loaded.  Here, I create a custom namespace for my application, and then append (think of Objext.extend in Prototype) an existing object into this namespace.</p>
<h2><strong>YAHOO.util.Event</strong></h2>
<p>OK, so we have loaded YUI into the DOM, and we are ready to get started.  One of the first components that you need to understand is the <a href="http://developer.yahoo.com/yui/event/" target="_blank">Event</a> class in YUI.  The event class abstracts the browser event implementations away, so you can rely on your events working across a majority of the browsers out there.  So, what does this event class do?  Here&#8217;s a quick rundown:</p>
<ul>
<li>Attaching events to one or more elements at one time</li>
<li>Removing events from elements</li>
<li>Scope correction</li>
<li>Automatic cleanup</li>
<li>Knowing when an element is available in the DOM</li>
<li>Custom events</li>
</ul>
<h2><strong>YAHOO.util.Event.addListener</strong> or <strong>YAHOO.util.on</strong></h2>
<p>The addListener method of the Event class allows us to append an event handler to an element, a critical component of keeping your javascript out of the presentation layer &#8212; unobtrusive JS.  Here is a quick example:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p203code10'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p20310"><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code" id="p203code10"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myelement'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">display</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'none'</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>The first argument is the element object, or the element ID. The second argument is the event type, which can include event types such as change, mouseover, mouseout, keyup, etc&#8230;  The third argument is the function to call.</p>
<h2>Scope declaration</h2>
<p>The fourth argument is not used in this simple example above, but can be used to pass an object as the second argument to the callback function (the event object is the first argument).  You can also use the fourth argument to specify the scope object, and set the fifth argument to true.  Here is an example of ensuring the this scope within the callback function is set properly:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p203code11'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p20311"><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code" id="p203code11"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</span> <span style="color: #339933;">=</span> <span style="color: #3366CC;">'Web Biz'</span><span style="color: #339933;">;</span>
	YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myelement'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		window.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #000066;">name</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Notice that the <em>this </em>scope in the example above no longer is the event&#8217;s <em>currentTarget </em>but the <em>this </em>scope of the outer function.  When we click on the element &#8216;myelement&#8217;, we will get a JavaScript alert with the contents &#8216;Web Biz&#8217;.</p>
<p>Removing events<br />
This one is quite simple, its just a matter of using YAHOO.util.Event.removeListener(), here is an example of removing all &#8216;click&#8217; events from the element &#8216;myelement&#8217;:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p203code12'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p20312"><td class="line_numbers"><pre>1
</pre></td><td class="code" id="p203code12"><pre class="javascript" style="font-family:monospace;">YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">removeListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myelement'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<h2><strong>Handler attachment deferral</strong></h2>
<p>This a neat feature of the YUI library that I don&#8217;t think exists in very many other libraries.  If you call YAHOO.util.Event.on(&#8217;myelement&#8217;, &#8230;) and the element with an ID of &#8216;myelement&#8217; doesn&#8217;t yet exist in the DOM, then it will periodically check for its existence, and once found will add the event handler.  Note, this will not work if you pass the first argument as an element object reference instead of the string of the element&#8217;s ID.</p>
<h2><strong>Knowing when an element exists</strong></h2>
<p>This section goes along with the last one.  YUI is great at knowing the state of the DOM, and allows you to prep your events before the element exists (think of declaring your event handlers before the Ajax call has returned and injected the html into the DOM).</p>
<p>There are several method included in YUI, including <em>YAHOO.util.Event.onDomReady()</em> which fires before window.onload but after the DOM is loaded (images and other assets might still be loading).  <em>YAHOO.util.Event.onContentReady()</em> fires when an element and it&#8217;s <em>nextSibling </em>is also loaded.  The most useful one, IMHO, is the <em>YAHOO.util.Event.onAvailable() </em>method.  Here is a quick example of this method:</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p203code13'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table width="100%" ><tr id="p20313"><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
</pre></td><td class="code" id="p203code13"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> myObj <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	getStuff<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">attachEvents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Connect</span>.<span style="color: #660066;">asyncRequest</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'POST'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'test.cfm'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
			success<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>t<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Dom</span>.<span style="color: #660066;">get</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'myelement'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">innerHTML</span> <span style="color: #339933;">=</span> YAHOO.<span style="color: #660066;">lang</span>.<span style="color: #660066;">trim</span><span style="color: #009900;">&#40;</span>t.<span style="color: #660066;">responseText</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			failure<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				window.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'Oops, something went wrong. Give it another try.'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			scope<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	attachEvents<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">onAvailable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mybutton'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			YAHOO.<span style="color: #660066;">util</span>.<span style="color: #660066;">Event</span>.<span style="color: #660066;">addListener</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'mybutton'</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">'click'</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">activate</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">this</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	activate<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		window.<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'You clicked the button'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
myObj.<span style="color: #660066;">getStuff</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Here, I have encapsulated some methods into an object myObj, and I am utilizing the scope correction features of the Event class to keep the <em>this </em>scope within my methods to the myObj object reference.  Notice that within the getStuff() method, I am calling the <em>attachEvents()</em> method before calling my test.cfm file via Ajax.  The &#8216;mybutton&#8217; element doesn&#8217;t yet exist in the DOM, but I can be sure that once it does, it will have the event handler on the click event that calls the <em>activate()</em> method.</p>
<p>Hopefully this posting will give you a glimpse into the world of YUI, and encourage you to check it out and learn more about it.  I hope to continue this with a series of posting about using YUI.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.brianflove.com/articles/2009/01/23/getting-started-with-yui/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
