<?xml version="1.0" encoding="utf-8"?>

			<rss version="2.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:cc="http://web.resource.org/cc/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd">

			<channel>
			<title>Blog of Shaun McCran - Architecting robust, elegant technical and business solutions - Frameworks</title>
			<link>http://www.mccran.co.uk/index.cfm</link>
			<description>I write about Architecture and Design, Architectural patterns, Architectural Principles and Architectural policies. This includes TOGAF, Zachman, Business Architecture, SOA and Process and tools such as the IBM Rational software and Adobe products. I also write about my previous life as a mobile and web developer.</description>
			<language>en-gb</language>
			<pubDate>Tue, 09 Jun 2026 06:52:29 -0000</pubDate>
			<lastBuildDate>Thu, 28 Jan 2010 15:08:00 -0000</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>shaun@mccran.co.uk</managingEditor>
			<webMaster>shaun@mccran.co.uk</webMaster>
			<itunes:subtitle></itunes:subtitle>
			<itunes:summary></itunes:summary>
			<itunes:category text="Technology" />
			<itunes:category text="Technology">
				<itunes:category text="Podcasting" />
			</itunes:category>
			<itunes:category text="Technology">
				<itunes:category text="Tech News" />
			</itunes:category>
			<itunes:keywords></itunes:keywords>
			<itunes:author></itunes:author>
			<itunes:owner>
				<itunes:email>shaun@mccran.co.uk</itunes:email>
				<itunes:name></itunes:name>
			</itunes:owner>
			
			<itunes:explicit>no</itunes:explicit>
			
			
			
			
			
			<item>
				<title>Passing url variables through Isapi re write - Regular Expression</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/1/28/Passing-url-variables-through-Isapi-re-write--Regular-Expression</link>
				<description>
				
				One of the more common tasks in ColdFusion development is passing variables through the URL string. We are all familiar with the idea that the question mark (?) denotes the url query string start, and that name value pairs are separated with the ampersand (&amp;). 

I usually avoid using this in display templates, as it isn&apos;t great exposing your internal site workings to customers, and with Fusebox it is very easy to pass the URL variables to an &quot;act_&quot; template and remain hidden.

What happens when you want to use dynamic url variables with a URL re writing application like Isapi re write? I&apos;ve been using Isapi re write in some FuseBox framework application, and it is relatively easy to set up a rewrite rule, as shown below.

&lt;code&gt;
RewriteRule home(/) index.cfm?fuseaction=circuitname.circuitfunction
&lt;/code&gt; 

Where the url /home/ would actually serve up the content specified in the fuse specified. But this is hard coded. What about dynamic variables?

We can create a regular expression to handle the translation of the variables.

&lt;code&gt;
RewriteRule destination/(.*)/(.*)/  index.cfm?go=circuitname.circuitfunction&amp;$1=$2
&lt;/code&gt;

We use a similar URL, but append the dollar ($) 1 = dollar ($) 2 string. In the re write rule we specify that appended variables are transposed into the string using the slash (/) as a separator.

So as an example we could pass a product id of 24 into the rule  like this:

&lt;code&gt;
www.siteurl.com/cart/productId/24/
RewriteRule buy/(.*)/(.*)/  index.cfm?go=cart.buy&amp;$1=$2
&lt;/code&gt;

It would be rewritten to the more familiar url string. A handy way of continuing to mask the url.
				
				</description>
				
				
				<category>Coldfusion</category>
				
				<category>Frameworks</category>
				
				<category>Isapi rewrite</category>
				
				<category>Web technologies</category>
				
				<pubDate>Thu, 28 Jan 2010 15:08:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/1/28/Passing-url-variables-through-Isapi-re-write--Regular-Expression</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Using Coldfusion to generate JQuery validation scripts</title>
				<link>http://www.mccran.co.uk/index.cfm/2010/1/17/Using-Coldfusion-to-generate-JQuery-validation-scripts</link>
				<description>
				
				One of the ideas that we have been throwing around the office is creating a platform that will create the form-validation-database cycle automatically. Something akin to ORM, but not. ORM looks good, but we want more control over what is happening.
