<?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>pukkared</title>
	<atom:link href="http://www.pukkared.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.pukkared.com</link>
	<description>Web Design &#38; Development</description>
	<lastBuildDate>Thu, 26 Aug 2010 01:44:22 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Looping over Arrays</title>
		<link>http://www.pukkared.com/?p=916</link>
		<comments>http://www.pukkared.com/?p=916#comments</comments>
		<pubDate>Thu, 26 Aug 2010 01:40:28 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.pukkared.com/?p=916</guid>
		<description><![CDATA[I&#8217;ve been working in CF 7 a lot lately.  This has forced me to look at writing Coldfusion differently from what I&#8217;m used to, being Coldfusion 8 &#38; 9.  An example is that in CF 7 there is no attribute available in the &#60;cfloop&#62; tag.  This means that I have to loop over an array [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been working in CF 7 a lot lately.  This has forced me to look at writing Coldfusion differently from what I&#8217;m used to, being Coldfusion 8 &amp; 9.  An example is that in CF 7 there is no attribute available in the &lt;cfloop&gt; tag.  This means that I have to loop over an array by looping from 1 to however long the array is.  There are two ways to loop over an array in CF 7.  First is to evaluate the array length with each loop, and the second is to set the length of the loop into a variable and loop from 1 to that value.</p>
<p>To illustrate the first example of evaluating with each loop the code would look like:</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;cfloop from=&quot;1&quot; to=&quot;#arrayLen(variables.myArray)#&quot; index=&quot;variables.i&quot;&gt;

&lt;/cfloop&gt;
</pre>
</div>
<p>and the to illustrate the second example of setting the length first the code would look like:</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;!-- set the length of the array --&gt;
&lt;cfset variables.aryLen = arrayLen(variables.myArray) /&gt;

&lt;cfloop from=&quot;1&quot; to=&quot;#variables.aryLen#&quot; index=&quot;variables.i&quot;&gt;

&lt;/cfloop&gt;
</pre>
</div>
<p>Lastly, in Coldfusion 8 &amp; 9 you can write it like the following:</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;cfloop array=&quot;#variables.myArray#&quot; index=&quot;variables.i&quot;&gt;

&lt;/cfloop&gt;
</pre>
</div>
<p>So of the first two options, clearly setting the length of the array into a variable has design advantages and should always be the preferred method.  Nonetheless I was curious if there was really a performance difference.</p>
<p>I used the following script to loop over an array with 100,000 values using the three above methods.</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;cfif NOT structKeyExists(SESSION, &quot;asAttribute&quot;)&gt;
	&lt;cfset SESSION.asAttribute = arrayNew(1) /&gt;
&lt;/cfif&gt;

&lt;cfif NOT structKeyExists(SESSION, &quot;setLength&quot;)&gt;
	&lt;cfset SESSION.setLength = arrayNew(1) /&gt;
&lt;/cfif&gt;

&lt;cfif NOT structKeyExists(SESSION, &quot;evaluateLength&quot;)&gt;
	&lt;cfset SESSION.evaluateLength = arrayNew(1) /&gt;
&lt;/cfif&gt;

&lt;cfif NOT structKeyExists(SESSION, &quot;refreshes&quot;)&gt;
	&lt;cfset SESSION.refreshes = 0 /&gt;
&lt;/cfif&gt;

&lt;cfset SESSION.refreshes = SESSION.refreshes + 1 /&gt;

&lt;cfoutput&gt;
	Number of refreshes: #SESSION.refreshes#&lt;br /&gt;&lt;br /&gt;
&lt;/cfoutput&gt;

&lt;!-- create an array --&gt;
&lt;cfset variables.myArray = arrayNew(1) /&gt;

&lt;!-- populate array --&gt;
&lt;cfloop from=&quot;1&quot; to=&quot;100000&quot; index=&quot;variables.i&quot;&gt;
	&lt;cfset variables.myArray[variables.i] = &quot;Value#variables.i#&quot; /&gt;
&lt;/cfloop&gt;

&lt;cfset variables.startCount = getTickCount() /&gt;

&lt;cfloop array=&quot;#variables.myArray#&quot; index=&quot;variables.i&quot;&gt;

&lt;/cfloop&gt;

&lt;cfset variables.endCount = getTickCount() /&gt;

&lt;cfset variables.processingTime = variables.endCount - variables.startCount /&gt;

&lt;cfset arrayAppend(SESSION.asAttribute, variables.processingTime) /&gt;

&lt;cfset variables.attributeAvg = arrayAvg(SESSION.asAttribute) /&gt;

&lt;cfoutput&gt;
	Using as an attribute - &lt;br /&gt;
	Average: #variables.attributeAvg#
&lt;/cfoutput&gt;

&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;

&lt;!-- set the length of the array --&gt;
&lt;cfset variables.aryLen = arrayLen(variables.myArray) /&gt;

&lt;cfset variables.startCount = getTickCount() /&gt;

&lt;cfloop from=&quot;1&quot; to=&quot;#variables.aryLen#&quot; index=&quot;variables.i&quot;&gt;

&lt;/cfloop&gt;

&lt;cfset variables.endCount = getTickCount() /&gt;

&lt;cfset variables.processingTime = variables.endCount - variables.startCount /&gt;

&lt;cfset arrayAppend(SESSION.setLength, variables.processingTime) /&gt;

&lt;cfset variables.attributeAvg = arrayAvg(SESSION.setLength) /&gt;

&lt;cfoutput&gt;
	Setting length in a varible - &lt;br /&gt;
	Average: #variables.attributeAvg#
&lt;/cfoutput&gt;

&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;

&lt;cfset variables.startCount = getTickCount() /&gt;

&lt;cfloop from=&quot;1&quot; to=&quot;#arrayLen(variables.myArray)#&quot; index=&quot;variables.i&quot;&gt;

&lt;/cfloop&gt;

&lt;cfset variables.endCount = getTickCount() /&gt;

&lt;cfset variables.processingTime = variables.endCount - variables.startCount /&gt;

&lt;cfset arrayAppend(SESSION.evaluateLength, variables.processingTime) /&gt;

&lt;cfset variables.attributeAvg = arrayAvg(SESSION.evaluateLength) /&gt;

&lt;cfoutput&gt;
	Evaluating length for each loop - &lt;br /&gt;
	Average: #variables.attributeAvg#
&lt;/cfoutput&gt;
</pre>
</div>
<p>Each was timed and stored in the session.  At the end of 10, 25, 50, and 100 page refreshes the average execution speed was determined for each method.</p>
<p>After all was said and done evaluating the array for each loop vs. setting the length and looping to the length was within 4 milliseconds running a loop over an array with 100,000 values.  The following chart illustrates the differences.<br />
<div id="attachment_862" class="wp-caption alignnone" style="width: 660px"><a href="http://blog.pukkared.com/wp-content/uploads/2010/08/array_avg.png"><img src="http://blog.pukkared.com/wp-content/uploads/2010/08/array_avg.png" alt="Array Looping Execution Comparison" title="Array Looping Execution Comparison" width="650" height="422" class="size-full wp-image-862" /></a><p class="wp-caption-text"> </p></div></p>
<p>Hopefully, what is obvious from this is not so much that there is little to no difference in the execution time between pre-setting the array length vs. evaluating it with each loop, but that using the array as an attribute (which can only be used in Coldfusion 8 &#038; 9) of the <cfloop> tag runs much faster than either of the other two methods.  About 25 milliseconds faster.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=916</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Showing line numbers in Visual C# 2010 Express</title>
		<link>http://www.pukkared.com/?p=909</link>
		<comments>http://www.pukkared.com/?p=909#comments</comments>
		<pubDate>Fri, 16 Jul 2010 00:44:12 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Visual C#]]></category>

		<guid isPermaLink="false">http://www.pukkared.com/?p=909</guid>
		<description><![CDATA[Thought I would share how to show line numbers for the code editor in Microsoft Visual C# Express because it is less than intuitive.  My personal opinion is that the numbers should show by default.  It makes a ton of sense to display error locations by line number, but not actually show the line numbers [...]]]></description>
			<content:encoded><![CDATA[<p>Thought I would share how to show line numbers for the code editor in Microsoft Visual C# Express because it is less than intuitive.  My personal opinion is that the numbers should show by default.  It makes a ton of sense to display error locations by line number, but not actually show the line numbers in the code editor.</p>
<p>Anyways, in the top navigation open tools &gt; options dialog.  In the dialog make sure you first check the &#8216;Show all settings&#8217; checkbox in the lower left corner.  Now expand the &#8216;Text Editor&#8217; menu item.  Click &#8216;All Languages&#8217;.  Lastly check the &#8216;Line numbers&#8217; checkbox in the options.  It should really not be this complicated.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=909</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Setting print margins using Eclipse to maintain line character length</title>
		<link>http://www.pukkared.com/?p=900</link>
		<comments>http://www.pukkared.com/?p=900#comments</comments>
		<pubDate>Sat, 15 May 2010 01:25:20 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Coldfusion 8]]></category>
		<category><![CDATA[Coldfusion 9]]></category>
		<category><![CDATA[Coldfusion Builder]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://www.pukkared.com/?p=900</guid>
		<description><![CDATA[Sometimes you may have standard line lengths with which to work when writing code.  If this is the case and your using Coldfusion and Eclipse with the cfEclipse plugin you can maintain the character length consistency by setting up the print margins to n character length.
Point being that when running the cfeclipse plugin you [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes you may have standard line lengths with which to work when writing code.  If this is the case and your using Coldfusion and Eclipse with the cfEclipse plugin you can maintain the character length consistency by setting up the print margins to n character length.</p>
<p>Point being that when running the cfeclipse plugin you need to choose CFEclipse &gt; Editor in the preferences left navigation.  In the options you will check &#8216;Show print margin&#8217;, set the &#8216;Print margin column&#8217; text field to the desired character length, and if you choose the &#8216;Print margin&#8217; option in the &#8216;Appearance color options&#8217; select box.  Then choose the color you wish the margin to be.  This will set a line length that will show in the code editor pane.  Of course it will not wrap the line. It is still your duty as a developer to wrap appropriately.  Nonetheless it does give you a guide for where the line should wrap at least.</p>
<p>If you&#8217;re writing Java then you would select General &gt; Editor &gt; Text Editors in the preferences pane.  Although the display is slightly different, generally follow the same steps as above for showing the print margin.</p>
<p>If you&#8217;re using Coldfusion Builder you will follow the same exact directions as listed just above for showing the print margins writing Java.</p>
<p>Lastly, if you&#8217;re using Flex Builder 3 you will again follow the same directions as above for showing print margins writing Java.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=900</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Android LinearLayout tag not stacking elements</title>
		<link>http://www.pukkared.com/?p=894</link>
		<comments>http://www.pukkared.com/?p=894#comments</comments>
		<pubDate>Fri, 07 May 2010 02:19:34 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=894</guid>
		<description><![CDATA[This is really more of a reference for myself than anything else.  Point being I just spent about half an hour trying to figure out why my TextViews were not showing up in my LinearLayout for my Android application.  What I was getting was the top level TextView but none of the others below it. [...]]]></description>
			<content:encoded><![CDATA[<p>This is really more of a reference for myself than anything else.  Point being I just spent about half an hour trying to figure out why my TextViews were not showing up in my LinearLayout for my Android application.  What I was getting was the top level TextView but none of the others below it.  As I moved them around in their order I realized that they were there, but falling behind the TextView on top.  So, clearly, the issue is that they are layering instead of stacking.</p>
<p>Just to make sure we&#8217;re all on the same page in resolving this issue (which is really not an issue at all) we&#8217;re working on a layout XML file for an Android application.  So if you&#8217;re using the built-in Eclipse Android plugin you will have a main.xml file by default in the res/layout directory.  If you delete the XML from this file and add a new LinearLayout from the layout perspective, and then add some TextViews or whatever, you&#8217;ll notice that only the top one shows.</p>
<p>So for example.</p>
<h3>Does not work</h3>
<div class="code">
<pre class="brush: xml;">
&lt;LinearLayout 	android:id=&quot;@+id/LinearLayout01&quot;
			android:layout_width=&quot;fill_parent&quot;
			android:layout_height=&quot;wrap_content&quot;
			xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
			android:background=&quot;@android:color/black&quot;&gt;

&lt;/LinearLayout&gt;
</pre>
</div>
<p>and&#8230;</p>
<h3>Does work</h3>
<div class="code">
<pre class="brush: xml;">
&lt;LinearLayout 	android:id=&quot;@+id/LinearLayout01&quot;
			android:layout_width=&quot;fill_parent&quot;
			android:layout_height=&quot;wrap_content&quot;
			xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
			android:background=&quot;@android:color/black&quot;
			android:orientation=&quot;vertical&quot;&gt;

&lt;/LinearLayout&gt;
</pre>
</div>
<p>For whatever reason, when you add a LinearLayout like this it does not include the &#8216;android:orientation=&#8221;vertical | horizontal&#8221;&#8216; attribute.  Apparently this is a pretty important attribute.  This determines if the assets stack horizontally or vertically.  And if not specified no error is thrown, instead it just seems to layer, or possibly just show the top asset.  Doesn&#8217;t really matter as far as I see it.  For those of us who have no idea what we&#8217;re doing it should seriously throw an error or something.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=894</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Device does not show up in Eclipse &#8216;Android Device Chooser&#8217;</title>
		<link>http://www.pukkared.com/?p=891</link>
		<comments>http://www.pukkared.com/?p=891#comments</comments>
		<pubDate>Thu, 06 May 2010 14:36:43 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Mobile Development]]></category>
		<category><![CDATA[Mobile]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=891</guid>
		<description><![CDATA[This is just a quick note on how to make sure your device shows up in the device listing when debugging an Android app in Eclipse.  I spent some time trying to figure this out since I had the plugins all installed and the app ran good in the Emulator, but my device just [...]]]></description>
			<content:encoded><![CDATA[<p>This is just a quick note on how to make sure your device shows up in the device listing when debugging an Android app in Eclipse.  I spent some time trying to figure this out since I had the plugins all installed and the app ran good in the Emulator, but my device just wouldn&#8217;t show up in the device list when choosing to debug manually.  I found the solution, of course, in the docs.</p>
<p>So if you&#8217;re having this problem you should make sure that your device is set up for debugging.  I&#8217;m running the Droid Incredible, so you may need to take slightly different steps to accomplish this than what I layout here.</p>
<ol>
<li>On the home screen of your device choose Menu &gt; Settings &gt; Applications &gt; Development.</li>
<li>Make sure that &#8216;USB debugging&#8217; is checked. I would also suggest checking the &#8216;Stay awake&#8217; option as well so you don&#8217;t have to keep waking your phone up during debugging.</li>
</ol>
<p>If the rest of your debug settings are correct your device should show up.  At least for me this was the solution.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=891</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Connecting to the MailChimp API with Coldfusion</title>
		<link>http://www.pukkared.com/?p=885</link>
		<comments>http://www.pukkared.com/?p=885#comments</comments>
		<pubDate>Mon, 26 Apr 2010 01:49:50 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Coldfusion 8]]></category>
		<category><![CDATA[Coldfusion 9]]></category>
		<category><![CDATA[mailchimp]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=885</guid>
		<description><![CDATA[I have just started playing with the MailChimp API with Coldfusion.  As usual, there&#8217;s not a lot of Coldfusion documentation or examples.  So I thought I&#8217;d start posting some of the how-to&#8217;s as I myself figure them out.  Here will demonstrate how to make a simple connection with the API so you [...]]]></description>
			<content:encoded><![CDATA[<p>I have just started playing with the MailChimp API with Coldfusion.  As usual, there&#8217;s not a lot of Coldfusion documentation or examples.  So I thought I&#8217;d start posting some of the how-to&#8217;s as I myself figure them out.  Here will demonstrate how to make a simple connection with the API so you can start doing more productive things like adding emails to lists and getting stats. </p>
<p>Let&#8217;s begin at the beginning of using any API.  We need an account and an API key.  Go ahead and create an account as if you&#8217;re a client, or if you are doing this for an actual client go ahead and create an account for them.  MailChimp makes this super simple.  Once you have an account click on the &#8216;account&#8217; button in the top left  corner of the dashboard.  This will take you to a set of links.  Click the &#8216;API Keys &#038; Info&#8217; link.  This will take you to a page where you can manage your API keys.  Clicking &#8216;Add A Key&#8217; will generate a new key for you to use.</p>
<p>Now that we have our key and account we&#8217;re ready to make our connection via Coldfusion.  Before looking at any code, let&#8217;s make sure we know where our documentation is at.  You can find the MailChimp docs <a href="http://www.mailchimp.com/api/1.2/">here</a>.  Requesting data from MailChimp requires you to pass the method and parameters via the url: http://us1.api.mailchimp.com/1.2/.  As parameters you need to indicate the type of output MailChimp should return data as.  In our case we&#8217;ll use JSON.  So we&#8217;ll attach &#8216;?output=json&#8217;.  Next we need to specify the method.  MailChimp has a ping() method meant for no other reason than to make sure the connection is working.  So this is what we&#8217;ll use here.  To do this we attach the method parameter &#8216;&#038;method=ping&#8217;.  If you look at the docs you&#8217;ll see that this requires only one parameter to work, which is the API key (this is required for all methods).  So we&#8217;ll attach another parameter &#8216;&#038;apikey=[yourapikey]&#8216;.</p>
<p>So let&#8217;s look at how to write this using Coldfusion.</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;!--- SET URL ---&gt;
&lt;cfset VARIABLES.api_url = &quot;http://us1.api.mailchimp.com/1.2/?output=json&amp;method=ping&amp;apikey=[your key]-us1&quot;&gt;

&lt;!--- SEND DATA VIA CFHTTP TAG ---&gt;
&lt;cfhttp name=&quot;call&quot; url=&quot;#VARIABLES.api_url#&quot; result=&quot;VARIABLES.mycall&quot;&gt;

&lt;!--- BECAUSE RETURNED AS JSON WE NEED TO DESERIALIZE THE RESPONSE ---&gt;
&lt;cfset VARIABLES.deserialized = deserializeJSON(VARIABLES.mycall.fileContent)&gt;

&lt;!--- DUMP RESPONSE ---&gt;
&lt;cfdump var=&quot;#VARIABLES.deserialized#&quot;&gt;
</pre>
</div>
<p>First we set our URL.  In this case you&#8217;ll, of course, change the &#8216;[your key]&#8216; to whatever your actual key is that MailChimp generated for you in your account.  Next we use the Coldfusion <cfhttp> tag to send the url to MailChimp.  MailChimp then processes it and sends back the result which we store as &#8216;VARIABLES.mycall&#8217;.  Because we specified to MailChimp to return data back to us as JSON we need to make sure we deserialize it before displaying it.  We do this using the &#8216;deserializeJSON()&#8217; method.  Also the response is passed back as a struct with the actual data from MailChimp stored in the &#8216;fileContent&#8217; key.  Lastly we just dump the data so we can see that &#8216;Everything&#8217;s Chimpy!&#8217;.  </p>
<p>At this point you should be able to start playing more with the API to do more complex and practical things.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=885</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Using Coldfusion to specify which pages to run under an SSL</title>
		<link>http://www.pukkared.com/?p=868</link>
		<comments>http://www.pukkared.com/?p=868#comments</comments>
		<pubDate>Mon, 26 Apr 2010 00:49:01 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Coldfusion 8]]></category>
		<category><![CDATA[Coldfusion 9]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=868</guid>
		<description><![CDATA[I recently had a site that ran under an SSL certificate.  As this was the case each page of the site ran under the &#8216;https://&#8217; protocol.  A few weeks ago the client noticed that when run in Internet Explorer they were receiving a message stating that not all of the data was being [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had a site that ran under an SSL certificate.  As this was the case each page of the site ran under the &#8216;https://&#8217; protocol.  A few weeks ago the client noticed that when run in Internet Explorer they were receiving a message stating that not all of the data was being passed via the SSL.  It would ask if the user wished to load in the insecure data as well as the secure.  If the user chose yes everything loaded as normal.  If they chose no everything except AJAX data would load onto the page.</p>
<p>While this makes sense I&#8217;m not sure why it just started happening.  Nonetheless, I noted that it was not necessary to run the entire site under the SSL.  Since I, of course, do not use AJAX anywhere in the checkout process, I decided that the simple solution was to run the SSL only under the checkout.  This would allow the rest of the site to run under the &#8216;http://&#8217; protocol without any security prompts concerning AJAX from Internet Explorer.  So let&#8217;s take a look at how to run the SSL under only select pages in your site.</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;!--- ***************  MAKE SURE THE SSL IS IN PLACE  *************** ---&gt;
&lt;cfset var storepath = &quot;http://www.yourdomain.com/checkout/&quot;&gt;
&lt;cfset var url = &quot;http://&quot; &amp; CGI.HTTP_HOST &amp; CGI.SCRIPT_NAME&gt;
&lt;cfset var isinstore = findNoCase(storepath, url)&gt;

&lt;!--- IF FOUND CHANGE TO SECURE PROTOCOL ---&gt;
&lt;cfif isinstore neq 0 AND CGI.SERVER_PORT neq &quot;443&quot;&gt;
	&lt;!--- SET TO SECURE PROTOCOL ---&gt;
	&lt;cfset url = &quot;https://&quot; &amp; CGI.HTTP_HOST &amp; CGI.SCRIPT_NAME&gt;

	&lt;!--- SET QUERY STRING IF NECESSARY ---&gt;
	&lt;cfif CGI.QUERY_STRING neq &quot;&quot;&gt;
		&lt;cfset url = url &amp; &quot;?&quot; &amp; CGI.QUERY_STRING&gt;
	&lt;/cfif&gt;

	&lt;!--- REDIRECT USER ---&gt;
	&lt;cflocation url=&quot;#url#&quot; addtoken=&quot;false&quot;&gt;
&lt;/cfif&gt;
</pre>
</div>
<p>This snippet of code is run under the onRequestStart() method in the Application.cfc.  This allows the program to check the url with each request that is made.  Some pre-planning is required to choose where the SSL is run without just doing a page by page check.  In this case we have made sure that we have placed all of our secure pages under a single directory.  In this case we are wanting to secure our &#8216;checkout&#8217; directory.  If we are under this directory we also want to make sure that we are not running on the secure port 443.  If not we can take the current url, run the secure protocol at the beginning, attach the query string if necessary, and then redirect the user to the secure page.</p>
<p>With each request Coldfusion checks if the page falls under the &#8216;checkout&#8217; directory and if so it redirects to itself using the &#8216;https://&#8217; protocol.  For this protocol to work, it of course assumes that you have set up the SSL in IIS or whatever you use.  I also recommend going into the site and changing any absolute paths linking to any of the pages running under your secure directory to use the secure protocol by default.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=868</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating a Twitter style character counter with jQuery</title>
		<link>http://www.pukkared.com/?p=873</link>
		<comments>http://www.pukkared.com/?p=873#comments</comments>
		<pubDate>Fri, 23 Apr 2010 02:39:31 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[jQuery]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=873</guid>
		<description><![CDATA[I&#8217;m not really sure why I decided to write the javascript to handle a text area with a limited character count as well as a character counter like that used on Twitter.  Reason or not, it turned out to be fairly simple to pull off.  By far the hardest part was finding a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m not really sure why I decided to write the javascript to handle a text area with a limited character count as well as a character counter like that used on Twitter.  Reason or not, it turned out to be fairly simple to pull off.  By far the hardest part was finding a way to only run the onkeyup event when the appropriate text area field was focused.  The idea being that every time the user presses a key typing in their name there isn&#8217;t a bunch of javascript running unnecessarily in the background.  Somewhere on the web I found an activeElement javascript method that returns the focused form element.  Just a fair warning that I&#8217;ve never used this outside of this example and have no idea if it works in IE or not.  I did check though in Chrome, Firefox, and Safari however.</p>
<p>I came up with two scenarios for using a limited character text area with a character counter.  First is a text area that allows x number of characters.  The counter counts up to this number and then increases no more.  The string itself is trimmed to the max character on each keypress beyond the max characters allowed.  Second is a text area much truer to the Twitter &#8216;What&#8217;s Happening&#8217; text area.  This text area will allow the user to type as much as they wish, while the counter begins at the max and counts down to 0.  At zero the counter begins counting down through negative numbers.  I&#8217;ve also added a class at this point that changes the color of negative numbers to red.</p>
<p>Let&#8217;s take a look at some code.</p>
<h3>The HTML</h3>
<div class="code">
<pre class="brush: xml;">
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;&gt;
	&lt;head&gt;
		&lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=UTF-8&quot; /&gt;
		&lt;title&gt;Character Counter&lt;/title&gt;

		&lt;!-- JQUERY LINK --&gt;
		&lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;

		&lt;!-- CHARACTER COUNTER JS FILE --&gt;
		&lt;script src=&quot;js/character_counter.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
	&lt;/head&gt;

	&lt;body&gt;
		&lt;form name=&quot;text_input&quot; method=&quot;post&quot; action=&quot;#&quot;&gt;
			&lt;textarea name=&quot;my_text&quot; id=&quot;my_text&quot; cols=&quot;50&quot; rows=&quot;10&quot;&gt;&lt;/textarea&gt;
		&lt;/form&gt;

		Characters: &lt;em&gt;&lt;span id=&quot;counter&quot;&gt;&lt;/span&gt;&lt;/em&gt;
	&lt;/body&gt;
&lt;/html&gt;
</pre>
</div>
<p>Pretty simple stuff we have here.  First is a link to the jQuery library hosted by Google.  Next is a link to the character_counter.js file that I will get into next.  As far as HTML is concerned we have a text area with an id of &#8216;my_text&#8217; and a span with an id of &#8216;counter&#8217;.  The span is empty because it will serve as a container for us to dynamically insert the character count as the user types into the text area.</p>
<p>I will list first the javascript that counts up to the max number of characters and then trims the string to the max character count so that the user can literally on enter the allowed number of characters.  Afterwards, I will show the code that will allow the user to type as much as they wish and count into negative numbers.</p>
<h3>character_counter.js (Counts up with character limit)</h3>
<div class="code">
<pre class="brush: jscript;">
$(document).ready(function()
{
	var max_length = 10;

	//run listen key press
	whenkeydown(max_length);
});

whenkeydown = function(max_length)
{
	$(&quot;#my_text&quot;).unbind().keyup(function()
	{
		//check if the appropriate text area is being typed into
		if(document.activeElement.id === &quot;my_text&quot;)
		{
			//get the data in the field
			var text = $(this).val();

			//set number of characters
			var numofchars = text.length;

			if(numofchars &lt;= max_length)
			{
				//set the length of the text into the counter span
				$(&quot;#counter&quot;).html(&quot;&quot;).html(text.length);
			}
			else
			{
				//make sure string gets trimmed to max character length
				$(this).val(text.substring(0, max_length));
			}
		}
	});
}
</pre>
</div>
<h3>character_counter.js (Counts down without a character limit)</h3>
<div class="code">
<pre class="brush: jscript;">
$(document).ready(function()
{
	//set max length
	var max_length = 10;

	//load in max characters when page loads
	$(&quot;#counter&quot;).html(max_length);

	//run listen key press
	whenkeydown(max_length);
});

whenkeydown = function(max_length)
{
	$(&quot;#my_text&quot;).unbind().keyup(function()
	{
		//check if the appropriate text area is being typed into
		if(document.activeElement.id === &quot;my_text&quot;)
		{
			//get the data in the field
			var text = $(this).val();

			//set number of characters
			var numofchars = text.length;

			//set the chars left
			var chars_left = max_length - numofchars;

			//check if we are still within our maximum number of characters or not
			if(numofchars &lt;= max_length)
			{
				//set the length of the text into the counter span
				$(&quot;#counter&quot;).html(&quot;&quot;).html(chars_left).css(&quot;color&quot;, &quot;#000000&quot;);
			}
			else
			{
				//style numbers in red
				$(&quot;#counter&quot;).html(&quot;&quot;).html(chars_left).css(&quot;color&quot;, &quot;#FF0000&quot;);
			}
		}
	});
}
</pre>
</div>
<p>Gist of both is that we need to set a max character count for the text area and then listen for the keyup event to fire.  When this happens we then check if the text area with the id of &#8216;my_text&#8217; is focused.  If not there is no need to continue running code.  If so we get the value of the text area and get the length which is the number of characters.  If we are increasing our counter by one we just need to use jQuery to write to the span tag the current length of the value of the text area.  If counting down we do the opposite.  We subtract the length of the value of the text area from the max number of characters allowed.  Next, if we are trimming the string so that it can never actually get longer than the number of allowed characters we check if the length has exceeded the max characters.  If so we use the &#8217;subString()&#8217; method to make sure that the value is trimmed off each time the user tries to add a character.  If running the counter into negative numbers we don&#8217;t really need to run any conditionals unless changing the color so that negative numbers show up different than positive numbers.  In this case I just check if the length of the value exceeds the max length.  If so I use the jQuery css() method to change the color of the text to red.</p>
<p>That&#8217;s really it.  Not pretty, but functional and simple.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=873</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Looping over lists</title>
		<link>http://www.pukkared.com/?p=870</link>
		<comments>http://www.pukkared.com/?p=870#comments</comments>
		<pubDate>Wed, 21 Apr 2010 20:42:13 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Coldfusion 9]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=870</guid>
		<description><![CDATA[I realize that the title implies a super basic topic, and it certainly does.  But this is something that tripped me up a little earlier today so I thought that simple as it may be I would share for anyone else encountering a similar problem.  My issue was that I created a list, [...]]]></description>
			<content:encoded><![CDATA[<p>I realize that the title implies a super basic topic, and it certainly does.  But this is something that tripped me up a little earlier today so I thought that simple as it may be I would share for anyone else encountering a similar problem.  My issue was that I created a list, looped over the list, for each loop checked the value, and depending on the value output a new value.  What I found was that my switch statements would pick up the first value in the list but not the rest.  The problem ended up being that I was putting a space between my comma and the next value.  Let&#8217;s look at a quick example of this.</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;!--- SET A LIST ---&gt;
&lt;cfset VARIABLES.list = &quot;RI, MA, CT&quot;&gt;

&lt;!--- LOOP OVER LIST ---&gt;
&lt;cfloop list=&quot;#VARIABLES.list#&quot; delimiters=&quot;,&quot; index=&quot;VARIABLES.i&quot;&gt;
	&lt;!--- CHECK ITEM IN LIST AND SHOW FULL STATE NAME ---&gt;
	&lt;cfswitch expression=&quot;#VARIABLES.i#&quot;&gt;
		&lt;cfcase value=&quot;RI&quot;&gt;
			&lt;cfset VARIABLES.state = &quot;Rhode Island&quot;&gt;
		&lt;/cfcase&gt;

		&lt;cfcase value=&quot;MA&quot;&gt;
			&lt;cfset VARIABLES.state = &quot;Massachusetts&quot;&gt;
		&lt;/cfcase&gt;

		&lt;cfcase value=&quot;CT&quot;&gt;
			&lt;cfset VARIABLES.state = &quot;Connecticut&quot;&gt;
		&lt;/cfcase&gt;
	&lt;/cfswitch&gt;

	&lt;!--- DISPLAY FULL STATE NAME ---&gt;
	&lt;cfoutput&gt;
		#VARIABLES.state#&lt;br /&gt;
	&lt;/cfoutput&gt;
&lt;/cfloop&gt;
</pre>
</div>
<p>This will display &#8220;Rhode Island&#8221; three times.  What causes this?  Again it&#8217;s that space after the commas in my initial list.  As it stands the the case value is looking for &#8221; MA&#8221; not &#8220;MA&#8221;.</p>
<p>If you convert the items in the list into a byte array you will see that both MA and CT have an extra character which is a space.  Simple and obvious solution though.  Just make sure that your lists are nice and tight.  While I have a tendency to use arrays as opposed to lists in these cases I really find it hard to believe that I&#8217;m just now noticing this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=870</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VARIABLES scope in CFCs in Coldfusion 9</title>
		<link>http://www.pukkared.com/?p=840</link>
		<comments>http://www.pukkared.com/?p=840#comments</comments>
		<pubDate>Mon, 12 Apr 2010 01:19:44 +0000</pubDate>
		<dc:creator>Matthew Cook</dc:creator>
				<category><![CDATA[Coldfusion 9]]></category>

		<guid isPermaLink="false">http://blog.pukkared.com/?p=840</guid>
		<description><![CDATA[The point is to hopefully add a little clarification to the VARIABLES scope used inside of CFCs in Coldfusion 9.  I&#8217;ll also be using a few other things like an init() method to further illustrate the use of the VARIABLES scope.  I&#8217;ll be using simple examples of these things for demonstration purposes only.  That being [...]]]></description>
			<content:encoded><![CDATA[<p>The point is to hopefully add a little clarification to the VARIABLES scope used inside of CFCs in Coldfusion 9.  I&#8217;ll also be using a few other things like an init() method to further illustrate the use of the VARIABLES scope.  I&#8217;ll be using simple examples of these things for demonstration purposes only.  That being said, we&#8217;ll look at the first example which will demonstrate the &#8216;VARIABLES&#8217; scope in a cfc as well as using an &#8216;init()&#8217; method to set up a CFC.  Let&#8217;s take a look at the component.</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;cfcomponent displayname=&quot;Manage Person&quot; hint=&quot;Manages the persons created.&quot; output=&quot;false&quot;&gt;

	&lt;!--- **************************  INITIALIZE  ************************** ---&gt;
	&lt;cffunction name=&quot;init&quot; displayname=&quot;Initialize&quot; description=&quot;Sets the variables that will need to be used throughout this component.&quot; output=&quot;false&quot; access=&quot;public&quot; returntype=&quot;any&quot;&gt;

		&lt;cfset VARIABLES.name = &quot;Matthew&quot;&gt;
		&lt;cfset VARIABLES.haircolor = &quot;Brown&quot;&gt;
		&lt;cfset VARIABLES.eyecolor = &quot;Hazel&quot;&gt;
		&lt;cfset VARIABLES.height = &quot;5 feet, 6 inches&quot;&gt;
		&lt;cfset VARIABLES.weight = &quot;130 lbs&quot;&gt;
		&lt;cfset VARIABLES.gender = &quot;Male&quot;&gt;

		&lt;cfreturn THIS&gt;

	&lt;/cffunction&gt;

	&lt;!--- **************************  ADD PERSON  ************************** ---&gt;
	&lt;cffunction name=&quot;addPerson&quot; displayname=&quot;Add Person&quot; description=&quot;Creates a person object.&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;struct&quot;&gt;

		&lt;!--- BUILD STRUCT ---&gt;
		&lt;cfset var data = structNew()&gt;
		&lt;cfset data.success = true&gt;
		&lt;cfset data.message = &quot;&quot;&gt;
		&lt;cfset data.person = structNew()&gt;
		&lt;cfset data.person.name = VARIABLES.name&gt;
		&lt;cfset data.person.haircolor = VARIABLES.haircolor&gt;
		&lt;cfset data.person.eyecolor = VARIABLES.eyecolor&gt;
		&lt;cfset data.person.height = VARIABLES.height&gt;
		&lt;cfset data.person.weight = VARIABLES.weight&gt;
		&lt;cfset data.person.gender = VARIABLES.gender&gt;

		&lt;!--- RETURN STRUCT ---&gt;
		&lt;cfreturn data /&gt;

	&lt;/cffunction&gt;

	&lt;!--- *****************************  SET NAME  ***************************** ---&gt;
	&lt;cffunction name=&quot;setName&quot; displayname=&quot;Set Name&quot; description=&quot;Sets a persons name into the component.&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;

		&lt;!--- ARGUMENTS ---&gt;
		&lt;cfargument name=&quot;name&quot; displayname=&quot;Person Name&quot; hint=&quot;The name of a person.&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;

		&lt;!--- SET NAME INTO THIS SCOPE ---&gt;
		&lt;cfset VARIABLES.name = ARGUMENTS.name&gt;

	&lt;/cffunction&gt;

	&lt;!--- **************************  SET EYE COLOR  ************************** ---&gt;
	&lt;cffunction name=&quot;setEyeColor&quot; displayname=&quot;Set Eye Color&quot; description=&quot;Sets the eye color of a person.&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;

		&lt;!--- ARGUMENTS ---&gt;
		&lt;cfargument name=&quot;eyecolor&quot; displayname=&quot;Person Eye Color&quot; hint=&quot;The eye color of a person.&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;

		&lt;!--- SET EYE COLOR INTO THIS SCOPE ---&gt;
		&lt;cfset VARIABLES.eyecolor = ARGUMENTS.eyecolor&gt;

	&lt;/cffunction&gt;

	&lt;!--- **************************  SET HAIR COLOR  ************************** ---&gt;
	&lt;cffunction name=&quot;setHairColor&quot; displayname=&quot;Set Hair Color&quot; description=&quot;Sets the hair color of a person.&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;

		&lt;!--- ARGUMENTS ---&gt;
		&lt;cfargument name=&quot;haircolor&quot; displayname=&quot;Person Hair Color&quot; hint=&quot;The hair color of a person.&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;

		&lt;!--- SET HAIR COLOR INTO THIS SCOPE ---&gt;
		&lt;cfset VARIABLES.haircolor = ARGUMENTS.haircolor&gt;

	&lt;/cffunction&gt;

	&lt;!--- **************************  SET WEIGHT  ************************** ---&gt;
	&lt;cffunction name=&quot;setWeight&quot; displayname=&quot;Set Weight&quot; description=&quot;Sets the weight of a person&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;

		&lt;!--- ARGUMENTS ---&gt;
		&lt;cfargument name=&quot;weight&quot; displayname=&quot;Person Weight&quot; hint=&quot;The weight of a person.&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;

		&lt;!--- SET WEIGHT INTO THIS SCOPE ---&gt;
		&lt;cfset VARIABLES.weight = ARGUMENTS.weight&gt;

	&lt;/cffunction&gt;

	&lt;!--- **************************  SET GENDER  ************************** ---&gt;
	&lt;cffunction name=&quot;setGender&quot; displayname=&quot;Set Gender&quot; description=&quot;Sets the gender of a person&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;

		&lt;!--- ARGUMENTS ---&gt;
		&lt;cfargument name=&quot;gender&quot; displayname=&quot;Person Gender&quot; hint=&quot;The gender of a person.&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;

		&lt;!--- SET GENDER INTO THIS SCOPE ---&gt;
		&lt;cfset VARIABLES.gender = ARGUMENTS.gender&gt;

	&lt;/cffunction&gt;

	&lt;!--- **************************  SET HEIGHT  ************************** ---&gt;
	&lt;cffunction name=&quot;setHeight&quot; displayname=&quot;Set Height&quot; description=&quot;Sets the height of a person&quot; access=&quot;public&quot; output=&quot;false&quot; returntype=&quot;void&quot;&gt;

		&lt;!--- ARGUMENTS ---&gt;
		&lt;cfargument name=&quot;height&quot; displayname=&quot;Person Height&quot; hint=&quot;The height of a person.&quot; type=&quot;string&quot; required=&quot;true&quot; /&gt;

		&lt;!--- SET HEIGHT INTO THIS SCOPE ---&gt;
		&lt;cfset VARIABLES.height = ARGUMENTS.height&gt;

	&lt;/cffunction&gt;

&lt;/cfcomponent&gt;
</pre>
</div>
<p>We have a simple cfc here with an init() method, an addPerson() method, and several setter methods for setting different attributes of a person.  The scope being used here is the VARIABLES scope. This scope persists with the instance of the component.  In other words, until the a new instance is created any data stored in the VARIABLES scope will be available to all functions inside the component.</p>
<p>The init() method is called  when we create an instance of the component.  Upon creation we simply set a few pieces of data into the VARIABLES scope preparing the component to use any of this data in any of the following methods.  In this case I go ahead and simply create a default person object, but could easily leave this data blank and rely on the set methods to fill in the person object attributes.</p>
<p>The next method is the addPerson() method which just compiles all of the attributes that make a person object and store it into a struct called &#8216;data&#8217;.  Notice though that none of the values of a person are set in this method.  It&#8217;s only job is to lump it all into a struct.  We can do this because our data is stored in the VARIABLES scope.</p>
<p>The remaining functions just set data into the VARIABLES scope.  Notice that they simply accept a value as an ARGUMENT, and then take that value and set it into the VARIABLES scope.  This essentially overrides the value set initially in the init() method.  Let&#8217;s look now at how this would be called from the .cfm page.</p>
<p><span id="more-840"></span></p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;!--- CREATE AN INSTANCE OF OUR OBJECT ---&gt;
&lt;cfset person_obj = createObject(&quot;component&quot;, &quot;my_tools.inheritance.cfcs.manage_person&quot;).init()&gt;

&lt;!--- ADD A PERSON OBJECT ---&gt;
&lt;cfset person = person_obj.addPerson()&gt;

&lt;!--- DUMP THE PERSON OBJECT ---&gt;
&lt;cfdump var=&quot;#person#&quot;&gt;
</pre>
</div>
<p>First we create an instance of our component using the &#8216;createObject()&#8217; method.  Not only do we create an instance, but we also go on and run the &#8216;init()&#8217; method as well.  The init() method returns the THIS scope.  This is very important to do.  If you do not return the THIS scope when running an init() method during the instance creation you won&#8217;t get anything back to play on.  So for example, if I didn&#8217;t return the THIS  scope I wouldn&#8217;t be able to call the addPerson() method because I technically don&#8217;t have it to call because it was never returned.  If you do not call a method upon creating an instance Coldfusion will by default return everything that the component has to offer.</p>
<p>So if we were to simply dump our component instance &#8216;person_obj&#8217; we would get the following.  To get the following output I temporarily changed the return on the init() method to VARIABLES so we could see the variables that were created upon creating the component instance.  Dumping the instance when the we return the appropriate THIS scope only returns the available methods.  This makes sense since we can&#8217;t access any data stored in the component&#8217;s VARIABLES scope outside of the component itself.</p>
<div id="attachment_853" class="wp-caption alignnone" style="width: 526px"><a href="http://blog.pukkared.com/wp-content/uploads/2010/04/Screen-shot-2010-04-11-at-8.31.41-PM.png"><img class="size-full wp-image-853" title="Component Dump" src="http://blog.pukkared.com/wp-content/uploads/2010/04/Screen-shot-2010-04-11-at-8.31.41-PM.png" alt="Component dump." width="516" height="763" /></a><p class="wp-caption-text">manage_person cfc dump</p></div>
<p>Anyways, this was just a small portion of the actual struct, but you get the idea.  Point being when we look at the VARIABLES scope of our cfc we see the data that was set in the init() method as well as each function that is also stored in the VARIABLES scope by default under the name of the function.</p>
<p>All is well so far.  Now let&#8217;s look at what is returned when we add a person.  Remember that in the init() method we create a default person.  Since we are not running any setter methods our addPerson() method will simply return the default person object.  So given the above code, when we dump the &#8216;person&#8217; variable we get the following.</p>
<div id="attachment_860" class="wp-caption alignnone" style="width: 224px"><a href="http://blog.pukkared.com/wp-content/uploads/2010/04/Screen-shot-2010-04-11-at-8.54.04-PM.png"><img class="size-full wp-image-860" title="Default Person Object" src="http://blog.pukkared.com/wp-content/uploads/2010/04/Screen-shot-2010-04-11-at-8.54.04-PM.png" alt="Default person object." width="214" height="218" /></a><p class="wp-caption-text">Default person object.</p></div>
<p>Now let&#8217;s say we want to create a new person.  To do this we will need to call our setter methods and pass them the attributes of our new person.  To create our new person our code would look like the following.</p>
<div class="code">
<pre class="brush: coldfusion;">
&lt;!--- CREATE AN INSTANCE OF OUR OBJECT ---&gt;
&lt;cfset person_obj = createObject(&quot;component&quot;, &quot;my_tools.inheritance.cfcs.manage_person&quot;).init()&gt;

&lt;!--- SET NEW HAIR COLOR ---&gt;
&lt;cfset person_obj.setName(&quot;Adriana&quot;)&gt;
&lt;cfset person_obj.setEyeColor(&quot;Brown&quot;)&gt;
&lt;cfset person_obj.setHairColor(&quot;Black&quot;)&gt;
&lt;cfset person_obj.setWeight(&quot;105 lbs&quot;)&gt;
&lt;cfset person_obj.setGender(&quot;Female&quot;)&gt;
&lt;cfset person_obj.setHeight(&quot;5 feet, 4 inches&quot;)&gt;

&lt;!--- ADD A PERSON OBJECT ---&gt;
&lt;cfset person = person_obj.addPerson()&gt;

&lt;!--- DUMP THE PERSON OBJECT ---&gt;
&lt;cfdump var=&quot;#person#&quot;&gt;
</pre>
</div>
<p>Our new person object now looks like the following.</p>
<div id="attachment_862" class="wp-caption alignnone" style="width: 221px"><a href="http://blog.pukkared.com/wp-content/uploads/2010/04/Screen-shot-2010-04-11-at-9.08.10-PM.png"><img class="size-full wp-image-862" title="Person Object" src="http://blog.pukkared.com/wp-content/uploads/2010/04/Screen-shot-2010-04-11-at-9.08.10-PM.png" alt="Person Object" width="211" height="216" /></a><p class="wp-caption-text">Person 2 object</p></div>
<p>Point being here that we have just used our setter methods to manipulate the VARIABLES scope in the cfc to reflect the attributes of a different person.  Then we use our same addPerson() method to compile those attributes into an object, or more specifically a struct.  When all is said and done, the main thing to keep in mind is that data in the VARIABLES scope persists the duration of the component instance and is available for use from within the component.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.pukkared.com/?feed=rss2&amp;p=840</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
