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

<channel>
	<title>Dan's Drivelings &#187; ColdSpring</title>
	<atom:link href="http://dan.skaggsfamily.ws/category/coldspring/feed/" rel="self" type="application/rss+xml" />
	<link>http://dan.skaggsfamily.ws</link>
	<description>Random Thoughts of a Techno-Hermit</description>
	<lastBuildDate>Thu, 09 Sep 2010 02:37:19 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Building Advanced Workflows with ColdSpring at cf.Obective()</title>
		<link>http://dan.skaggsfamily.ws/2010/04/24/building-advanced-workflows-with-coldspring-at-cf-obective/</link>
		<comments>http://dan.skaggsfamily.ws/2010/04/24/building-advanced-workflows-with-coldspring-at-cf-obective/#comments</comments>
		<pubDate>Sat, 24 Apr 2010 22:53:03 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>
		<category><![CDATA[cf.Objective()]]></category>

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

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=315</guid>
		<description><![CDATA[I&#8217;ve attached my slides from the my CFinNC session called &#8220;ColdSpring: Solution to a Problem You May Not Know You Have&#8221;. I&#8217;ve also included the example files that I referenced during the presentation. The slides have been uploaded to SlideSix.com or you can view them below. A PDF version of the slides is also available [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve attached my slides from the my <a href="http://www.cfinnc.com" target="_blank">CFinNC</a> session called &#8220;ColdSpring: Solution to a Problem You May Not Know You Have&#8221;. I&#8217;ve also included the <a href='http://dan.skaggsfamily.ws/wp-content/uploads/2009/10/ColdSpring-Demo-CFinNC-2009.zip'>example files</a> that I referenced during the presentation.</p>
<p>The slides have been uploaded to <a href="http://slidesix.com/view/ColdSpring-A-Solution-to-a-Problem-You-May-Not-Know-You-Have" target="_blank">SlideSix.com</a> or you can view them below. A <a href='http://dan.skaggsfamily.ws/wp-content/uploads/2009/10/CFinNC-09-Preso.pdf'>PDF version</a> of the slides is also available for download.</p>
<p>Thanks to all those folks that attended my session. Also a huge thanks and a job well done to the conference committee and volunteers that made the conference happen.</p>
<p><object height="425" width="550"><param name="movie" value="http://slidesix.com/viewer/SlideSixViewer.swf?alias=ColdSpring-A-Solution-to-a-Problem-You-May-Not-Know-You-Have" /><param name="menu" value="false"/><param name="scale" value="noScale"/><param name="allowFullScreen" value="true"/><param name="allowScriptAccess" value="always" /><param value="transparent" name="wmode" /><param value="quality" name="best" /><embed src="http://slidesix.com/viewer/SlideSixViewer.swf?alias=ColdSpring-A-Solution-to-a-Problem-You-May-Not-Know-You-Have" allowscriptaccess="always" allowFullScreen="true" height="425" width="550" type="application/x-shockwave-flash" wmode="transparent" quality="best" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://dan.skaggsfamily.ws/2009/10/18/slides-from-my-coldspring-session-at-cfinnc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>I&#8217;m presenting at the CF in NC conference in October</title>
		<link>http://dan.skaggsfamily.ws/2009/08/24/im-presenting-at-the-cf-in-nc-conference-in-october/</link>
		<comments>http://dan.skaggsfamily.ws/2009/08/24/im-presenting-at-the-cf-in-nc-conference-in-october/#comments</comments>
		<pubDate>Mon, 24 Aug 2009 19:08:53 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>
		<category><![CDATA[Speaking Engagements]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=293</guid>
		<description><![CDATA[I am super excited to announce that I&#8217;ve been selected to present a session at the CF in NC conference in Raleigh, NC in October. This will be my first time presenting to a conference setting and I am really looking forward to the experience. Just last week I gave my first ever technical presentation [...]]]></description>
			<content:encoded><![CDATA[<p>I am super excited to announce that I&#8217;ve been selected to present a session at the <a href="http://www.cfinnc.com">CF in NC</a> conference in Raleigh, NC in October. This will be my first time presenting to a conference setting and I am really looking forward to the experience.  Just last week I gave my first ever technical presentation to the <a href="http://www.meetup.com/coldfusionmeetup/">CFMeetup</a> group and got some great feedback.</p>
<p>I&#8217;ll be presenting an introduction to dependency injection using the ColdSpring framework titled &#8220;Intro to ColdSpring: A solution to a problem you may not know you have&#8221;.</p>
<p>I&#8217;m also looking forward to meeting face-to-face with a bunch of folks I&#8217;ve interacted with digitally over the last few years.  Hope to see a bunch of you there! </p>
]]></content:encoded>
			<wfw:commentRss>http://dan.skaggsfamily.ws/2009/08/24/im-presenting-at-the-cf-in-nc-conference-in-october/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Standardizing HTML forms with the cfUniForm custom tag library</title>
		<link>http://dan.skaggsfamily.ws/2009/04/29/standardizing-html-forms-with-the-cfuniform-custom-tag-library/</link>
		<comments>http://dan.skaggsfamily.ws/2009/04/29/standardizing-html-forms-with-the-cfuniform-custom-tag-library/#comments</comments>
		<pubDate>Wed, 29 Apr 2009 18:21:25 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=199</guid>
		<description><![CDATA[As web developers one of the most frequent things we&#8217;re tasked with building is some sort of form to capture data from our visitors. As we&#8217;ve all learned (some of us the hard way), putting a form out there and trusting that our visitors will use it exactly the way we design it every time [...]]]></description>
			<content:encoded><![CDATA[<p>As web developers one of the most frequent things we&#8217;re tasked with building is some sort of form to capture data from our visitors.  As we&#8217;ve all learned (some of us the hard way), putting a form out there and trusting that our visitors will use it exactly the way we design it every time is the proverbial pipe dream. How many times have each of us written Javascript functions to validate the entries into form fields? It&#8217;s much the same every time and, honestly, it gets old reinventing the wheel each time. Enter <a href="http://cfuniform.riaforge.org/" target="_blank">cfUniform</a>, a very robust, open-source custom tag library from Matt Quackenbush (with others contributing).</p>
<p>cfUniform is a ColdFusion custom tag library that makes adding validation to your forms a snap.  The fact that it writes (most) validation for you based on attributes you put in the tag makes it worth using for that feature alone in my mind. However, the benefits don&#8217;t stop with validation.  It also styles your form fields, labels, hints and error messages for you.  Since you can configure a link to a CSS stylesheet in the configuration for the custom tag, you can skin the output generated by cfUniform to match your site&#8217;s look and feel.<br />
<span id="more-199"></span></p>
<p>Best of all, its REALLY easy to get started with.  The example below assumes that you&#8217;ve put /tags and /commonassets folders from the distribution file in the root of your web site.</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
</pre></td><td class="code"><pre class="cfml" style="font-family:monospace;">&lt;cfimport taglib=&quot;/tags/forms/cfUniForm&quot; prefix=&quot;uform&quot; /&gt;
&nbsp;
&lt;div class=&quot;cfUniForm-form-container&quot;&gt;
	&lt;uform:form action=&quot;someFile.cfm&quot; 
		id=&quot;loginForm&quot; 
		submitValue=&quot; Log In &quot; 
		loadjQuery=&quot;true&quot; 
		loadValidation=&quot;true&quot; 
		loadMaskUI=&quot;true&quot; 
		loadDateUI=&quot;false&quot; 
		loadTimeUI=&quot;false&quot;&gt;
&nbsp;
		&lt;uform:fieldset legend=&quot;&quot;&gt;
&nbsp;
			&lt;uform:field label=&quot;User Name&quot; 
			       name=&quot;username&quot; 
			       isRequired=&quot;true&quot; 
			       type=&quot;text&quot;  
			       hint=&quot;Enter your user name.&quot; /&gt;
&nbsp;
			&lt;uform:field label=&quot;Password&quot; 
				name=&quot;password&quot; 
				isRequired=&quot;true&quot; 
				type=&quot;password&quot;  
				hint=&quot;Enter your password.&quot; /&gt;	
&nbsp;
		&lt;/uform:fieldset&gt;		
	&lt;/uform:form&gt;
&lt;/div&gt;</pre></td></tr></table></div>

<p>That simple example gets you a login form that has javascript validation requiring a value in both fields as well as Javascript-driven error message feedback to the user when they don&#8217;t fill out one of the fields.  Obviously this is a very simple use case and cfUniform supports a whole range of things you typically want to do on a form.  If you have a very specific validation case, you can even specify your own custom javascript to use as the validation when the form is submited.</p>
<p>If you&#8217;re like me, you&#8217;ve probably got a &#8220;pet&#8221; folder structure that you use for your projects and they typically don&#8217;t have the folders /tags and /commonassets hanging off the root.  The developers foresaw this quandary and included the facility to pass in a structure containing configuration keys that point the library to the location of various files in the web structure. This is one of my favorite features because it allows me to compartmentalize the library into whatever part of my folder structure I want and then pass in the configuration values. It also makes it very easy to configure a config object in ColdSpring using a MapFactoryBean (remember talking about those a couple weeks ago in this post?) so that you reuse the same configuration object every time you use the library throughout your application.</p>
<p>I&#8217;ve not gone into a great amount of detail here on how to use the many features of the library because the developers have a <a href="http://www.quackfuzed.com/demos/cfUniForm/" target="_blank">well-rounded set of examples</a> already published.  There you&#8217;ll see the directions for how to set up a MapFactoryBean config object in ColdSpring as well as all the other form field options that you have in the framework.</p>
<p>Thanks to Matt and the other developers for removing a great portion of the mundane Javascript validation stuff and giving us an easy-to-use library to standardize the look and feel of our forms.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.skaggsfamily.ws/2009/04/29/standardizing-html-forms-with-the-cfuniform-custom-tag-library/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Making configuration even easier with ColdSpring&#8217;s hidden gems</title>
		<link>http://dan.skaggsfamily.ws/2009/04/01/making-configuration-even-easier-with-coldsprings-hidden-gems/</link>
		<comments>http://dan.skaggsfamily.ws/2009/04/01/making-configuration-even-easier-with-coldsprings-hidden-gems/#comments</comments>
		<pubDate>Wed, 01 Apr 2009 05:11:46 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=168</guid>
		<description><![CDATA[In my last post, we went through a brief introduction of ColdSpring and how you can use it to make configuring your application&#8217;s objects much easier. We discussed how objects (beans) are declared in ColdSpring&#8217;s XML configuration file and how you can pass any number of values into ColdSpring to be used in configuring those [...]]]></description>
			<content:encoded><![CDATA[<p>In my last post, we went through a brief introduction of ColdSpring and how you can use it to make configuring your application&#8217;s objects much easier. We discussed how objects (beans) are declared in ColdSpring&#8217;s XML configuration file and how you can pass any number of values into ColdSpring to be used in configuring those beans using the defaultProperties argument when you create the ColdSpring obect. At the end of the post, we touched on a slight &#8220;problem&#8221; with using ColdSpring this way. </p>
<p>To be fair, the &#8220;problem&#8221; isn&#8217;t with ColdSpring at all. The problem is with us developers&#8211;we&#8217;re lazy and we hate redundant typing.  In a large application with dozens or more objects, we don&#8217;t want to constantly have to type ${dsn} every time we want to inject the DSN property into a bean. Multiply dozens of objects by potentially several properties needed by each object and you can set yourself up for quite a bit of typing, just to get the beans configured (and that doesn&#8217;t even take into account that most of us are bad typists and can&#8217;t spell DSN the same way a dozen times in a row).<span id="more-168"></span>Luckily for us, the brilliant folks that gave us ColdSpring built in a couple of beans that we can use to solve the &#8220;problem&#8221;. Those beans are called the <strong>MapFactoryBean</strong> and the <strong>ListFactoryBean</strong>. Don&#8217;t be scared off by their names. Their functions actually mimic a couple of ColdFusion data types that you already use every day anyway.</p>
<h2>What&#8217;s a MapFactoryBean anyway?</h2>
<p>A MapFactoryBean is ColdSpring&#8217;s method of storing any number of key/value pairs so they can be inserted easily together into your components. What&#8217;s that? You say that ColdFusion has something built in that does key/value pairs in a single variable? You&#8217;d be correct Grasshopper.  MapFactoryBeans are ColdSpring&#8217;s way to configure a ColdFusion structure that will be passed in as an argument to your other beans.</p>
<p>Before MapFactoryBeans, using just properties, we might have something similar to the code below in dozens of objects in our config file:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;MySuperService&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;components.services.MySuperService&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;key1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value1}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;key2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value2}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;key3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value3}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Now, we can set those properties into a MapFactoryBean once.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;PropertyMapBean&quot;</span> </span>
<span style="color: #009900;">   <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;coldspring.beans.factory.config.MapFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
   <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;SourceMap&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;key1&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value1}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;key2&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value2}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;entry</span> <span style="color: #000066;">key</span>=<span style="color: #ff0000;">&quot;key3&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value3}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/entry<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/map<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Remember in my last post we talked about ColdSpring&#8217;s ability to inject other beans as arguments into your beans?  Now that we have our properties consolidated into a MapFactoryBean, you can inject it into your other beans rather than passing in individual properties each time.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;MySuperService&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;components.services.MySuperService&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span> 
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;configProperties&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;PropertyMapBean&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p><strong>NOTE:</strong> Don&#8217;t forget to include the XML node &lt;property name=&#8221;SourceMap&#8221;&gt;. It&#8217;s important.</p>
<h2>So then a ListFactoryBean must be&#8230;</h2>
<p>&#8230;the equivalent of a ColdFusion list then right? Well, close but no cigar for you on that one.  ListFactoryBeans actually give you the ability to pass a ColdFusion array into your beans. You get partial credit though because at least you were thinking &#8220;outside the bean&#8221;.</p>
<p>Creating a ListFactoryBean is just as easy as creating a MapfactoryBean.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;PropertyListBean&quot;</span> </span>
<span style="color: #009900;">    <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;coldspring.beans.factory.config.ListFactoryBean&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;property</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;sourceList&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value1}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value2}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
          <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${value3}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/list<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/property<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>As before you can now pass this into your beans and use it in your objects as a native ColdFusion array.</p>
<h2>Why use these two beans?</h2>
<p>You may be asking yourself, &#8220;why can&#8217;t I just use ColdFusion structures and arrays instead of these fancy-schmancy beans&#8221;. That&#8217;s a great question. The answer lies in the fact that ColdSpring&#8217;s beans and attributes are configured via XML.  Ever tried to create a ColdFusion variable inside an XML file? Nah, didn&#8217;t think you had.  I&#8217;m being a bit flippant there I realize, but the bottom line is that ColdSpring uses these two beans to give us a way to create ColdFusion native data types from within our XML configuration.</p>
<p>So, as you can see from the above, simplified examples, the ColdSpring crew has done a fantastic job of not only giving us a tool (ColdSpring) to make our lives easier, they&#8217;ve also given tools (MapFactoryBeans and ListFactoryBeans) to the tool to help us with our redundant typing phobia.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.skaggsfamily.ws/2009/04/01/making-configuration-even-easier-with-coldsprings-hidden-gems/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ColdSpring: An answer to a problem you may not know you have</title>
		<link>http://dan.skaggsfamily.ws/2009/03/29/coldspring-an-answer-to-a-problem-you-may-not-know-you-have/</link>
		<comments>http://dan.skaggsfamily.ws/2009/03/29/coldspring-an-answer-to-a-problem-you-may-not-know-you-have/#comments</comments>
		<pubDate>Mon, 30 Mar 2009 00:44:30 +0000</pubDate>
		<dc:creator>Dan Skaggs</dc:creator>
				<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdSpring]]></category>

		<guid isPermaLink="false">http://dan.skaggsfamily.ws/?p=151</guid>
		<description><![CDATA[Over the last two years or so I&#8217;ve been working hard to really &#8220;get&#8221; object-oriented programming as it applies to ColdFusion development. Like a lot of ColdFusion developers that have been around a while, when I started trying to create applications using CFCs, I essentially had CFCs that were collections of UDFs. Before long, after [...]]]></description>
			<content:encoded><![CDATA[<p>Over the last two years or so I&#8217;ve been working hard to really &#8220;get&#8221; object-oriented programming as it applies to ColdFusion development. Like a lot of ColdFusion developers that have been around a while, when I started trying to create applications using CFCs, I essentially had CFCs that were collections of UDFs. Before long, after talking with other developers that understood OO principles, I started making my CFCs more &#8220;object&#8217;y&#8221; as I learned more about those principles.</p>
<p>Along the way I naturally heard about various frameworks related to ColdFusion (Fusebox, Model-Glue, Mach-II, ColdSpring etc etc) but never gave them more than a passing glance as I was trying to cram a bunch of new concepts into my brain as it was and I just didn&#8217;t have the mental bandwidth to take on frameworks at the same time (however that has since changed and I&#8217;ve had a chance to work with Mach-II and Model-Glue).  Eventually I got to the point where my applications used numerous objects and some of those objects required the services of other objects to do their jobs. That&#8217;s the point that I really began struggling with the effort involved in writing a good OO application. It took lots of lines of code to create an object, configure it simply to pass it into another object.  Sound familiar? Maybe you&#8217;re at that point with your ColdFusion OO trek. If so, read on and I&#8217;ll introduce you to ColdSpring, a free dependency-injection framework (whoa there, stay with me, don&#8217;t let the buzzwords turn you off) that will make your life much easier.<span id="more-151"></span><br />
<h2>What is ColdSpring?</h2>
<p>The simplest way to describe what ColdSpring does for us (for dependency injection at least) is to think of it as an centralized place where we can go to retrieve fully-configured, ready-to-use objects within our code. We ask the ColdSpring object for a particular ?bean? (every object in ColdSpring is referred to as a bean&#8230;don?t get that confused with a bean in the Gateway/DAO/bean design pattern) and ColdSpring creates the object, runs the init methods with any arguments and hands it back to us ready to use.  If one of the arguments happens to be another object, ColdSpring creates that object, inserts it into the init function automatically. Sounds great right? Trust me, it gets better.</p>
<p>There are two main benefits of using ColdSpring this way.</p>
<ol>
<li>The configuration for a specific ?bean? is confined to one place (the coldspring.xml file) so if something changes with the object, you don?t have to go searching all over your code base to update all the places where you?ve manually created the object.</li>
<li>Object creation and configuration is the same <strong>every time</strong> meaning that you don?t have to remember all the configuration parameters every place in your code where you need to use that object.</li>
</ol>
<p>There?s a third, less obvious advantage to using ColdSpring to manage your objects.  When you define an object in ColdSpring, you can elect to tell ColdSpring to make it a singleton (meaning that only one instance of this object will ever exist in your entire application). Any time after application init that you ask for that object, ColdSpring will hand you the copy of it that already exists, eliminating the time required to create and configure a new instance.</p>
<p>This benefit comes with a bit of a caution however. You should never create any objects as singletons that store session-specific data (such as a Product, User, etc). DAOs, Gateways, Config objects and the like are prime candidates for singleton status because, while they have attributes within them that they need to do their jobs, they simply move data around as requested, never storing that actual data within themselves.</p>
<h2>How ColdSpring makes life easier</h2>
<p>Using ColdSpring increases modularity within our code base.  Essentially, each CFC should be as ?dumb? to the world outside itself as possible.  Code within a CFC should not reach out to shared scopes to pull values (eg Application, Session, Server scopes, etc). It should not be responsible for knowing the dot-notated path to a particular object that it needs to use to do its work. This is sometimes referred to as the ?Law of Demeter? or ?Principle of Least Knowledge?. Essentially, this principle states that an object should be provided everything it needs (called dependencies) to do its job and should not have to have knowledge of anything outside itself and the objects that are given to it in order to perform its work.</p>
<p>For example, consider a DAO component that requires a datasource to run its queries. If you hard code #application.dsn# into the datasource attribute of every &lt;cfquery&gt; tag and someone comes along and decides that a more verbose variable name (say application.datasource) is preferable, you have to manually update every  &lt;cfquery&gt; tag in your application.</p>
<p>However, if you?ve created a private variables.datasource property inside your DAO component and included a &lt;cfargument&gt; in your init function that takes the name of a datasource which is then stored in your private property, your &lt;cfquery&gt; tags have no need to know that, outside your DAO component,  you?ve changed the name of the variable storing that string. This is, admittedly, a simple example, but the same holds true whether it?s a simple value or another object that is required to be passed in so your component can do its job.</p>
<p>ColdSpring makes adhering to this principle much easier than if you were doing all the dependency creation by hand before passing it into the object.  By specifying in your datasource as a default property when you create the ColdSpring object, you can reuse that in all your objects.  Consider the following example to create the ColdSpring object:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--- Create ColdSpring defaultProperties ---&gt;</span>
<span style="color: #333333;"><span style="color: #0000FF;">&lt;</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span>
	defaultProperties = structNew();
	defaultProperties.dsn = &quot;myHighPoweredDatasource&quot;;
	defaultProperties.mailServer = &quot;mail.mydomain.com&quot;;
<span style="color: #333333;"><span style="color: #0000FF;">&lt;/</span><span style="color: #990000; font-weight: bold;">cfscript</span><span style="color: #0000FF;">&gt;</span></span></pre></td></tr></table></div>

<p>When you create the ColdSpring object and pass in the &#8220;defaultProperties&#8221; structure, you can then reference these values in your object creation.  For example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;CustomerDAO&quot;</span> </span>
<span style="color: #009900;">        <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;model.customers.CustomerDAO&quot;</span> <span style="color: #000066;">singleton</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;datasource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${dsn}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>The code above tells ColdSpring to create an object named CustomerDAO using the component located at model.customers.CustomerDAO. Once it?s created ColdSpring will run the init method (ColdFusion?s constructor method) and pass in the value of the default property &#8220;dsn&#8221; as an argument named datasource.  What this is accomplishing is effectively removing any link between your DAO component and the application.dsn variable.  Your component doesn?t know (and frankly doesn?t care) that there?s a value stored in the application scope&#8212;you?ve explicitly given the DAO object all it needs to do its job.</p>
<p>Notice if you will the last attribute on the &lt;bean&#8230;.&gt; line above. See that? Setting singleton=&#8221;true&#8221; means that there will only ever be one CustomerDAO object created in your application&#8212;a big plus if you?re constantly getting and putting customer records to/from the database through this object.</p>
<p>Constructor args to ColdSpring bean definitions need not be simple values.  Consider the following bean configuration entry from that same example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;bean</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;CustomerGateway&quot;</span> </span>
<span style="color: #009900;">	<span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;model.customers.CustomerGateway&quot;</span> <span style="color: #000066;">singleton</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;datasource&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>${dsn}<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/value<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;constructor-arg</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;dao&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
		<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;ref</span> <span style="color: #000066;">bean</span>=<span style="color: #ff0000;">&quot;CustomerDAO&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
	<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/constructor-arg<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/bean<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></td></tr></table></div>

<p>Our CustomerGateway object needs a datasource and a DAO object to be able to do its job. Here we&#8217;re creating a CustomerGateway object much the same way that we created the DAO.  The first constructor argument is the same datasource that we used in the DAO (hey, they need to talk to the same database right?). However, notice the content of the second &lt;constructor-arg&gt;. Here we?re not passing in a simple variable using the &lt;value&gt; tag.  We?re telling ColdSpring that it should pass the &#8220;bean&#8221; named &#8220;CustomerDAO&#8221; that we previously created to the init function of the CustomerGateway as an argument named DAO.</p>
<p>So, that?s a little different than passing in a simple string, right. Not according to ColdSpring.  The beauty of this is, Coldspring will create and configure the CustomerDAO &#8220;bean&#8221; first and then pass that fully-configured, ready-to-use (don&#8217;t forget singleton) object into the CustomerGateway bean (even if in your XML config file you have the DAO config AFTER the Gateway config).  </p>
<p>If you were doing this by hand, you?d have to manually create the DAO object, run the init function passing in the DSN. Then manually create the Gateway object, run the init function and pass in the DSN and the DAO object you just created&#8230;.every time you needed a Gateway object.  That?s a fair amount of work right?  ColdSpring does this all for you with a few simple lines on XML configuration and you can get on to more important parts of building the application.</p>
<h2>But what about&#8230;.</h2>
<p>Aha Grasshopper, I can see that you&#8217;ve realized something.  We&#8217;re continually having to manually type ${dsn} (and other string variables you need to give to your objects). That&#8217;s a lot of work right? Patience, Grasshopper, next time we&#8217;ll talk about two tools that the brilliant developers of ColdSpring gave us to solve that very (redundant) issue&#8212;the MapFactoryBean and the ListFactoryBean.  Until then&#8230;..</p>
<p>**Special thanks to my good friend <a href="http://www.nodans.com/" target="_blank">Dan Wilson</a> for his insight into object-oriented principles, ColdSpring and a bunch of other cool stuff.</p>
]]></content:encoded>
			<wfw:commentRss>http://dan.skaggsfamily.ws/2009/03/29/coldspring-an-answer-to-a-problem-you-may-not-know-you-have/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