&lt;p&gt;
In this article I am exploring the idea of automatically creating JQuery validation from a simple Coldfusion input. In this case a list of required fields. I&apos;ll say up front Ray Camden&apos;s blog entry on Jquery Validation (&lt;a href=&quot;http://www.coldfusionjedi.com/index.cfm/2009/2/10/An-Introduction-to-jQuery-and-Form-Validation-2&quot; target=&quot;_blank&quot;&gt;http://www.coldfusionjedi.com/index.cfm/2009/2/10/An-Introduction-to-jQuery-and-Form-Validation-2&lt;/a&gt;) has been an invaluable help.
&lt;p&gt;
The principle behind this is that you can create a generic validation object routine, and simple provide it with a set data object (list or struct, haven&apos;t decided yet) and have it match against a form and validate it. So with that in mind we will create a simple form.


&lt;code&gt;
&lt;form name=&quot;form&quot; id=&quot;form&quot; method=&quot;post&quot; action=&quot;index.cfm?inline=#url.inline#&quot;&gt;

&lt;label for=&quot;name&quot;&gt;Name&lt;/label&gt;&lt;br/&gt;
&lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; class=&quot;form-field&quot;&gt;&lt;p/&gt;

&lt;label for=&quot;telephone&quot;&gt;Telephone&lt;/label&gt;&lt;br/&gt;
&lt;input type=&quot;text&quot; name=&quot;telephone&quot; id=&quot;telephone&quot; class=&quot;form-field&quot;&gt;&lt;p/&gt;

&lt;label for=&quot;email&quot;&gt;Email&lt;/label&gt;&lt;br/&gt;
&lt;input type=&quot;text&quot; name=&quot;email&quot; id=&quot;email&quot; class=&quot;form-field&quot;&gt;&lt;p/&gt;

&lt;label for=&quot;favouriteSandwhich&quot;&gt;Favourite Sandwhich&lt;/label&gt;&lt;br/&gt;
&lt;input type=&quot;text&quot; name=&quot;favouriteSandwhich&quot; id=&quot;favouriteSandwhich&quot; class=&quot;form-field&quot;&gt;&lt;p/&gt;

&lt;input type=&quot;submit&quot; name=&quot;action&quot; value=&quot;Submit&quot;&gt;

&lt;/form&gt;
&lt;/code&gt;
As you can see from above, this is a simple form.  Next we will include references to the Google code repository for the AJAX library, and out JQuery validation plugin.

&lt;code&gt;
&lt;scr/ipt type=&quot;text/javascript&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js&quot;&gt;&lt;/script&gt;
&lt;scr/ipt type=&quot;text/javascript&quot; src=&quot;jquery.validate.pack.js&quot;&gt;&lt;/script&gt;

&lt;/code&gt;

Next we have the JQuery script to validate our fields. Firstly we create a list of the fields that are required. By doing this it is incredibly easy to add another required field to the model.

&lt;code&gt;
&lt;cfset variables.requiredList = &quot;name,email&quot;&gt;
&lt;/code&gt;

The next phase of this will probably accept a structure rather than a list, in that way I can combine field lengths and any other custom criteria, rather than merely the fact that it is required.

The JQuery validation starts off in exactly the same way as usual, we create a function to catch the validation request, and use the id of the form as the reference. We declare the error container style of &quot;#error&quot;.

Next we loop over our list inside the &quot;rules:&quot; element. This creates the required rules for each field. I&apos;ve also added a basic check for the value &apos;email&apos;. This will create an email validation rule. Next we create custom messages in the &quot;message:&quot; element. Again this catches the email value and adds an appropriate message.

&lt;code&gt;

		&lt;scri/pt&gt;
		$(document).ready(function(){
			$(&quot;#form&quot;).validate({
			
			errorContainer: &quot;#error&quot;,
			errorLabelContainer: &quot;#error ul&quot;,
			wrapper: &quot;li&quot;,

			rules: {
				&lt;cfoutput&gt;
					&lt;cfloop list=&quot;#variables.requiredList#&quot; index=&quot;variables.index&quot;&gt;
					#variables.index#: {required: true &lt;cfif findNoCase(&apos;email&apos;, variables.index, &apos;1&apos;)&gt;, email: true&lt;/cfif&gt;,  minlength: 5},
					&lt;/cfloop&gt;
				&lt;/cfoutput&gt;
					},

			messages: {
				
				&lt;cfoutput&gt;
					&lt;cfloop list=&quot;#variables.requiredList#&quot; index=&quot;variables.index&quot;&gt;
					#variables.index#: {required: &quot;The #variables.index# field is required&quot;,
					&lt;cfif findNoCase(&apos;email&apos;, variables.index, &apos;1&apos;)&gt; email: &quot;Email addresses are of the form user@host. Please enter a valid email address.&quot;,&lt;/cfif&gt;
					 minlength: jQuery.format(&quot;You need to use at least {0} characters for your name.&quot;)
					},
					
					&lt;/cfloop&gt;
				&lt;/cfoutput&gt;
			
					  }
								}
			);
		});
		&lt;/script&gt;
&lt;/code&gt;

Lastly we can create a style for the #error container we declared above.

&lt;code&gt;
&lt;style&gt;
/* Error handling styles */
#error {-moz-background-clip:border; 
		-moz-background-inline-policy:continuous;
		-moz-background-origin:padding; 
		background:#FFE7DF;
		background-position: 5px 8px;
		border: #FF3F00 solid 1px;
		color:#440000;
		margin:10px 0 1em;
		padding:0px 7px 7px 7px;
		display:none;
		width: 90%;}

/* padding for the list */
#error ul {list-style-type:none; padding: 0px 0px 0px 0px;}

/* padding for the list items */
#error ul li {padding: 4px 0 2px 16px;}

