<?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>Simon Whatley &#187; Framework</title>
	<atom:link href="http://www.simonwhatley.co.uk/tag/framework/feed" rel="self" type="application/rss+xml" />
	<link>http://www.simonwhatley.co.uk</link>
	<description>The opposite of every great idea is another great idea</description>
	<lastBuildDate>Wed, 02 Nov 2011 09:28:34 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Rich Internet Application Frameworks for Flex and AIR</title>
		<link>http://www.simonwhatley.co.uk/ria-flex-air-frameworks</link>
		<comments>http://www.simonwhatley.co.uk/ria-flex-air-frameworks#comments</comments>
		<pubDate>Thu, 04 Sep 2008 14:34:42 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Adobe Consulting]]></category>
		<category><![CDATA[Adobe Flex]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[asset management]]></category>
		<category><![CDATA[backend services]]></category>
		<category><![CDATA[Cairngorm]]></category>
		<category><![CDATA[classic Model-View-Controller]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Frameworks]]></category>
		<category><![CDATA[Gaia]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[Guasax]]></category>
		<category><![CDATA[Internet Application Frameworks]]></category>
		<category><![CDATA[Internet Applications]]></category>
		<category><![CDATA[inversion-of-control]]></category>
		<category><![CDATA[IoC]]></category>
		<category><![CDATA[Mate]]></category>
		<category><![CDATA[Model-Glue Flex]]></category>
		<category><![CDATA[model-view-controller]]></category>
		<category><![CDATA[mvc]]></category>
		<category><![CDATA[PureMVC]]></category>
		<category><![CDATA[software engineers]]></category>
		<category><![CDATA[Swiz]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=986</guid>
		<description><![CDATA[Whether you are new to Adobe &#174; Flex &#174; or have been developing for a while, frameworks can help you get organised quickly. Below is a list of Flex and AIR frameworks that will allow you to get up and running and develop highly-collaborative applications. The introductions are by the frameworks themselves, but I'd like to here from you about your experiences using them.]]></description>
			<content:encoded><![CDATA[<p>Whether you are new to Adobe &reg; Flex &reg; or have been developing for a while, frameworks can help you get organised quickly.</p>
<p>Below is a list of Flex and <acronym title="Adobe Integrated Runtime">AIR</acronym> frameworks that will allow you to get up and running and develop highly-collaborative applications. The introductions are by the frameworks themselves, but I&#8217;d like to here from you about your experiences using them.</p>
<h3>Cairngorm</h3>
<p>Cairngorm is the lightweight micro-architecture for <a href="http://en.wikipedia.org/wiki/Rich_Internet_application" title="Wikipedia: Rich Internet Application" target="_blank" rel="nofollow">Rich Internet Applications</a> built in Flex or <acronym title="Adobe Integrated Runtime">AIR</acronym>. A collaboration of recognized design patterns, Cairngorm exemplifies and encourages best-practices for <abbr title="Rich Internet Application">RIA</abbr> development advocated by <a href="http://www.adobe.com/consulting/" title="Adobe Consulting" target="_blank" rel="nofollow">Adobe Consulting</a>, encourages best-practice leverage of the underlying Flex framework, while making it easier for medium to large teams of software engineers deliver medium to large scale, mission-critical Rich Internet Applications.</p>
<p>More information can be found on the <a href="http://opensource.adobe.com/wiki/display/cairngorm/Cairngorm" title="Cairngorm RIA Framework" target="_blank" rel="nofollow">Cairngorm project&#8217;s website</a>.</p>
<h3>PureMVC</h3>
<p>PureMVC is a lightweight framework for creating applications based upon the classic <a href="http://en.wikipedia.org/wiki/Model-View-Controller" title="Wikipedia: Model, View and Controller design pattern" target="_blank" rel="nofollow">Model-View-Controller</a> concept.</p>
<p>Based upon proven design patterns, this free, open source framework which was originally implemented in the ActionScript 3 language for use with Adobe Flex, Flash and <acronym title="Adobe Integrated Runtime">AIR</acronym>, has now been ported to nearly all major development platforms.</p>
<p>Two versions of the framework are supported with reference implementations; Standard and MultiCore, though only the Standard version has been ported to other languages so far.</p>
<p>More information can be found on the <a href="http://puremvc.org/" title="PureMVC Framework" target="_blank" rel="nofollow">PureMVC project&#8217;s website</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>Mate</h3>
<p>Mate is a tag-based, event-driven Flex framework.</p>
<p>Flex applications are event-driven. Mate framework has been created to make it easy to handle the events your Flex application creates. Mate allows you to define who is handling those events, whether data needs to be retrieved from the server, or other events need to be triggered.</p>
<p>In addition, Mate provides a mechanism for dependency injection to make it easy for the different parts of your application to get the data and objects they need.</p>
<p>More information can be found on the <a href="http://mate.asfusion.com/" title="Mate Framework at ASFusion" target="_blank" rel="nofollow">Mate project&#8217;s website</a>.</p>
<h3>Swiz</h3>
<p>Swiz is a framework for Adobe Flex that aims to bring complete simplicity to <abbr title="Rich Internet Application">RIA</abbr> development. Swiz provides Inversion of Control, event handing, and simple life cycle for asynchronous remote methods. In contrast to other major frameworks for Flex, Swiz imposes no <abbr title="Java 2 Platform, Enterprise Edition">J2EE</abbr> patterns on your code, no repetitive folder layouts, and no boilerplate code on your development. Swiz represents best practices learned from the top <abbr title="Rich Internet Application">RIA</abbr> developers at some of the best consulting firms in the industry, enabling Swiz to be simple, lightweight, and extremely productive.</p>
<p>More information can be found on the <a href="http://code.google.com/p/swizframework/" title="Swiz Framework on Google Code" target="_blank" rel="nofollow">Swiz project&#8217;s website</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>Guasax</h3>
<p>Guasax is an ease of use programming framework which provides the creation of an ordered and scalable application with Adobe Flex. The lifecycle of the Guasax framework is based in the <acronym title="Model-View-Controller">MVC</acronym> pattern to take on our program actions. The Guasax framework helps you to maintain your business logic tier highly decoupled from your presentation logic tier.</p>
<p>Guasax takes reflection and introspection techniques as well as the <a href="http://en.wikipedia.org/wiki/Inversion_of_control" title="Wikipedia: Inversion of Control" target="_blank" rel="nofollow">Inversion of Control</a> (<abbr title="Inversion of Control">IoC</abbr>) pattern to execute the operations which we have pointed at and to make a decision about itself. Guasax is not intrusive on your class model. You <em>don&#8217;t</em> have to extend your classes in a framework class to use it.</p>
<p>More information can be found on the <a href="http://www.guasax.com/" title="Guasax Project" target="_blank" rel="nofollow">Guasax project&#8217;s website</a> or on their <a href="http://code.google.com/p/guasax/" title="Guasax Project on Google Code" target="_blank" rel="nofollow">Google code project</a>.</p>
<h3>Model-Glue: Flex</h3>
<p>Model-Glue: Flex brings <a href="http://en.wikipedia.org/wiki/Implicit_invocation" title="Wikipedia: Implicit Invocation" target="_blank" rel="nofollow">implicit invocation</a>, Model-View-Controller design, and cleaner, less repetitive integration with backend services to Flex and <acronym title="Adobe Integrated Runtime">AIR</acronym> applications.</p>
<p>It shuns repetitive, boilerplate code in favor of helper classes and expressive <abbr title="Application Programming Interface">API</abbr>s.</p>
<p>More information can be found on the <a href="http://www.model-glue.com/flex.cfm" title="Model-Glue: Flex project's website" target="_blank" rel="nofollow">Model-Glue: Flex project&#8217;s website</a>.</p>
<h3>Gaia</h3>
<p>Gaia is an open-source front-end Flash Framework for <abbr title="ActionScript 3">AS3</abbr> and <abbr title="ActionScript 2">AS2</abbr> designed to dramatically reduce development time.</p>
<p>Gaia is targeted at anyone who develops Flash sites. It provides solutions to the challenges and repeated tasks faced with front-end Flash site development, such as navigation, transitions, preloading, asset management, site structure, deep linking and <abbr title="Search Engine Optimisation">SEO</abbr>. It provides speed and flexibility in your workflow and a simple API that gives you access to its powerful features.</p>
<p>More information can be found on the <a href="http://www.gaiaflashframework.com/" title="Gaia framework's website" target="_blank" rel="nofollow">Gaia Framework&#8217;s website</a>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p><strong>UPDATE: Some more frameworks that I overlooked.</strong></p>
<h3>Parsley</h3>
<p>Parsley is an application framework for Flex/Flash/AIR applications written in AS3. It contains the following modules:</p>
<p><abbr title="Inversion of Control">IoC</abbr> Container (Configuration and Dependency Injection) &#8211; Inspired by the Spring Framework it brings the concept of an<abbr title="Inversion of Control">IoC</abbr>(Inversion of Control) container to ActionScript. It is useful for configuration and wiring of applications. It helps building a well structured architecture and decoupling the individual building blocks of your application. Configuration is based on <abbr title="eXtensible Markup Language">XML</abbr> files.</p>
<p><abbr title="Model View Controller">MVC</abbr> Framework &#8211; The <abbr title="Model View Controller">MVC</abbr> (Model View Controller) framework helps decouple the view layer from other parts of the application. It borrows the concept of a FrontController from Cairngorm, but instead of advocating the use of BusinessDelegate and ServiceLocator patterns, the framework integrates the FrontController with the <abbr title="Inversion of Control">IoC</abbr> container.<br />
More information can be found on the <a href="http://www.spicefactory.org/parsley/" title="Parsley framework's website" target="_blank" rel="nofollow">Parsley Framework&#8217;s website</a>.</p>
<h3>Prana</h3>
<p>Prana is an Inversion of Control (<abbr title="Inversion of Control">IoC</abbr>) Container for ActionScript 3.0, and more specifically the Flex framework. It enables you to configure objects and components in a non-intrusive way by describing them in an external <abbr title="eXtensible Markup Language">XML</abbr> document and having them loaded at runtime.</p>
<p>At its core is a Spring-ish application context and <abbr title="Inversion of Control">IoC</abbr> container. The <abbr title="eXtensible Markup Language">XML</abbr> dialect for the application context is aimed to be Spring compliant.</p>
<p>The framework also contains utility classes for configuring and extending Cairngorm and PureMVC applications, a Reflection <abbr title="Application Programming Interface">API</abbr> and general utilities.</p>
<p>More information can be found on the <a href="http://www.pranaframework.org" title="Prana framework's website" target="_blank" rel="nofollow">Prana Framework&#8217;s website</a>.</p>
<h3>Arp</h3>
<p>Arp is a pattern-based framework for Flash and Flex. It supports both ActionScript 2 and ActionScript 3.</p>
<p>More information can be found on the <a href="http://osflash.org/projects/arp/" title="Arp Framework" target="_blank" rel="nofollow">Arp project&#8217;s page</a> on the Open Source Flash website.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/ria-flex-air-frameworks/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the MooTools Autocompleter Plugin with ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/using-the-mootools-autocompleter-plugin-with-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/using-the-mootools-autocompleter-plugin-with-coldfusion#comments</comments>
		<pubDate>Thu, 21 Aug 2008 10:57:35 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Australia]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[autocompleter]]></category>
		<category><![CDATA[Bulgaria]]></category>
		<category><![CDATA[CNet]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[DOM]]></category>
		<category><![CDATA[Dylan Verheul]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Harald Kirschner]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[JavaScript Object Notation]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[mootools]]></category>
		<category><![CDATA[New Brunswick]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[search interface]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[united kingdom]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=883</guid>
		<description><![CDATA[In a previous post, I demonstrated how to implement Dylan Verheul’s jQuery Autocomplete plugin. Not content with demonstrating one library's plugin, it is now the turn of Mootools.]]></description>
			<content:encoded><![CDATA[<p>In a <a href="/using-jquery-auto-complete-with-coldfusion" title="Using jQuery Auto-Complete with ColdFusion">previous post</a>, I demonstrated how to implement Dylan Verheul&#8217;s <a href="http://www.dyve.net/jquery/?autocomplete" title="jQuery Autocomplete Plugin" target="_blank" rel="nofollow">jQuery Autocomplete plugin</a>. Not content with demonstrating one library&#8217;s plugin, it is now the turn of <a href="http://mootools.net/" title="MooTools JavaScript Framework" target="_blank" rel="nofollow">MooTools</a>.</p>
<blockquote><p>MooTools is a compact, modular, Object-Oriented JavaScript framework designed for the intermediate to advanced JavaScript developer. It allows you to write powerful, flexible, and cross-browser code with its elegant, well documented, and coherent API.</p></blockquote>
<p>In this post I will show you how to implement the <a href="http://digitarald.de/project/autocompleter/" title="Autocompleter Plugin" target="_blank" rel="nofollow">AutoCompleter plugin</a> by Harald Kirschner. Kirschner&#8217;s AutoCompleter plugin script for MooTools provides the functionality for text suggestion and completion. It features different data-sources (local, <acronym title="JavaScript Object Notation">JSON</acronym> or <abbr title="eXtensible Markup Language">XML</abbr>), a variety of user interactions, custom formatting, multiple selection, animations and much more.</p>
<h3>The Goal</h3>
<p>The goal of this post will be the same as the <a href="/using-jquery-auto-complete-with-coldfusion" title="Using jQuery Auto-Complete with ColdFusion">jQuery autocomplete post</a>: Allow the user to type a few characters into a standard form text input field and to automatically provide suggestions from which the user can select.</p>
<h3>Prerequisites</h3>
<ol>
<li>The <a href="http://mootools.net/download" title="Mootools Download" target="_blank" rel="nofollow">latest copy of MooTools</a></li>
<li>A basic understanding of JavaScript and <acronym title="JavaScript Object Notation">JSON</acronym></li>
<li>A server-side script that can respond to the <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> request, in our case ColdFusion</li>
</ol>
<h3>Demo</h3>
<p>The demo below will show how to interact with a simple ColdFusion script, but I&#8217;ll also provide <a href="/examples/autocomplete/mootools/" title="More examples">more (advanced) examples</a> in the <a href="/examples/autocomplete/mootools/autocomplete.zip" title="Download the files">download</a>.</p>
<h3>How It Works</h3>
<p>Once the user begins to type into the form text input field, the MooTools auto-complete is activated. After a set character length and time interval (both optional), a list of items is displayed below the input field. The user can select an item with either the arrow keys or mouse.</p>
<p>NB. Clicking back in the input field will repopulate the auto-complete list, if options are available, so that the user can change the selection. Deleting part of the chosen item will also trigger a new selection list.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>The Code</h3>
<p>There are three parts to this demo:</p>
<ol>
<li>The page’s HTML.</li>
<li>The server-side code to produce the dynamic page (i.e. to load the autocomplete <code>div</code> when the user types something into the input field).</li>
<li>The MooTools JavaScript.</li>
</ol>
<p><strong>HTML Form</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;h1&gt;Example: Country Lookup&lt;/h1&gt;
&lt;p&gt;Using &lt;abbr title=&quot;Asynchronous JavaScript and XML&quot;&gt;AJAX&lt;/abbr&gt; to interrogate the database.&lt;/p&gt;
&lt;p&gt;Example data: Australia, Bulgaria, United Kingdom&lt;/p&gt;
&lt;form name=&quot;frmAutoCompleteCountry&quot; id=&quot;frmAutoCompleteCountry&quot; action=&quot;#&quot; method=&quot;post&quot;&gt;
&lt;p&gt;
&lt;label for=&quot;country&quot;&gt;Country&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;country&quot; id=&quot;country&quot; /&gt;
&lt;/p&gt;
&lt;/form&gt;</pre></div></div>

<p><strong>ColdFusion</strong></p>
<p>Below is a simple ColdFusion component that takes a string as an argument. This string is part or all of the country name. The query results are parsed as an array and returned from the function, as <acronym title="JavaScript Object Notation">JSON</acronym>, to the MooTools auto-complete function.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cfcomponent</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
&nbsp;
	<span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;getCountry&quot;</span> <span style="color: #0000ff">access</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;remote&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000ff">returntype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;array&quot;</span> returnf<span style="color: #0000ff;">or</span>mat<span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;json&quot;</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;country&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> <span style="color: #0000ff;">var</span> qryCountry <span style="color: #0000ff">=</span> <span style="color: #800080;">queryNew</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">'country'</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> <span style="color: #0000ff;">var</span> arrCountry <span style="color: #0000ff">=</span> <span style="color: #800080;">arrayNew</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">1</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfquery</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryCountry&quot;</span> <span style="color: #0000ff">datasource</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;test&quot;</span><span style="color: #800000;">&gt;</span></span>
		SELECT countryName
		FROM country
		WHERE countryName LIKE <span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;%#ARGUMENTS.country#%&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;/cfquery&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfloop</span> <span style="color: #0000ff">query</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryData&quot;</span><span style="color: #800000;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> arrCountry<span style="color: #000000;">&#91;</span>currentRow<span style="color: #000000;">&#93;</span> <span style="color: #0000ff">=</span> qryCountry.countryName<span style="color: #000000;">&#91;</span>currentRow<span style="color: #000000;">&#93;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;/cfloop&gt;</span></span>
&nbsp;
		<span style="color: #333333;"><span style="color: #0000ff;">&lt;</span>cfreturn arrCountry <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span>
&nbsp;
<span style="color: #333333;"><span style="color: #800000;">&lt;/cfcomponent&gt;</span></span></pre></div></div>

<p><strong>JavaScript</strong></p>
<p>The JavaScript will attach itself after the <acronym title="Document Object Model">DOM</acronym> is ready &#8212; this more or less relates to when the page has loaded in the browser. Each time the text input field, with the ID of country, is changed, the <code>Autocompleter.Ajax.Json</code> event is fired. This makes a call to the ColdFusion component, which returns a <acronym title="JavaScript Object Notation">JSON</acronym> object of matched items. This <acronym title="JavaScript Object Notation">JSON</acronym> object is interpreted by the plugin and rendered as an <abbr title="Hyper-Text Markup Language">HTML</abbr> un-ordered list.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;mootools.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;Observer.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;Autocompleter.js&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; href=&quot;Autocompleter.css&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
window.addEvent('domready', function() {
	new Autocompleter.Ajax.Json(
		'country',
		'data/Country.cfc?method=getCountry&amp;returnformat=json&amp;country=' + $('country').getProperty('value')
		, {
			'minLength': 1, // We wait for at least one character
			'overflow': true // Overflow for more entries'
	});
});
&lt;/script&gt;</pre></div></div>

<h3>Where to Take it Next</h3>
<p><strong>Unobtrusive JavaScript</strong></p>
<p>As with any page that is loaded with JavaScript and <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> functionality, it should work without JavaScript.</p>
<p>To achieve this with the above tutorial, you will need to replace the MooTools autocomplete functionality with an ‘interim’ page that allows a user to select from a list of items, effectively turning the input field into a simple search interface. Of course, all other form field information would need to be retained between pages.</p>
<h3>Download the Code</h3>
<p>The <a href="/examples/autocomplete/mootools/autocomplete.zip" title="Download the example code">example code</a> can be downloaded from the demo page. Included are ColdFusion and PHP examples.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/using-the-mootools-autocompleter-plugin-with-coldfusion/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using jQuery Auto-Complete with ColdFusion</title>
		<link>http://www.simonwhatley.co.uk/using-jquery-auto-complete-with-coldfusion</link>
		<comments>http://www.simonwhatley.co.uk/using-jquery-auto-complete-with-coldfusion#comments</comments>
		<pubDate>Wed, 16 Jul 2008 17:28:05 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[Australia]]></category>
		<category><![CDATA[autocomplete]]></category>
		<category><![CDATA[Bulgaria]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[Dylan Verheul]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[New Brunswick]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[united kingdom]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=587</guid>
		<description><![CDATA[Creating an autocomplete form field historically has not been a trivial matter and would require an indepth knowledge of JavaScript and CSS. However, the task is made far more simple when using one of the many freely-available JavaScript libraries. In this post I will show you how to implement the jQuery Autocomplete created by Dylan Verheul.]]></description>
			<content:encoded><![CDATA[<p>Creating an autocomplete form field historically has not been a trivial matter and would require an indepth knowledge of JavaScript and CSS. However, the task is made far more simple when using one of the many freely-available JavaScript libraries. In this post I will show you how to implement the <a href="http://www.dyve.net/jquery/?autocomplete" title="jQuery Autocomplete Plugin" target="_blank" rel="nofollow">jQuery Autocomplete</a> created by Dylan Verheul.</p>
<h3>The Goal</h3>
<p>Allow the user to type a few characters into a standard form text input field and to automatically provide suggestions from which the user can select.</p>
<h3>Prerequisites</h3>
<ol>
<li>The <a href="http://code.jquery.com/jquery-latest.js" target="_blank">latest copy of jQuery</a></li>
<li>A basic understanding of JavaScript</li>
<li>A server-side script that can respond to the <acronym title="Asynchronous JavaScript and XML">AJAX</acronym> request, in our case ColdFusion</li>
</ol>
<h3>Demo</h3>
<p>The demo will specifically look at a simple form text input field, which takes a country name.</p>
<p><a href="http://www.simonwhatley.co.uk/examples/autocomplete/jquery/">See the demo, and others, in action</a></p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h3>How It Works</h3>
<p>Once the user begins to type into the form text input field, the jQuery autocomplete is activated. After a set time interval, a list of items is displayed below the input field. The user can select these with either the arrow keys or mouse.</p>
<h3>The Code</h3>
<p>There are three parts to this demo:</p>
<ol>
<li>The page&#8217;s HTML.</li>
<li>The server-side code to produce the dynamic page (i.e. to load the autocomplete <code>div</code> when the user types something into the input field).</li>
<li>The jQuery &#038; JavaScript.</li>
</ol>
<p><strong>HTML Form</strong></p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;h3&gt;Example 1.: Country Lookup&lt;/h3&gt;
&lt;p&gt;Using &lt;abbr title=&quot;Asynchronous JavaScript and XML&quot;&gt;AJAX&lt;/abbr&gt; to interrogate the database.&lt;/p&gt;
&lt;p&gt;Example data: Australia, Bulgaria, United Kingdom&lt;/p&gt;
&lt;form name=&quot;frmAutoCompleteCountry&quot; id=&quot;frmAutoCompleteCountry&quot; action=&quot;#&quot; method=&quot;post&quot;&gt;
&lt;p&gt;
&lt;label for=&quot;country&quot;&gt;Country&lt;/label&gt;
&lt;input type=&quot;text&quot; name=&quot;country&quot; id=&quot;country&quot; /&gt;
&lt;/p&gt;
&lt;/form&gt;
&lt;p&gt;NB. If you have &lt;a href=&quot;http://getfirebug.com/&quot; title=&quot;Get Firebug&quot;&gt;Firebug&lt;/a&gt; installed you will be able to view the &lt;abbr title=&quot;Asynchronous JavaScript and XML&quot;&gt;AJAX&lt;/abbr&gt; call.&lt;/p&gt;</pre></div></div>

<p><strong>ColdFusion</strong></p>
<p>This is a simple example, using a database to return a list of country names that match the characters the user has input. You could expand this and return a <acronym title="JavaScript Object Notation">JSON</acronym> data structure.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cfsetting</span> <span style="color: #0000ff">enablecfoutputonly</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;cfquery</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryGetCountry&quot;</span> <span style="color: #0000ff">datasource</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;myDatasource&quot;</span><span style="color: #800000;">&gt;</span></span>
SELECT countryName
FROM Country
WHERE countryName LIKE <span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#URL.q#%&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cfquery&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;cfoutput</span> <span style="color: #0000ff">query</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryGetCountry&quot;</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #0000ff;">#qryGetCountry.countryName##</span>chr(10)<span style="color: #0000ff;">#</span>
<span style="color: #0000ff;"><span style="color: #800000;">&lt;/cfoutput&gt;</span></span></pre></div></div>

<p><strong>JavaScript</strong></p>
<p>The JavaScript will attach itself after the document is ready, i.e. after the page has loaded. Each time the text input field, with the ID of country, is changed, the autocomplete event is fired. This makes a call to the ColdFusion page, which returns a list of matched items.</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;jquery-1.2.6.min.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.autocomplete.js&quot;&gt;&lt;/script&gt;
&lt;link type=&quot;text/css&quot; href=&quot;autocomplete.css&quot; rel=&quot;stylesheet&quot; media=&quot;screen&quot; /&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
$(document).ready(function() {
	$(&quot;#country&quot;).autocomplete(
		&quot;country.cfm&quot;,
		{
			minChars:2,
			delay:200,
			autoFill:false,
			matchSubset:false,
			matchContains:1,
			cacheLength:10,
			selectOnly:1
		}
	);
);
&lt;/script&gt;</pre></div></div>

<h3>Where To Take It Next</h3>
<p><strong>JSON</strong></p>
<p>The above example only shows a simple text list, separated by carriage returns. It is more preferable to use <acronym title="JavaScript Object Notation">JSON</acronym>.</p>
<p><strong>Unobtrusive JavaScript</strong></p>
<p>As with any page that is loaded with JavaScript and AJAX functionality, it should work without JavaScript.</p>
<p>To achieve this with the above tutorial, you will need to replace the jQuery autocomplete functionality with an &#8216;interim&#8217; page that allows a user to select from a list of items, effectively turning the input field into a simple search interface. Of course, all other form field information would need to be retained between pages.</p>
<h3>Download The Code</h3>
<p>The <a href="http://www.simonwhatley.co.uk/examples/autocomplete/jquery/">example code</a> can be downloaded from the demo page. Included are ColdFusion and PHP examples.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/using-jquery-auto-complete-with-coldfusion/feed</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>jQuery 1.2 API Reference</title>
		<link>http://www.simonwhatley.co.uk/jquery-12-api-reference</link>
		<comments>http://www.simonwhatley.co.uk/jquery-12-api-reference#comments</comments>
		<pubDate>Wed, 09 Apr 2008 10:55:25 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[AJAX]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[lightweight applications]]></category>
		<category><![CDATA[reference]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=419</guid>
		<description><![CDATA[Among the plethora of JavaScript libraries to have been released, few have been recognised to be as effective as jQuery. This lightweight library has been the subject of different discussions since it was launched in 2006. Basically, jQuery has the ability to flawlessly string together JavaScript together with HTML. Because of its effectiveness, there have different types of lightweight applications and plug-ins launched using jQuery. Ajax based websites that offers simple interface would virtually work together using jQuery's simple interface.]]></description>
			<content:encoded><![CDATA[<p>Among the plethora of JavaScript libraries to have been released, few have been recognised to be as effective as <a href="http://jquery.com/" title="jQuery" target="_blank" rel="nofollow">jQuery</a>. This lightweight library has been the subject of different discussions since it was launched in 2006. Basically, jQuery has the ability to flawlessly string together JavaScript together with <acronym title="HyperText Markup Language">HTML</acronym>. Because of its effectiveness, there have different types of lightweight applications and plug-ins launched using jQuery. Ajax based websites that offers simple interface would virtually work together using jQuery&#8217;s simple interface.</p>
<p>Download the <a href='http://www.simonwhatley.co.uk/blog/wp-content/uploads/2008/02/jquery12_api_reference.png' title='jQuery 1.2 API Reference'>jQuery 1.2 API Reference</a> (360KB).</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>More information can be found on the <a href="http://jquery.com/" title="jQuery" target="_blank" rel="nofollow">jQuery Website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/jquery-12-api-reference/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ActionScript 3 RIA Reference Guide</title>
		<link>http://www.simonwhatley.co.uk/actionscript-3-ria-reference-guide</link>
		<comments>http://www.simonwhatley.co.uk/actionscript-3-ria-reference-guide#comments</comments>
		<pubDate>Mon, 07 Apr 2008 08:46:21 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Adobe Flash Player]]></category>
		<category><![CDATA[Adobe Integrated Runtime]]></category>
		<category><![CDATA[AIR]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flash Player]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[Internet application development]]></category>
		<category><![CDATA[PDF]]></category>
		<category><![CDATA[reference]]></category>
		<category><![CDATA[Rich Internet Applications]]></category>
		<category><![CDATA[runtime]]></category>
		<category><![CDATA[the Flash Player]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=484</guid>
		<description><![CDATA[The ActionScript reference for rich Internet application development provides an alphabetical reference for all native ActionScript APIs for the Adobe technology platform runtimes: Adobe Flash Player and Adobe AIRâ€”as well as the Adobe Flex framework APIs. Use this guide both as an API reference and a tool to learn about the ActionScript APIs available within the runtimes.]]></description>
			<content:encoded><![CDATA[<p>The ActionScript reference for rich Internet application development provides an alphabetical reference for all native ActionScript <acronym title="Application Programming Interface">API</acronym>s for the Adobe technology platform runtimes: Adobe Flash Player and Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym>â€”as well as the Adobe Flex framework <acronym title="Application Programming Interface">API</acronym>s. Use this guide both as an <acronym title="Application Programming Interface">API</acronym> reference and a tool to learn about the ActionScript <acronym title="Application Programming Interface">API</acronym>s available within the runtimes.</p>
<p>Download the <a href='http://www.simonwhatley.co.uk/blog/wp-content/uploads/2008/04/actionscript_ria_guide.pdf' title='ActionScript reference for RIA development'>ActionScript reference for RIA development</a> (PDF 1.3MB)</p>
<p>The Adobe technology platform contains two primary runtimes. Flash Player is browser-based, and Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym> is desktop-based. Because Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym> is built on top of Flash Player, the Flash Player <acronym title="Application Programming Interface">API</acronym>s are available within Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym>. Consequently, Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym> <acronym title="Application Programming Interface">API</acronym>s are not available within Flash Player. The Flex framework is built on top of the Flash Player <acronym title="Application Programming Interface">API</acronym>s, so it runs in both Flash Player and Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym>. However, a number of Flex <acronym title="Application Programming Interface">API</acronym>s take advantage of <acronym title="Adobe Integrated Runtime">AIR</acronym> <acronym title="Application Programming Interface">API</acronym>s, and thus work only within Adobe <acronym title="Adobe Integrated Runtime">AIR</acronym>.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>More information about this guide can be found on the <a href="http://www.adobe.com/devnet/actionscript/articles/atp_ria_guide.html" title="Adobe Developer Centre Website" target="_blank" rel="nofollow">Adobe Developer Centre Website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/actionscript-3-ria-reference-guide/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Anatomy of the Application.cfc in ColdFusion 8</title>
		<link>http://www.simonwhatley.co.uk/anatomy-of-the-applicationcfc-in-coldfusion-8</link>
		<comments>http://www.simonwhatley.co.uk/anatomy-of-the-applicationcfc-in-coldfusion-8#comments</comments>
		<pubDate>Tue, 18 Mar 2008 09:03:38 +0000</pubDate>
		<dc:creator>Simon</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Adobe ColdFusion]]></category>
		<category><![CDATA[application]]></category>
		<category><![CDATA[CFC]]></category>
		<category><![CDATA[CGI]]></category>
		<category><![CDATA[ColdFusion]]></category>
		<category><![CDATA[ColdFusion Component]]></category>
		<category><![CDATA[cross-site]]></category>
		<category><![CDATA[Framework]]></category>
		<category><![CDATA[HTTP]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[onApplicationEnd]]></category>
		<category><![CDATA[onApplicationStart]]></category>
		<category><![CDATA[onError]]></category>
		<category><![CDATA[onMissingTemplate]]></category>
		<category><![CDATA[onRequest]]></category>
		<category><![CDATA[onRequestEnd]]></category>
		<category><![CDATA[onRequestStart]]></category>
		<category><![CDATA[onSessionEnd]]></category>
		<category><![CDATA[onSessionStart]]></category>
		<category><![CDATA[request]]></category>
		<category><![CDATA[scopes]]></category>
		<category><![CDATA[session]]></category>
		<category><![CDATA[this]]></category>
		<category><![CDATA[www.domain.com]]></category>

		<guid isPermaLink="false">http://www.simonwhatley.co.uk/?p=414</guid>
		<description><![CDATA[With the release of ColdFusion MX 7 came the introduction of the Application.cfc ColdFusion component. This component replaced the traditional Application.cfm and OnRequestEnd.cfm ColdFusion application templates. Furthermore, if Application.cfc is present, both of these templates are ignored by the application.

In addition to replacing the Application.cfm, the Application.cfc introduced a number of built in methods that handle specific events. These events, as discussed in detail below, allow for a greater control over events within the application.]]></description>
			<content:encoded><![CDATA[<p>With the release of ColdFusion MX 7 came the introduction of the Application.cfc ColdFusion component. This component replaced the traditional Application.cfm and OnRequestEnd.cfm ColdFusion application templates. Furthermore, if Application.cfc is present, both of these templates are ignored by the application.</p>
<p>In addition to replacing the Application.cfm, the Application.cfc introduced a number of built in methods that handle specific events. These events, as discussed in detail below, allow for a greater control over events within the application.</p>
<h2>Application Variables</h2>
<p>The <code>THIS</code> scope in the Application.cfc contains several built-in variables that allow you to set the properties of the application.</p>
<p>The following <code>cfscript</code> briefly outlines the variables that you can set to control the application&#8217;s behaviour.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #000099;"><span style="color: #800000;">&lt;cfscript&gt;</span></span>
<span style="color: #000099;"><span style="color: #808080;">//the application name (should be unique)</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff;">name</span> <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;ApplicationName&quot;</span>;</span>
<span style="color: #000099;"><span style="color: #808080;">//how long the application variables persist</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">applicationTimeout</span> <span style="color: #0000ff">=</span> <span style="color: #800080;">createTimeSpan</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">2</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #808080;">//define whether client variables are enabled</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">clientManagement</span> <span style="color: #0000ff">=</span> false;</span>
<span style="color: #000099;"><span style="color: #808080;">//where should we store them, if enabled?</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">clientStorage</span> <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;registry&quot;</span>; <span style="color: #808080;">//cookie||registry||datasource</span></span>
<span style="color: #000099;"><span style="color: #808080;">//define where cflogin information should persist</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">loginStorage</span> <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;session&quot;</span>; <span style="color: #808080;">//cookie||session</span></span>
<span style="color: #000099;"><span style="color: #808080;">//define whether session variables are enabled</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">sessionManagement</span> <span style="color: #0000ff">=</span> true;</span>
<span style="color: #000099;"><span style="color: #808080;">//how long the session variables persist?</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">sessionTimeout</span> <span style="color: #0000ff">=</span> <span style="color: #800080;">createTimeSpan</span><span style="color: #000000;">&#40;</span><span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">0</span>,<span style="color: #ff0000;">20</span>,<span style="color: #ff0000;">0</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #808080;">//define whether to set cookies on the browser?</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">setClientCookies</span> <span style="color: #0000ff">=</span> true;</span>
<span style="color: #000099;"><span style="color: #808080;">//should cookies be domain specific</span></span>
<span style="color: #000099;"><span style="color: #808080;">//i.e. *.domain.com or www.domain.com</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">setDomainCookies</span> <span style="color: #0000ff">=</span> false;</span>
<span style="color: #000099;"><span style="color: #808080;">//should we try to block cross-site scripting?</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">scriptProtect</span> <span style="color: #0000ff">=</span> false;</span>
<span style="color: #000099;"><span style="color: #808080;">//should we secure our JSON calls?</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">secureJSON</span> <span style="color: #0000ff">=</span> false;</span>
<span style="color: #000099;"><span style="color: #808080;">//use a prefix in front of JSON strings?</span></span>
<span style="color: #000099;">THIS.<span style="color: #0000ff">secureJSONPrefix</span> <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;&quot;</span>;</span>
<span style="color: #000099;"><span style="color: #808080;">//used to help ColdFusion work with missing files</span></span>
<span style="color: #000099;"><span style="color: #808080;">//and directory indexes. tells ColdFusion not to call</span></span>
<span style="color: #000099;"><span style="color: #808080;">//onMissingTemplate method.</span></span>
<span style="color: #000099;">THIS.welcomeFi<span style="color: #0000ff;">le</span>L<span style="color: #0000ff;">is</span>t <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;&quot;</span>;</span>
<span style="color: #000099;"><span style="color: #808080;">//define custom coldfusion mappings.</span></span>
<span style="color: #000099;"><span style="color: #808080;">//Keys are mapping names, values are full paths</span></span>
<span style="color: #000099;">THIS.mappings <span style="color: #0000ff">=</span> <span style="color: #800080;">structNew</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;"><span style="color: #808080;">//define a list of custom tag paths.</span></span>
<span style="color: #000099;">THIS.customTagPaths <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;&quot;</span>;</span>
<span style="color: #000099;"><span style="color: #800000;">&lt;/cfscript&gt;</span></span></pre></div></div>

<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<h2>Method Summary</h2>
<p>Below is a brief discussion of the built-in event methods available to the Application.cfc. Since the Application.cfc is a regular ColdFusion component, you can also implement your own methods alongside the built in ones (assuming the names are uniquely different).</p>
<h3>The onApplicationStart Method</h3>
<p>Runs when the application first starts up: when the first request for a page is processed or the first <acronym title="ColdFusion Component">CFC</acronym> method is invoked by an event.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onApplicationStart&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;boolean&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000ff;">&lt;</span>cfreturn true <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This method is typically used to initialise code; for example to to set variables, such as datasource, into the <code>APPLICATION</code> scope, or create <a href="http://en.wikipedia.org/wiki/Singleton_pattern" title="Singleton Design Pattern" target="_blank" rel="nofollow">Singleton</a> instances of ColdFusion components.</p>
<p>For example:</p>
<p>The following example creates structures in tha application scope to store general configuration settings and Singleton objects that can be later referenced by the application framework.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onApplicationStart&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;boolean&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #000099;"><span style="color: #800000;">&lt;cfscript&gt;</span></span>
<span style="color: #000099;">	<span style="color: #808080;">// INITIALISE CONFIGURATION VARIABLES AND APPLICATION BUSINESS COMPONENTS</span></span>
<span style="color: #000099;">	<span style="color: #808080;">// **********************************************************************</span></span>
<span style="color: #000099;">	<span style="color: #808080;">// LOAD COMMON SITE VARIABLES INTO APPLICATION SCOPE</span></span>
<span style="color: #000099;">	<span style="color: #808080;">// create structure to hold configuration settings</span></span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strConfig <span style="color: #0000ff">=</span> <span style="color: #800080;">structNew</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #808080;">//site-wide datasource(s)</span></span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strConfig.<span style="color: #0000ff">datasource</span> <span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;DatasourceName&quot;</span>;</span>
<span style="color: #000099;">	<span style="color: #808080;">// default records per page for pagination</span></span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strConfig.rec<span style="color: #0000ff;">or</span>dsPerPa<span style="color: #0000ff;">ge</span> <span style="color: #0000ff">=</span> <span style="color: #ff0000;">15</span>;</span>
<span style="color: #000099;">	<span style="color: #808080;">// **********************************************************************</span></span>
<span style="color: #000099;">	<span style="color: #808080;">// LOAD PERSISTENT OBJECTS INTO APPLICATION SCOPE</span></span>
<span style="color: #000099;">	<span style="color: #808080;">// data for object instantiation</span></span>
<span style="color: #000099;">	strArgs	<span style="color: #0000ff">=</span> <span style="color: #800080;">structNew</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>; <span style="color: #808080;">// flush strArgs</span></span>
<span style="color: #000099;">	strArgs.<span style="color: #0000ff">datasource</span> <span style="color: #0000ff">=</span> <span style="color: #0000ff">APPLICATION</span>.strConfig.<span style="color: #0000ff">datasource</span>;</span>
&nbsp;
<span style="color: #000099;">	<span style="color: #808080;">// create structure to hold objects</span></span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strObjs <span style="color: #0000ff">=</span> <span style="color: #800080;">structNew</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strObjs.objUserMana<span style="color: #0000ff;">ge</span>r <span style="color: #0000ff">=</span> <span style="color: #800080;">createObject</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;component&quot;</span>,<span style="color: #009900;">&quot;com.whatley.user.UserManager&quot;</span><span style="color: #000000;">&#41;</span>.init<span style="color: #000000;">&#40;</span><span style="color: #0000ff">argumentCollection</span><span style="color: #0000ff;">=</span>strArgs<span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #808080;">//etc...</span></span>
&nbsp;
<span style="color: #000099;">	<span style="color: #808080;">// instantiate utility service objects</span></span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strObjs.objEmailServices <span style="color: #0000ff">=</span> <span style="color: #800080;">createObject</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;component&quot;</span>,<span style="color: #009900;">&quot;com.whatley.service.Email&quot;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strObjs.objFi<span style="color: #0000ff;">le</span>Services <span style="color: #0000ff">=</span> <span style="color: #800080;">createObject</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;component&quot;</span>,<span style="color: #009900;">&quot;com.whatley.service.File&quot;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strObjs.objQueryServices <span style="color: #0000ff">=</span> <span style="color: #800080;">createObject</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;component&quot;</span>,<span style="color: #009900;">&quot;com.whatley.service.Query&quot;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #808080;">//etc...</span></span>
&nbsp;
<span style="color: #000099;">	<span style="color: #808080;">// native coldfusion objects</span></span>
<span style="color: #000099;">	<span style="color: #0000ff">APPLICATION</span>.strObjs.objServiceFact<span style="color: #0000ff;">or</span>y <span style="color: #0000ff">=</span> <span style="color: #800080;">createObject</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">&quot;java&quot;</span>,<span style="color: #009900;">&quot;coldfusion.server.ServiceFactory&quot;</span><span style="color: #000000;">&#41;</span>;</span>
&nbsp;
<span style="color: #000099;">	<span style="color: #808080;">// **********************************************************************</span></span>
<span style="color: #000099;">	return true;</span>
<span style="color: #000099;">	<span style="color: #800000;">&lt;/cfscript&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>Since the objects above are created as Singletons, we do not have to create or destroy objects throughout the application, but simply reference the object held in memory. This is efficient, but of course, would not be suitable for per-session objects, such as shopping carts.</p>
<p>For example:</p>
<p>Referencing and invoking an object from the <code>APPLICATION</code> scope:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cfinvoke</span> <span style="color: #0000ff;">object</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;APPLICATION.strObjs.objUserManager&quot;</span> <span style="color: #0000ff;">method</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;getUser&quot;</span> <span style="color: #0000ff">returnvariable</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryGetUser&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;userId&quot;</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#SESSION.strUser.userId#&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cfinvoke&gt;</span></span></pre></div></div>

<h3>The onApplicationEnd Method</h3>
<p>Runs when the application stops: when the application times out or the service is stopped.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onApplicationEnd&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;applicationScope&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This method is typically used to clean-up currently activities, save the current state of the application to a database or log the application&#8217;s end to a file. The latter can be useful to help determine when and why an application ended.</p>
<p>Below is a simple example of how you could implement a simple log:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onApplicationEnd&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;applicationScope&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
        <span style="color: #333333;"><span style="color: #800000;">&lt;cflog</span> <span style="color: #0000ff">file</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#THIS.Name#&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Information&quot;</span></span>
<span style="color: #333333;">        	<span style="color: #0000ff;">text</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Application #ARGUMENTS.applicationScope.applicationName# Ended&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>Notes:</p>
<ul>
<li>The method is not associated with an individual request so you cannot use it to display data to a user.</li>
<li>If you call this method explicity, ColdFusion does not end the application, but does execute the code within the method.</li>
<li>The method can access the <code>SERVER</code> scope directly, but does not have access to the <code>SESSION</code> and <code>REQUEST</code> scopes.</li>
</ul>
<h3>The onMissingTemplate Method</h3>
<p>Triggered when the user requests a ColdFusion template that doesn&#8217;t exist.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onMissingTemplate&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;boolean&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;targetpage&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000ff;">&lt;</span>cfreturn true <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>ColdFusion invokes this method when it encounters a file not found condition, that is, when a URL specifies a <acronym title="ColdFusion Markup Language">CFML</acronym> page that does not exist. This is an important addition to ColdFusion 8 and allows missing template errors (also known as <a href="http://en.wikipedia.org/wiki/HTTP_404" title="HTTP 404 Error" target="_blank" rel="nofollow">HTTP 404</a> errors) to be captured more efficiently by the application framework.</p>
<h3>The onRequestStart Method</h3>
<p>Runs before the request is processed.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onRequestStart&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;boolean&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;thePage&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #0000ff;">&lt;</span>cfreturn true <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This method is great for user authorisation and login handling and for request specific variable initialisation. For example, you could use this method to log statistics to a database (performance and usage).</p>
<p>As this method runs at the beginning of a request, we can also use it to fire other events. In the example below, I reinitialise the Application which enables me to refresh objects held in memory that may have changed during code development or release.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onRequestStart&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #000099;"><span style="color: #800000;">&lt;cfscript&gt;</span></span>
<span style="color: #000099;">	<span style="color: #808080;">//flush the application scope</span></span>
<span style="color: #000099;">	<span style="color: #0000ff;">if</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>CGI.server_name <span style="color: #0000ff">=</span><span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;localhost&quot;</span><span style="color: #000000;">&#41;</span> || <span style="color: #000000;">&#40;</span><span style="color: #800080;">structKeyExists</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff">URL</span>,<span style="color: #009900;">'refresh'</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">&amp;&amp;</span> <span style="color: #800080;">structKeyExists</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff">URL</span>,<span style="color: #009900;">'password'</span><span style="color: #000000;">&#41;</span> <span style="color: #0000ff;">&amp;&amp;</span> <span style="color: #0000ff">URL</span>.<span style="color: #0000ff">password</span> <span style="color: #0000ff">=</span><span style="color: #0000ff">=</span> <span style="color: #009900;">&quot;p455w0rd&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span></span>
<span style="color: #000099;">	<span style="color: #000000;">&#123;</span></span>
<span style="color: #000099;">		onApplicationStart<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	<span style="color: #000000;">&#125;</span></span>
<span style="color: #000099;">	return true;</span>
<span style="color: #000099;">	<span style="color: #800000;">&lt;/cfscript&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<h3>The onRequest Method</h3>
<p>Runs before the request is processed, but after onRequestStart.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onRequest&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;thePage&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfinclude</span> <span style="color: #0000ff">template</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#ARGUMENTS.thePage#&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This event handler provides an optional request filter mechanism for ColdFusion page requests. Use it to intercept requests to target pages and override the default behavior of running the requested pages. You can use this method to do preprocessing that is required for all requests. Typical uses include filtering and modifying request page contents (such as removing extraneous white space), or creating a switching mechanism that determines the exact page to display based on available parameters.</p>
<h3>The onRequestEnd Method</h3>
<p>Runs at the end of the request when all pages have been processed.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #808080; background-color:#ffff80;">&lt;!--- Runs at end of request ---&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onRequestEnd&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;thePage&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This method can be useful for gathering performance metrics, or for displaying dynamic footer information (although I wouldn&#8217;t generally put display code in an Application.cfc).</p>
<p>For example:</p>
<p>Log the <code>CGI</code> variables to a database table.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onRequestEnd&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfset</span> <span style="color: #0000ff;">var</span> qryInsertStats <span style="color: #0000ff">=</span> <span style="color: #800080;">queryNew</span><span style="color: #000000;">&#40;</span><span style="color: #009900;">'tempCol'</span><span style="color: #000000;">&#41;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfquery</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;qryInsertStats&quot;</span> <span style="color: #0000ff">datasource</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#APPLICATION.strConfig.datasource#&quot;</span><span style="color: #800000;">&gt;</span></span>
	INSERT INTO tbl_site_stats (template,query_string,referer,user_agent,remote_addr,datetime)
	VALUES
	(
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#CGI.PATH_INFO#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#CGI.QUERY_STRING#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#CGI.HTTP_REFERER#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#CGI.HTTP_USER_AGENT#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#CGI.REMOTE_ADDR#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_varchar&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfqueryparam</span> <span style="color: #0000ff;">value</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#now()#&quot;</span> <span style="color: #0000ff">cfsqltype</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;cf_sql_datetime&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	)
	<span style="color: #333333;"><span style="color: #800000;">&lt;/cfquery&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<h3>The onError Method</h3>
<p>Triggered when an error is encountered that is not caught by a try/catch block.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #808080; background-color:#ffff80;">&lt;!--- Runs on error ---&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onError&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;exception&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;eventname&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfdump</span> <span style="color: #0000ff;">var</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#ARGUMENTS#&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
        <span style="color: #333333;"><span style="color: #0000ff;">&lt;</span>cfab<span style="color: #0000ff;">or</span>t <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This method is used to handle errors in an application-specific manner. This method overrides any error handlers that you set in the ColdFusion Administrator or in cferror tags. It does not override try/catch blocks.</p>
<p>For example:</p>
<p>The following displays a friendly, static error page to the user if it is not a development server whilst also logging the error. If the error is on development, simply dump the error to screen for debugging.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onError&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;exception&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;eventName&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;string&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfif</span> CGI.server_name <span style="color: #0000ff;">neq</span> <span style="color: #009900;">&quot;localhost&quot;</span> <span style="color: #0000ff;">and</span> CGI.server_name <span style="color: #0000ff;">neq</span> <span style="color: #009900;">&quot;127.0.0.1&quot;</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #808080; background-color:#ffff80;">&lt;!--- Live application, handle error ---&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfinclude</span> <span style="color: #0000ff">template</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;error/error.htm&quot;</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #808080; background-color:#ffff80;">&lt;!--- Log all errors. ---&gt;</span></span>
	        <span style="color: #333333;"><span style="color: #800000;">&lt;cflog</span> <span style="color: #0000ff">file</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#THIS.Name#&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;error&quot;</span></span>
<span style="color: #333333;">	            <span style="color: #0000ff;">text</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Event Name: #ARGUMENTS.Eventname#&quot;</span> <span style="color: #800000;">&gt;</span></span>
	        <span style="color: #333333;"><span style="color: #800000;">&lt;cflog</span> <span style="color: #0000ff">file</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#THIS.Name#&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;error&quot;</span></span>
<span style="color: #333333;">	            <span style="color: #0000ff;">text</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Message: #ARGUMENTS.Exception.message#&quot;</span><span style="color: #800000;">&gt;</span></span>
	        <span style="color: #333333;"><span style="color: #800000;">&lt;cflog</span> <span style="color: #0000ff">file</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#THIS.Name#&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;error&quot;</span></span>
<span style="color: #333333;">	            <span style="color: #0000ff;">text</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;Root Cause Message: #ARGUMENTS.Exception.rootcause.message#&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfelse&gt;</span></span>
		<span style="color: #333333;"><span style="color: #808080; background-color:#ffff80;">&lt;!--- dump error for Staging and Development ---&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfif</span> <span style="color: #800080;">len</span><span style="color: #000000;">&#40;</span><span style="color: #0000ff">ARGUMENTS</span>.eventName<span style="color: #000000;">&#41;</span><span style="color: #800000;">&gt;</span></span>
			<span style="color: #333333;"><span style="color: #800000;">&lt;cfdump</span> <span style="color: #0000ff;">var</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#ARGUMENTS.eventName#&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;/cfif&gt;</span></span>
		<span style="color: #333333;"><span style="color: #800000;">&lt;cfdump</span> <span style="color: #0000ff;">var</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;#ARGUMENTS.exception#&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;/cfif&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<h3>The onSessionStart Method</h3>
<p>Runs when your session starts.</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onSessionStart&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>This method is used for initialising <code>SESSION</code>-scoped data, such as a shopping basket and application form.</p>
<p>For example:</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onSessionStart&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #000099;"><span style="color: #800000;">&lt;cfscript&gt;</span></span>
<span style="color: #000099;">	SESSION.<span style="color: #0000ff;">start</span> <span style="color: #0000ff">=</span> <span style="color: #800080;">now</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	SESSION.strShoppingBasket <span style="color: #0000ff">=</span> <span style="color: #800080;">structNew</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;</span>
<span style="color: #000099;">	SESSION.strShoppingBasket.items <span style="color: #0000ff">=</span> <span style="color: #ff0000;">0</span>;</span>
<span style="color: #000099;">	<span style="color: #800000;">&lt;/cfscript&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<h3>The onSessionEnd Method</h3>
<p>Runs when session ends</p>

<div class="wp_syntax"><div class="code"><pre class="cfm" style="font-family:monospace;"><span style="color: #333333;"><span style="color: #800000;">&lt;cffunction</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;onSessionEnd&quot;</span> <span style="color: #0000ff">returnType</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;void&quot;</span> <span style="color: #0000ff">output</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;sessionScope&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;struct&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;true&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
	<span style="color: #333333;"><span style="color: #800000;">&lt;cfargument</span> <span style="color: #0000ff;">name</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;appScope&quot;</span> <span style="color: #0000ff;">type</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;struct&quot;</span> <span style="color: #0000ff">required</span><span style="color: #0000ff;">=</span><span style="color: #009900;">&quot;false&quot;</span> <span style="color: #0000ff;">/</span><span style="color: #800000;">&gt;</span></span>
<span style="color: #333333;"><span style="color: #800000;">&lt;/cffunction&gt;</span></span></pre></div></div>

<p>Use this method for any clean-up activities when the session ends. A session ends when the session is inactive for the session time-out period. You can, for example, save session-related data, such as shopping basket contents or whether the user has not completed an order, in a database, or do any other required processing based on the user&#8217;s status. You might also want to log the end of the session, or other session related information, to a file for diagnostic use.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-6475233631580417";
/* 468x60 Basic */
google_ad_slot = "7117418273";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
<p>Adobe Livedocs has a whole <a href="http://livedocs.adobe.com/coldfusion/8/htmldocs/AppEvents_01.html" title="Application.CFC Reference" target="_blank" rel="nofollow">section dedicated to the Application.cfc</a>.</p>
<p>I have created an <a href="http://www.simonwhatley.co.uk/blog/wp-content/uploads/2008/03/application.txt" title="Example Application.cfc Template - ColdFusion 8" target="_blank">example Application.cfc</a>, which is available for <a href="http://www.simonwhatley.co.uk/blog/wp-content/uploads/2008/03/application.txt" title="Example Application.cfc Template - ColdFusion 8" target="_blank">download</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.simonwhatley.co.uk/anatomy-of-the-applicationcfc-in-coldfusion-8/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
	</channel>
</rss>