.error {color: red; list-style-type:none; padding: 0px 0px 0px 0px; width: 198px; color:#440000; background:#FFE7DF;}
li {list-style-type:none;}	
.form-field {width: 200px; padding: 0px 0px 0px 0px;}
&lt;/style&gt;

&lt;/code&gt;
&lt;p&gt;
This creates a totally dynamic validation routine - all fed from a list. I think it forms a good basis to build a more dynamic rules driven model, where you can set field lengths as well.
&lt;p&gt;
There is an example of the complete code here, along with a variation on the inline or external placing of the validation messages.
&lt;p&gt;
&lt;a href=&quot;http://www.mccran.co.uk/examples/validation/index.cfm&quot; target=&quot;_blank&quot;&gt;Follow this link for a demo of the JQuery validation model&lt;/a&gt;.
				
				</description>
				
				
				<category>JQuery</category>
				
				<category>Coldfusion</category>
				
				<category>Frameworks</category>
				
				<category>Javascript</category>
				
				<category>AJAX</category>
				
				<pubDate>Sun, 17 Jan 2010 23:08:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2010/1/17/Using-Coldfusion-to-generate-JQuery-validation-scripts</guid>
				
				
			</item>
			
		 	
			
			
			<item>
				<title>Using Isapi rewrite to serve up non existing templates</title>
				<link>http://www.mccran.co.uk/index.cfm/2009/12/16/Using-Isapi-rewrite-to-serve-up-non-existing-templates</link>
				<description>
				
				I was discussing some ideas for an application framework this morning with the team, and one of the issues we hit upon was having a common directory for templates, but serving them up as if they were from a different directory. 

The idea is to have one instance of a reusable skinnable template, that appears to live on several sites.

IE all the content lives in &quot;webroot/content/templateName.cfm&quot;, but is actually served up by many sites, IE &quot;127.0.0.1/site1/template1.cfm&quot;, &quot;127.0.0.1/site2/template1.cfm&quot; ... etc

In this way they can be re skinned or adapted as needed, and they aren&apos;t database driven. The main stumbling block for the discussion was the need to actually create blank versions of each of the named templates, in each of the sites, as ColdFusion server would error on the request. 

I spent twenty minutes trying to work it so that my Application.cfc&apos;s onRequest or onRequestStart method would intercept the request before it was actually made, but that just wasn&apos;t working. My other idea was to use the onMissingTemplate method, but the server is only running ColdFusion 7, so that was a no go (I figured I could catch the missing template request and just re path it, although I&apos;d have to assess if that was really inefficient due to almost every page request logging as failed).

My eventual solution was Isapi rewrite. I am re writing all the requests to the same template, and just passing in the template variable. In that way I can request pages that don&apos;t actually exist, but they appear in the url.

Create an index.cfm template like this:

&lt;code&gt;
&lt;h1&gt;I am the index page&lt;/h1&gt;
&lt;ul&gt;
	&lt;li&gt;&lt;a href=&quot;page1&quot;&gt;Page 1&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;page2&quot;&gt;Page 2&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;page3&quot;&gt;Page 3&lt;/a&gt;&lt;/li&gt;
	&lt;li&gt;&lt;a href=&quot;page4&quot;&gt;Page 4&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;cfdump var=&quot;#url#&quot;&gt;
&lt;!--- write a handler to go get the url var passed in ---&gt;
&lt;/code&gt;

For this example I am using the free version of Helicon&apos;s Isapi rewrite, you can get it here: &lt;a href=http://www.helicontech.com/download-isapi_rewrite.htm target=&quot;new_win&quot;&gt;Link to Helicons Isapi re write&lt;/a&gt;

In the example below I have altered the first page link to look like it is actually a .cfm template request, just in case you want the url string to have a .fileextension look to it.

&lt;code&gt;
# Helicon ISAPI_Rewrite configuration file
# Version 3.1.0.68

RewriteEngine on
RewriteBase /mywebroot

#no physical page testing
RewriteRule page1.cfm(/)? isapitest/index.cfm?p=page1 
RewriteRule page2(/)? /index.cfm?p=page2
RewriteRule page3(/)? /index.cfm?p=page3
RewriteRule page4(/)? /index.cfm?p=page4

&lt;/code&gt;

So when you fire it up and test it you just see /page1, /page2 etc, and the pages don&apos;t actually exist.

I&apos;m not experienced enough with Isapi rewrite to know if there is a downside to this, but bookmarking in  a browser still works correctly, so I can&apos;t see an issues at present.
				
				</description>
				
				
				<category>Software Architecture</category>
				
				<category>Coldfusion</category>
				
				<category>Frameworks</category>
				
				<category>Isapi rewrite</category>
				
				<category>Web technologies</category>
				
				<pubDate>Wed, 16 Dec 2009 13:19:00 -0000</pubDate>
				<guid>http://www.mccran.co.uk/index.cfm/2009/12/16/Using-Isapi-rewrite-to-serve-up-non-existing-templates</guid>
				
				
			</item>
			
		 	
			</channel></rss>