<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"><channel><title>RSS feed for InstantSpot site Sam Farmer&apos;s ColdFusion Blog</title><link>http://samfarmer.instantspot.com</link><description>Tips and thoughs on ColdFusion and other technologies that make the web go...</description><language>en-us</language><copyright>This work is Copyright &#xA9; 2009 by Sam Farmer&apos;s ColdFusion Blog</copyright><generator>RSSVille ColdFusion FeedMaker, version 1.0</generator><pubDate>Sat, 07 Nov 2009 14:33:13 GMT</pubDate><item><title>ColdFusion One Liners Presentation at CFinNC Slides Posted</title><link>http://samfarmer.instantspot.com/blog/2009/10/17/ColdFusion-One-Liners-Presentation-at-CFinNC-Slides-Posted</link><description>&lt;p&gt;The slides and code from my ColdFusion One Liners presentation at CFinNC are now up on SlideSix.&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://slidesix.com/view/ColdFusion-One-Liners&quot;&gt;View the presentation on SlideSix&lt;/a&gt;&lt;/p&gt; &lt;p&gt;I enjoyed giving the presentation and if you have any questions let me know.&lt;/p&gt;</description><pubDate>Sat, 17 Oct 2009 19:24:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2009/10/17/ColdFusion-One-Liners-Presentation-at-CFinNC-Slides-Posted</guid><category>ColdFusion 8,ColdFusion 9,CFinNC</category></item><item><title>Use cfajaximport to help with CF8 to CF9 migration</title><link>http://samfarmer.instantspot.com/blog/2009/08/14/Use-cfajaximport-to-help-with-CF8-to-CF9-migration</link><description>&lt;p&gt;This came up in &lt;a href=&quot;http://coldfusionjedi.com/&quot;&gt;Raymond Camden&apos;s&lt;/a&gt; CFUnited presentation this morning and he suggested I blog it so here it is.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;You have extended the cfajax tags by calling the extJS functionality directly.&amp;nbsp; CF8 uses extJS 1.1 whereas CF9 is going to use extJS 3.0.&amp;nbsp; There will be cases it appears where this will break your code as some features have changed from the 1.1 to 3.0 release.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt;&lt;/p&gt; &lt;ol&gt;     &lt;li&gt;Copy the needed JavaScript files (from /cfide/scripts/ajax/*) to another folder in the webroot (say /cfExtJS11/ajax/) and make sure you keep the folder structure.&lt;/li&gt;     &lt;li&gt;On the top of any pages where you the cfajax tags use the cfajaximport tag:&lt;br /&gt;     &lt;br /&gt;     &amp;lt;cfajaximport scriptSrc=&amp;quot;/cfExtJS11&amp;quot;&amp;gt;&lt;/li&gt; &lt;/ol&gt; &lt;p&gt;(Edit 10/14: I made a minor change to item 1 for clarification)&lt;/p&gt;</description><pubDate>Fri, 14 Aug 2009 05:14:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2009/08/14/Use-cfajaximport-to-help-with-CF8-to-CF9-migration</guid><category>ColdFusion 8,ColdFusion 9</category></item><item><title>Submitting a cfform inside a cfdiv to a new page</title><link>http://samfarmer.instantspot.com/blog/2009/06/14/Submitting-a-cfform-inside-a-cfdiv-to-a-new-page</link><description>&lt;p&gt;A form created with cfform inside a cfdiv will submit via AJAX and have the response placed in the div created by the cfdiv.&lt;/p&gt; &lt;p&gt;Its possible, with a little JavaScript and HTML, to have the form submit to a new page and to use the cfform validation if needed.  First lets look at the main page:&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfajaximport tags=&amp;quot;cfform&amp;quot;&amp;gt; &amp;lt;h2&amp;gt;My Page&amp;lt;/h2&amp;gt; &amp;lt;cfdiv bind=&amp;quot;url:theForm.cfm&amp;quot;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;Not doing much here other than setting up a very basic page with a cfdiv that will get the source from theForm.cfm.&amp;nbsp; Lets now look at that page:&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfform method=&amp;quot;post&amp;quot; action=&amp;quot;theDestination.cfm&amp;quot; id=&amp;quot;divForm&amp;quot; name=&amp;quot;divForm&amp;quot;&amp;gt;  Team: &amp;lt;cfinput type=&amp;quot;date&amp;quot; name=&amp;quot;team&amp;quot; id=&amp;quot;team&amp;quot; required=&amp;quot;true&amp;quot; message=&amp;quot;Please enter your team&amp;quot;&amp;gt;  &amp;lt;br&amp;gt;  &amp;lt;cfinput type=&amp;quot;submit&amp;quot; name=&amp;quot;sub&amp;quot; id=&amp;quot;sub&amp;quot; value=&amp;quot;Submit Via AJAX&amp;quot;&amp;gt;&amp;lt;br&amp;gt;  &amp;lt;input type=&amp;quot;button&amp;quot;    onclick=&amp;quot;if (_CF_checkdivForm(this.form)) {document.divForm.submit();}&amp;quot;    value=&amp;quot;Submit the to a New Page&amp;quot;&amp;gt; &amp;lt;/cfform&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;A standard cfform example that uses some validation (I researched this topic because the form I was using had extensive use of the datefield type of cfinput).&amp;nbsp; Clicking on the Submit button will submit the form via AJAX and display the results (I&apos;ve listed theDestination.cfm below).&lt;/p&gt; &lt;p&gt;Clicking on &apos;Submit to a New Page&apos; button (and its a standard html button) will, if the form passes validation, submit to a new page.&amp;nbsp; If it fails validation and the user had not entered a team that message via an alert will be displayed.&amp;nbsp; Lets take a look at the JavaScript inside the onClick:&amp;nbsp;&lt;/p&gt; &lt;p&gt;&lt;font face=&quot;Courier New&quot;&gt;if (_CF_checkdivForm(this.form)) {document.divForm.submit();}&lt;/font&gt;&lt;/p&gt; &lt;p&gt;The function inside the if statement is written by ColdFusion and is there for all cfform produced forms.&amp;nbsp; The name of this function is simply _CF_check and the value placed in the id attribute for cfform.&amp;nbsp; That function will return true or false and if true we tell the browser to submit the form.&lt;/p&gt; &lt;p&gt;For reference here is the coe for theDestination.cfm:&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfdump var=&amp;quot;#form#&amp;quot;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;</description><pubDate>Sun, 14 Jun 2009 20:02:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2009/06/14/Submitting-a-cfform-inside-a-cfdiv-to-a-new-page</guid><category>ColdFusion 8</category></item><item><title>Should Ben Forta Twitter?  What the Stats Say Plus my Quick Review of Twitter</title><link>http://samfarmer.instantspot.com/blog/2009/02/20/Should-Ben-Forta-Twitter--What-the-Stats-Say-Plus-my-Quick-Review-of-Twitter</link><description>&lt;p&gt;[UPDATE] Ben Forta now has a &lt;a href=&quot;http://twitter.com/benforta&quot;&gt;Twitter account&lt;/a&gt; [/UPDATE]&lt;/p&gt; &lt;p&gt;The other day Ben Forta posted an &lt;a href=&quot;http://www.forta.com/blog/index.cfm/2009/2/18/Serges-Adobe-Twitter-Roundup&quot;&gt;entry about Twitter&lt;/a&gt; and mentioned that he was not a user as he &amp;quot;didn&apos;t get the whole Twitter thing&amp;quot;.&amp;nbsp; Fair enough.&lt;/p&gt; &lt;p&gt;I found this interesting because Twitter is essentially &amp;quot;micro-blogging&amp;quot; and Ben&apos;s blog is a mixture of short &amp;quot;micro-blogging&amp;quot; posts generally annoucing news and longer posts that often go in to great detail.&amp;nbsp; So I decided to find out how many of Ben&apos;s entries would qualify for the 140 character twitter maximum.&amp;nbsp; This proved to be rather easy:&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cffeed action=&amp;quot;read&amp;quot; query=&amp;quot;getBen&amp;quot; source=&amp;quot;http://feeds2.feedburner.com/BenForta&amp;quot;&amp;gt;  &amp;lt;cfset twitterOk = 0&amp;gt;   &amp;lt;cfloop query=&amp;quot;getBen&amp;quot;&amp;gt;  &amp;lt;cfset body = ReReplaceNoCase( getBen.content, &amp;quot;&amp;lt;(.|\n)*?&amp;gt;&amp;quot;, &amp;quot;&amp;quot;, &amp;quot;all&amp;quot; )&amp;gt;  &amp;lt;cfif len(body) lte 140&amp;gt;   &amp;lt;cfset twitterOk++&amp;gt;  &amp;lt;/cfif&amp;gt; &amp;lt;/cfloop&amp;gt;  &amp;lt;cfoutput&amp;gt;&amp;lt;h2&amp;gt;#twitterOk# of #getBen.recordCount#&amp;lt;/h2&amp;gt;&amp;lt;/cfoutput&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;3 of Ben&apos;s last 15 entries, stripped of html, would have been ok for Twitter.&amp;nbsp; Maybe its time for Twitter, Ben?&lt;/p&gt; &lt;p&gt;&lt;strong&gt;My Thoughts on Twitter&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;I joined Twitter last summer and have found it to be at times fun, a useful way to find interesteing articles and a good way to do some online networking.&amp;nbsp; I generally follow other technology people and overall have a positive experience of it.&amp;nbsp; &lt;a href=&quot;http://twitter.com/sam_farmer&quot;&gt;Check out my Twitter profile&lt;/a&gt;.&lt;/p&gt;</description><pubDate>Fri, 20 Feb 2009 16:50:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2009/02/20/Should-Ben-Forta-Twitter--What-the-Stats-Say-Plus-my-Quick-Review-of-Twitter</guid><category>ColdFusion 8</category></item><item><title>Kill That Thread!</title><link>http://samfarmer.instantspot.com/blog/2009/02/03/Kill-That-Thread</link><description>&lt;p&gt;Every six months or so we have a thread that will not quit and consumes a lot of resources causing general slowness all round. &amp;nbsp;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Its possible to kill the thread with the following code.&amp;nbsp; Put in your ColdFusion Administrator and the thread name which can be found from Server Monitor.&lt;/p&gt; &lt;p&gt;&lt;br /&gt; &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;adminObj = createObject(&amp;quot;component&amp;quot;,&amp;quot;cfide.adminapi.administrator&amp;quot;); adminObj.login([password]);  sMonObj = createObject(&amp;quot;component&amp;quot;,&amp;quot;cfide.adminapi.servermonitoring&amp;quot;); sMonObj.abortRequest(&amp;quot;jrpp-100&amp;quot;);&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt;</description><pubDate>Wed, 04 Feb 2009 03:50:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2009/02/03/Kill-That-Thread</guid><category>ColdFusion 8</category></item><item><title>CFUnited Presentations Posted: Intro to CFML plus Creating, Manipulating and Printing PDFs</title><link>http://samfarmer.instantspot.com/blog/2008/06/20/CFUnited-Presentations-Posted-Intro-to-CFML-plus-Creating-Manipulating-and-Printing-PDFs</link><description>&lt;p&gt;Here are the presentations and code from my two CFUnited talks.&amp;nbsp; I enjoyed giving the sessions and if you have any questions please let me know.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Creating, Manipulating and Printing PDFs&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://mvsna.org/samfarmer/download/CFB108%20Create%20Manipulte%20Print%20PDFs.pdf&quot;&gt;Presentation (PDF)&lt;/a&gt; and &lt;a href=&quot;http://mvsna.org/samfarmer/download/CFUnitedPDFCode.zip&quot;&gt;Code&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;Intro to CFML as a language&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;a href=&quot;http://mvsna.org/samfarmer/download/GCF101%20Intro%20to%20CFML%20as%20a%20language.pdf&quot;&gt;Presentation (PDF)&lt;/a&gt; and &lt;a href=&quot;http://mvsna.org/samfarmer/download/CFUnitedIntroCode.zip&quot;&gt;Code&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt;</description><pubDate>Fri, 20 Jun 2008 13:39:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2008/06/20/CFUnited-Presentations-Posted-Intro-to-CFML-plus-Creating-Manipulating-and-Printing-PDFs</guid><category>ColdFusion 8,CFUnited</category></item><item><title>cfAjaxProxy and Mach-II</title><link>http://samfarmer.instantspot.com/blog/2008/06/08/cfAjaxProxy-and-MachII</link><description>&lt;p&gt;Here&apos;s an easy way to use cfAjaxProxy with a Mach-II application.&lt;/p&gt; &lt;p&gt;First I created a new cfc that extends Application.cfc to gain access to all of the Mach-II features.&lt;/p&gt; &lt;p&gt;Then add a function with access=&amp;quot;remote&amp;quot; and list all of the arguments (cfajaxproxy requires all arguments be defined).  Next set all the arguments to the form or url scope so that Mach-II can read them.  Finally call handleRequest().&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfcomponent output=&amp;quot;false&amp;quot; extends=&amp;quot;Application&amp;quot;&amp;gt; &amp;lt;cffunction name=&amp;quot;getData&amp;quot; access=&amp;quot;remote&amp;quot; output=&amp;quot;true&amp;quot; hint=&amp;quot;&amp;quot;&amp;gt;  &amp;lt;cfargument name=&amp;quot;artistID&amp;quot; default=&amp;quot;&amp;quot;&amp;gt;  &amp;lt;cfargument name=&amp;quot;artistName&amp;quot; default=&amp;quot;&amp;quot;&amp;gt;  &amp;lt;cfset url.event = &amp;quot;user.edit&amp;quot;&amp;gt;  &amp;lt;cfset url.artistID = arguments.artistID&amp;gt;  &amp;lt;cfset url.artistName = arguments.artistName&amp;gt;  &amp;lt;cfset handleRequest()&amp;gt; &amp;lt;/cffunction&amp;gt; &amp;lt;/cfcomponent&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;I&apos;m sure there are cleaner ways but this works and allows easy use of the great cfAjaxProxy tag in a Mach-II application.&lt;/p&gt;</description><pubDate>Sun, 08 Jun 2008 22:22:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2008/06/08/cfAjaxProxy-and-MachII</guid><category>ColdFusion 8,Mach-II</category></item><item><title>Five Cool Additions and One Undocumented Function in 8.0.1</title><link>http://samfarmer.instantspot.com/blog/2008/04/24/Five-Cool-Additions-and-One-Undocumented-Function-in-801</link><description>&lt;p&gt;The release notes for ColdFusion 8.0.1 detail 10 &lt;a href=&quot;http://www.adobe.com/support/documentation/en/coldfusion/801/cf801releasenotes.pdf&quot;&gt;pages&lt;/a&gt; of tweaks and new features.  Here are five cool additions, and one undocumented function, in no particular order:&lt;/p&gt; &lt;ul&gt;     &lt;li&gt;&lt;strong&gt;Leopard and 64 bit support&lt;/strong&gt;&lt;br /&gt;     Considering the devoted followers of both CF and Apple it was no surprise to see install solutions for CF8 popping up within hours of Leopards release.  As cool as that is a supported release along with 64-bit support is extremely nice.  And, wow, the speed of CF8 on Leopard 64 bit is impressive; re-inits take half the time they use to.&lt;/li&gt;     &lt;li&gt;&lt;strong&gt;Nested Implicit Structure/Array&lt;/strong&gt;&lt;br /&gt;     Nested structures and arrays have always been possible.  Now the implicit expressions work as well like so:&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfset variables.nestIt = {a=[{no=&amp;quot;you did not&amp;quot;,        yes=&amp;quot;I did&amp;quot;,          oh=[&amp;quot;and on&amp;quot;,[&amp;quot;and on&amp;quot;]]}]}&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/li&gt;     &lt;li&gt;&lt;strong&gt;cfwindow refreshOnShow attribute&lt;/strong&gt;&lt;br /&gt;     When using a source for cfwindow the default behavior is to cache the response for when the window is closed and then opened.  I recently stumbled into this problem in an application I&apos;m building.  When refreshOnShow = true anytime the window is shown the content will be grabbed from the server.&lt;/li&gt;     &lt;li&gt;&lt;strong&gt;Watermark with html&lt;/strong&gt;&lt;br /&gt;     cfpdf action=&amp;quot;watermark&amp;quot; can now take html with formating in addition to an image.  A nice, nice addition.&lt;/li&gt;     &lt;li&gt;&lt;strong&gt;Richtext area for Safari&lt;/strong&gt;&lt;br /&gt;     Finally!  WYSIWYG textarea support for Safari (3.0 and up) users.  Big thanks should go to the &lt;a href=&quot;http://www.fckeditor.net/&quot;&gt;FCKEditor&lt;/a&gt; team on this one since its their work along with Adobe&apos;s integration that makes it possible to do &lt;cftextarea name=&quot;saf&quot; richtext=&quot;true&quot;&gt;&lt;/cftextarea&gt; and have a rich textarea.  I am especially happy with this as Safari is my current favorite browser (this can and does change often).&lt;/li&gt; &lt;/ul&gt; &lt;p&gt;The other addition is an undocumented function: getPrinterList() that well, returns a list of printers that cfprint can print to.&lt;/p&gt; &lt;p&gt;(I will be presenting &amp;quot;&lt;a href=&quot;http://cfunited.com/go/topics/2008#topic-1565&quot;&gt;Creating, Manipulating and Printing PDFs&lt;/a&gt;&amp;quot; and &amp;quot;&lt;a href=&quot;http://cfunited.com/go/topics/2008#topic-1725&quot;&gt;Intro to CFML as a Language&lt;/a&gt;&amp;quot; at &lt;a href=&quot;http://cfunited.com/&quot;&gt;CFUnited&lt;/a&gt; in June.)&lt;/p&gt;</description><pubDate>Thu, 24 Apr 2008 13:00:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2008/04/24/Five-Cool-Additions-and-One-Undocumented-Function-in-801</guid><category>ColdFusion 8</category></item><item><title>cfaui (Adobe User Intelligence) tags and functions up on Adobe Labs</title><link>http://samfarmer.instantspot.com/blog/2008/04/01/cfaui-Adobe-User-Intelligence-tags-and-functions-up-on-Adobe-Labs</link><description>&lt;p&gt;The most exciting feature of the ColdFusion 8 Updater 1 (now posted to Adobe Labs) is the new cfaui tags and functions.  aui stands for Adobe User Intelligence and allows us CF developers to do a whole bunch of new cool stuff (rumors suggest a Flex version is on the way as well).&lt;/p&gt; &lt;p&gt;It is based on the technology in cfajaxproxy and the embedded Apache Derby database and can be added to any page by placing&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfaui action=&amp;quot;track&amp;quot; trackID=&amp;quot;#session.userID&amp;quot;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;anywhere on the page.  This will track all actions a user takes on the page, store it in a database and constantly analyze it.  The first cool usage is the action=&amp;quot;hover&amp;quot; attribute which after a set period will display the text in any element defined on the page.  Here&apos;s an example:&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfaui action=&amp;quot;hover&amp;quot; element=&amp;quot;hoverTR&amp;quot; milliseconds=&amp;quot;1000&amp;quot;  messageElement=&amp;quot;messageSpan&amp;quot; message=&amp;quot;Most people pick chocolate&amp;quot; /&amp;gt;  &amp;lt;tr id=&amp;quot;hoverTR&amp;quot;&amp;gt;    &amp;lt;td&amp;gt;Favorite Ice Cream&amp;lt;/td&amp;gt;    &amp;lt;td&amp;gt;&amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;favIceCrean&amp;quot;&amp;gt;     &amp;lt;span id=&amp;quot;messageSpan&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/td&amp;gt; &amp;lt;/tr&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;What this does is after 1000 seconds of a user hovering over the the tr with the id of &amp;quot;hoverTR&amp;quot; it will place the content of the message attribute in the span with the id of &amp;quot;messageSpan&amp;quot;.&lt;/p&gt; &lt;p&gt;One UI challenge I have always faced is whether to use a text box or select box for collecting a US state.  Well with the new auiInputPreference function its now possible to give the user what they would prefer.  Look at this example:&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfif auiInputPreference(session.userID, &amp;quot;keyboard&amp;quot;)&amp;gt;   &amp;lt;input type=&amp;quot;text&amp;quot; name=&amp;quot;state&amp;quot;&amp;gt; &amp;lt;cfelse&amp;gt;    &amp;lt;select name=&amp;quot;state&amp;quot;&amp;gt;.... &amp;lt;/cfif&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;The auiInputPreference function will always return a boolean.  In this example I ask if the user has shown a preference for using the keyboard and if so will display a text box, if not (and in this case it would mean they lean towards using the mouse to move between fields) show a select box.&lt;/p&gt; &lt;p&gt;There are many other cool functions and features of the aui suite of tags and functions.  Head over to the Adobe Labs and check out the &lt;a href=&quot;http://en.wikipedia.org/wiki/April_Fools&apos;_Day&quot;&gt;documentation on the beta for ColdFusion 8 Updater 1&lt;/a&gt;.&lt;/p&gt;</description><pubDate>Tue, 01 Apr 2008 12:22:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2008/04/01/cfaui-Adobe-User-Intelligence-tags-and-functions-up-on-Adobe-Labs</guid><category>ColdFusion 8</category></item><item><title>DerbyCFC: New Project with createIfNotExists function for Derby Databases</title><link>http://samfarmer.instantspot.com/blog/2008/01/20/DerbyCFC-New-Project-with-createIfNotExists-function-for-Derby-Databases</link><description>&lt;p&gt;I&apos;ve just released version 0.9 of &lt;a href=&quot;http://derbycfc.riaforge.org/&quot;&gt;DerbyCFC&lt;/a&gt; on &lt;a href=&quot;http://www.riaforge.org/&quot;&gt;RIAForge&lt;/a&gt; which is designed to make it easier to work with the Derby database embedded in ColdFusion 8.&lt;/p&gt; &lt;p&gt;DerbyCFC comes with two functions; createIfNotExists which does pretty much what it says and will create a new Derby datasource and database.  getDerbyDatasources returns all Derby datasources in either raw format (a collection of structures) or as a query with a slightly smaller set of attributes.&lt;/p&gt; &lt;p&gt;&lt;img alt=&quot;&quot; src=&quot;http://derbycfc.riaforge.org/screenshots/createIfNotExists.png&quot; /&gt;&lt;/p&gt; &lt;p&gt;The download zip includes example pages for creating a datasource and listing of current datasources.  Go to the &lt;a href=&quot;http://derbycfc.riaforge.org/&quot;&gt;DerbyCFC project page&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;I&apos;m debating whether to extend this to provide a UI that would list and edit tables in a Derby database so let me know your thoughts.  My hope is that this will make it easier to create Derby databases for other open source projects.&lt;/p&gt;</description><pubDate>Sun, 20 Jan 2008 23:21:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2008/01/20/DerbyCFC-New-Project-with-createIfNotExists-function-for-Derby-Databases</guid><category>ColdFusion 8,DerbyCFC</category></item><item><title>cfdump output attrribute, The What, Why and How</title><link>http://samfarmer.instantspot.com/blog/2008/01/04/cfdump-output-attrribute-The-What-Why-and-How</link><description>&lt;p&gt;&lt;strong&gt;The What&lt;/strong&gt;&lt;br /&gt; Starting with ColdFusion 8 Adobe added a new attribute, output, to the incredibly popular cfdump tag.  The default value is browser which works exactly how it has since the tags inception.&lt;br /&gt; &lt;br /&gt; &lt;strong&gt;The Why&lt;/strong&gt;&lt;br /&gt; So, why use the output attribute?  Mostly at a time when the request is not going back to the browser such as a scheduled task or when the data is going to an AJAX request or Flex.  Or to log something -- the advantage of using cfdump output= over cflog is cfdump will parse whatever you throw at it into a text format. &lt;br /&gt; &lt;br /&gt; &lt;strong&gt;The How&lt;/strong&gt;&lt;br /&gt; cfdump takes any cf variables or pretty much any type of object and returns the data.  Here is the classic cfdump of a query&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfquery datasource=&amp;quot;cfartgallery&amp;quot; name=&amp;quot;getArtists&amp;quot;&amp;gt; SELECT artistID, city, firstname, lastname, state  FROM artists WHERE state = &apos;DC&apos; &amp;lt;/cfquery&amp;gt;  &amp;lt;cfdump var=&amp;quot;#getArtists#&amp;quot;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;produces&lt;br /&gt; &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/dumpBrowser.png&quot; alt=&quot;&quot; /&gt;&lt;br /&gt; &lt;br /&gt; &lt;br /&gt; Place a filename in the output attribute and ColdFusion will dump the contents in a text format to that file.  If the file does not exist, CF will create it, if it does exist CF will append to it.&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfdump var=&amp;quot;#getArtists#&amp;quot; output=&amp;quot;/artists.txt&amp;quot;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;Here is the output in artists.txt&lt;br /&gt; &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/dumpTextFile.png&quot; alt=&quot;&quot; /&gt;&lt;br /&gt; Note the text format of data output, instead of just dumping the html that gets returned to the browser, cf provides a lighter format for the output files. &lt;br /&gt; &lt;br /&gt; The third option is console which if you started CF from a command prompt will dump the output to the command prompt.  If not CF will place the output in the cfserver.log file.  To start CF from a command prompt from a multi-instance install open up terminal and cd to /Applications/JRun/bin and enter  &lt;code&gt;./JRun -start cfusion&lt;/code&gt; (Windows startup would be very similar).  It is possible to start up the standard edition from the command line but there is little point to doing so as CF will still send the output to cfserver.log. &lt;br /&gt; &lt;br /&gt; To send output to the console simply set output=&amp;quot;console&amp;quot;:&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfdump var=&amp;quot;#getArtists#&amp;quot; output=&amp;quot;console&amp;quot;&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;produces this in Terminal:&lt;br /&gt; &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/dumpTerminal.png&quot; alt=&quot;&quot; /&gt; &lt;br /&gt; Macs have a handy log viewer which works with any log file and automatically refreshes to show any changes.  Here is the cfserver.log after running the above code on a Mac CF Standard Edition:&lt;br /&gt; &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/console.png&quot; alt=&quot;&quot; /&gt;  &lt;br /&gt; Overall the output attribute adds some useful capabilities to an extremely useful tag.&lt;/p&gt;</description><pubDate>Fri, 04 Jan 2008 13:25:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2008/01/04/cfdump-output-attrribute-The-What-Why-and-How</guid><category>ColdFusion 8</category></item><item><title>Turn Long URLs in to Short Ones with ShortURL</title><link>http://samfarmer.instantspot.com/blog/2007/12/10/Turn-Long-URLs-in-to-Short-Ones-with-ShortURL</link><description>&lt;p&gt; I have just released a new project on RIAForge called &lt;a href=&quot;http://shorturl.riaforge.org/&quot;&gt;ShortURL&lt;/a&gt;  that utilizes the onMissingTemplate function of ColdFusion 8.  The full project description: &lt;/p&gt; &lt;p&gt; &lt;em&gt;Short URL takes any URL then creates a random 6 character string and adds .cfm to it. When the link is clicked on onMissingTemplate receieves the URL, looks up the full URL and forwards the user to the full URL. Very similar to tinyURL and other services except this is hosted on your domain. &lt;/em&gt; &lt;/p&gt; &lt;p&gt; Jason Delmore suggested a while back that more ColdFusion open-source projects should have an install file.  I have taken an attempt at this so install.cfm creates a database table and alters a setting in the Application.cfc file.  After downloading the project, unzip it and run install.cfm. &lt;/p&gt; &lt;p&gt; This is a first release so if you find any problems let me know (we have been using this at &lt;a href=&quot;http://interfolio.com/&quot;&gt;Interfolio&lt;/a&gt;  for 6 weeks with no problems).  &lt;/p&gt; </description><pubDate>Mon, 10 Dec 2007 13:02:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/12/10/Turn-Long-URLs-in-to-Short-Ones-with-ShortURL</guid><category>ColdFusion 8,ShortURL</category></item><item><title>How Interfolio Uses ColdFusion 8</title><link>http://samfarmer.instantspot.com/blog/2007/11/13/How-Interfolio-Uses-ColdFusion-8</link><description>&lt;p&gt;  Sean Corfield recently &lt;a href=&quot;http://corfield.org/blog/index.cfm/do/blog.entry/entry/Loving_ColdFusion_8&quot;&gt;blogged&lt;/a&gt; about some of the ways his company, Scazu, uses ColdFusion 8.  I started to write a comment but it got long and morphed into this entry. At Interfolio, back in March, we received permission to build our revised product line on ColdFusion 8. I estimate that we saved at least a month of development time (4 to 3 months) due to this.  We also won the Best of Scorpio contest as mentioned by &lt;a href=&quot;http://www.cfinsider.com/index.cfm/2007/8/23/Best-of-Scorpio-Winners&quot;&gt;Jason Delmore&lt;/a&gt;  for which we won a PlayStation 3 (and has exposed how woefully bad I am at video games).  &lt;/p&gt;  &lt;p&gt;  Here are some of the ways &lt;a href=&quot;http://interfolio.com/&quot;&gt;Interfolio&lt;/a&gt;  uses ColdFusion 8:  &lt;/p&gt;  &lt;p&gt;  &lt;strong&gt;Front End&lt;/strong&gt;  &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;cfajaxproxy -- use of cfajaxproxy has allowed us to write web interfaces that are dynamic based on a single proxy to a cfc.  Both our delivery and add document pages have different sections that rely on each other for rules and data, and implementing this has been very straightforward.   The serializeJSON function has allowed us to take a ColdFusion query and return it to the browser as JSON simply by passing the query to the function.&lt;/li&gt;   &lt;li&gt;cfsprydataset -- use of the cfsprydataset tag and form bindings has allowed us to refresh a dataset based on criteria a user selects.&lt;/li&gt;   &lt;li&gt;cfwindow -- we use this to collect survey data and provide quick updates in our admin section.&lt;/li&gt;   &lt;li&gt;cfdiv and AjaxLink -- by placing a cfform inside a cfdiv the form is then submitted via AJAX and the returning html replaces the content of the cfdiv all without writing a line of JavaScript or reloading the page. With our new release we have implemented tagging to documents and persons. We have used the cfdiv and cfform tag to make this process as dynamic, interactive and responsive as possible to the user.&lt;/li&gt;   &lt;li&gt;cfselect bindings -- we use this to simplify the classic two selects related functionality. &lt;br /&gt;   &lt;/li&gt;   &lt;li&gt;cfinput type=datefield and cfinput autosuggest -- the ease of adding a html calendar to a form and an autosuggest is staggering and has led to us using these features in places where we might not have spent the time in the past.&lt;/li&gt;  &lt;/ul&gt;  &lt;p&gt;  &lt;strong&gt;Processing&lt;/strong&gt;  &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;cffeed -- our company blog is hosted by Wordpress, we use cffeed to pull in the latest entries and display them in our product.&lt;/li&gt;   &lt;li&gt;cfzip -- we use cfzip to combine multiple pdfs into one download.&lt;/li&gt;   &lt;li&gt;cfpdf and cfpdfparam -- previously we used a third party tool to create a cover sheet and merge pdfs together.  Now we use cfdocument to create the cover sheet and cfpdf with cfpdfparam to merge the pdf.&lt;/li&gt;   &lt;li&gt;image functions -- we use several of the new image functions, in particular, to resize uploaded images.&lt;/li&gt;   &lt;li&gt;cflocation statuscode -- our present application has many pages that we will not be using anymore.  By using the new statuscode attribute of cflocation we can set permanently moved header information.&lt;/li&gt;   &lt;li&gt;file functions -- for more efficient file operations we use the new file operations such as FileMove() and FileCopy().&lt;/li&gt;   &lt;li&gt;Retrieval of auto generated identity keys -- previously we would have an extra query to obtain the value of the new ID, now we use the result structure and the generated_key key.&lt;/li&gt;  &lt;/ul&gt;  &lt;p&gt;  &lt;strong&gt;Language Enhancement&lt;/strong&gt;  &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Application defined mappings and custom tag paths -- by defining mappings and custom tag paths inside an Application.cfc file has allowed us the ability to dynamically set these at runtime and drop and run our code with ease.&lt;/li&gt;   &lt;li&gt;Implicit structure and array creation -- fewer lines and more readable code makes our development faster and cleaner.&lt;/li&gt;   &lt;li&gt;onMissingMethod -- we have implemented a service layer for our application but, instead of writing a bunch of very similar functions that simply call a Gateway, we use onMissingMethod to call the gateway.&lt;/li&gt;   &lt;li&gt;onMissingTemplate -- we create a &amp;quot;tinyurl&amp;quot; like short url for placing in emails.  These links do not actually exist but are caught by onMissingTemplate which looks up the correct page and sends the user there. (I will be releasing this functionality in the next few days)&lt;/li&gt;  &lt;/ul&gt;  &lt;p&gt;  &lt;strong&gt;Server Monitor&lt;/strong&gt;  &lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;We have an old computer running in our development room with server monitor up at all times for a real time view of the server.  We have also used the slow requests and slow query features to tune our application. &lt;/li&gt;  &lt;/ul&gt;  </description><pubDate>Tue, 13 Nov 2007 12:24:52 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/11/13/How-Interfolio-Uses-ColdFusion-8</guid><category>ColdFusion 8</category></item><item><title>ColdFusion 8: Append File Faster and Leaner</title><link>http://samfarmer.instantspot.com/blog/2007/11/05/ColdFusion-8-Append-File-Faster-and-Leaner</link><description>&lt;p&gt;While the cffile tags are extremely useful they are a bit of a resource hog because they load the actual file into memory.  ColdFusion 8 brings new file functions that interact with the file system directly.  Last week I saw just how much faster and leaner using these functions is.  I needed to loop over a 155,000 line file, do a regular expression on the line and append it to a new file.&lt;/p&gt; &lt;p&gt;Doing this with cffile action=&amp;quot;append&amp;quot; I could see the memory increase in the server monitor and it took on average 46 seconds.  I then switched out cffile action=&amp;quot;append&amp;quot; with the code below, ran it saw no memory increase in the server monitor and it took 20 seconds on average. &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfset variables.fileobj= fileOpen(&amp;quot;/fileLocation/OnYourcomputer/FileName.txt&amp;quot;, &amp;quot;append&amp;quot; )&amp;gt; &amp;lt;cfset fileWriteLine(variables.fileObj,&amp;quot;&amp;quot; )&amp;gt; &amp;lt;cfset fileClose(variables.fileobj)&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;Notice how in the fileOpen function I set the mode to append.  Oh, and I was also using cfloop file=&amp;quot;&amp;quot; with this which interacts directly with the file and makes looping over files easy.&lt;/p&gt;</description><pubDate>Mon, 05 Nov 2007 13:15:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/11/05/ColdFusion-8-Append-File-Faster-and-Leaner</guid><category>ColdFusion 8</category></item><item><title>Ok, That&apos;s Cool.  CF8 Debugging Tools</title><link>http://samfarmer.instantspot.com/blog/2007/10/11/Ok-Thats-Cool--CF8-Debugging-Tools</link><description>&lt;p&gt;  Until I started working with AJAX (and Flex) I never saw the need for more of a debugging tool than cfdump. Having struggled debugging tough problems and wondering&amp;nbsp; what exactly was going on I now see the need and two new ColdFusion 8 tools make my life much easier.  First, enter the JavaScript based &amp;quot;ColdFusion AJAX Logger&amp;quot; which is based on the &lt;a href=&quot;http://developer.yahoo.com/yui/logger/&quot;&gt;YUI Logger&lt;/a&gt;  with some extra features for CF coders.  The ColdFusion AJAX Logger will show all the AJAX activity going on between the browser and the server; requests made, the JSON response, etc.  And even better if ColdFusion returns an exception the cfdebug window will show this:  &lt;/p&gt;  &lt;p&gt;  &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/cfDebugException.png&quot; alt=&quot;ColdFustion Ajax Logger&quot; title=&quot;ColdFustion Ajax Logger&quot; width=&quot;500&quot; height=&quot;391&quot; /&gt; &lt;br /&gt;  &lt;/p&gt;  &lt;p&gt;  How do you turn it on?  Permissions for it are set in the CF Administrator once turned on simply add cfdebug= to the URL.   It is also possible to send JavaScript messages to it by writing ColdFusion.Log.Dump(obj).  This works almost exactly like cfdump and is a nice alternative to alert boxes.&lt;br /&gt;  &lt;/p&gt;  &lt;p&gt;  But what if you want more?  Then enter the Eclipse based ColdFusion Debugger.  Until I used this I never understood why people liked debuggers. Now I do.  And, wow, it provides more information than you know what to do with.  Here are all the variables shown from a breakpoint placed in a very simple file:  &lt;/p&gt;  &lt;p&gt;  &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/AllVariables.png&quot; alt=&quot;ColdFusion Debugger Variables&quot; title=&quot;ColdFusion Debugger Variables&quot; width=&quot;500&quot; height=&quot;360&quot; /&gt; &lt;br /&gt;  &lt;/p&gt;  &lt;p&gt;  The scopes to show can be customized (Preferences &amp;gt; ColdFusion &amp;gt; Debug Settings) and include: application, arguments, attributes, caller, cgi, client, cookie, form, flash, function_variables, request, server, session, thistag, url, variables.  And even better check the option to &amp;#39;Break on a CFML runtime exception&amp;#39; and then next time an error occurs this will happen:  &lt;/p&gt;  &lt;p&gt;  &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/CaughtException.png&quot; alt=&quot;CF Exception&quot; title=&quot;CF Exception&quot; width=&quot;500&quot; height=&quot;245&quot; /&gt; &lt;br /&gt;  &lt;/p&gt;  &lt;p&gt;  Click OK and this comes up with all the variable information and an arrow on the left to indicate the line of the error:  &lt;/p&gt;  &lt;p&gt;  &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/CaughtExceptionArrow.png&quot; alt=&quot;Exception with Arrow&quot; title=&quot;Exception with Arrow&quot; width=&quot;500&quot; height=&quot;249&quot; /&gt; &lt;br /&gt;  &lt;/p&gt;  &lt;p&gt;  Oddly enough it does not show a dump of the error information (and enhancement for 9?) but will show all the variables and values which should give enough information to easily debug the bug.&amp;nbsp; The download can be found &lt;a href=&quot;http://www.adobe.com/support/coldfusion/downloads.html&quot;&gt;here&lt;/a&gt; (ColdFusion 8 Extensions for Eclipse) and installation instructions &lt;a href=&quot;http://samfarmer.instantspot.com/#%20http://livedocs.adobe.com/coldfusion/8/htmldocs/usingdebugger_1.html&quot;&gt;here&lt;/a&gt; .   &lt;/p&gt;  &lt;p&gt;  Overall these two debugging features emphasis the point of what a well rounded release ColdFusion 8 is. &lt;br /&gt;  &lt;/p&gt;  </description><pubDate>Thu, 11 Oct 2007 11:10:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/10/11/Ok-Thats-Cool--CF8-Debugging-Tools</guid><category>ColdFusion 8</category></item><item><title>Two ColdFusion 8 Features Make My Day a Little Easier</title><link>http://samfarmer.instantspot.com/blog/2007/09/21/Two-ColdFusion-8-Features-Make-My-Day-a-Little-Easier</link><description>&lt;p&gt;At work I have recently used two of the less sexy but still solid new features of ColdFusion 8.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;cfloop file=&amp;quot;&amp;quot; index=&amp;quot;&amp;quot;&lt;/strong&gt; &lt;br /&gt; This will take a file, loop over it line by line and put each line in the variable assigned in index.  Now this used to be possible by using cffile and then looping over it as if it where a list.  The advantages of the new way are a) the less code to write and b) ColdFusion now reads the file line by line and does not place it in memory (as it does with the cffile tag) meaning its possible to parse huge files without seeing your memory jump.  I parsed a 140 MB file with no memory increase (thanks server monitor!). &lt;br /&gt; &lt;br /&gt; &lt;strong&gt;cffeed source=&amp;quot;&amp;quot; query=&amp;quot;&amp;quot;&lt;/strong&gt; &lt;br /&gt; Next up I had the need to process some RSS feeds so enter the cffeed tag.  The cffeed tag takes a source and returns it in several ways.  My favorite being as a query.  I&apos;ve worked with queries for 10 years so am much more comfortable processing that than having to loop over some XML.&lt;/p&gt; &lt;p&gt;The cffeed tag has multiple return formats; if you want the XML use the &lt;em&gt;xmlVar&lt;/em&gt; attribute, just the properties of the feed with the &lt;em&gt;properties&lt;/em&gt; attribute, the XML parsed into an array and structure use &lt;em&gt;name&lt;/em&gt; or to save it as a file with the &lt;em&gt;outputFile&lt;/em&gt; attribute.  In fact any combination of the above will work.  cffeed can also create RSS feeds.  Read the full documentation &lt;a href=&quot;http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=Tags_f_01.html#4002452&quot;&gt;here&lt;/a&gt;&lt;/p&gt; &lt;p&gt;A few other notes from using RSS:  &lt;br /&gt; 1) Wordpress seems to return better information in its atom feeds.  Just add atom/ to the end of a feed, it seems to be an undocumented feature (or one I could not find). &lt;br /&gt; 2) Atom feeds return datetime with a T between the date and time.  ColdFusion will not read this as a datetime.  A workaround?  Simply replace the T with a space before calling any date or time functions.&lt;/p&gt; &lt;p&gt;Both of these new features made my day a little easier which is a big reason for using ColdFusion in the first place.&lt;/p&gt;</description><pubDate>Fri, 21 Sep 2007 09:58:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/09/21/Two-ColdFusion-8-Features-Make-My-Day-a-Little-Easier</guid><category>ColdFusion 8</category></item><item><title>ColdFusion 8 License Plate</title><link>http://samfarmer.instantspot.com/blog/2007/09/19/ColdFusion-8-License-Plate</link><description>&lt;p&gt;  While riding my bike around DC I saw this ColdFusion themed license plate and snapped a photo with my cell phone:  &lt;/p&gt;  &lt;p&gt;  &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/cf8plate.jpg&quot; alt=&quot;CF 0866&quot; title=&quot;CF 0866&quot; width=&quot;316&quot; height=&quot;194&quot; /&gt;  &lt;/p&gt;  &lt;p&gt;  License plates in DC have the following syntax: Two Letters -- Flag -- 4 numbers.  So this is not a custom plate merely a standard one.  And those two 6&amp;#39;s?  Well there are two 6&amp;#39;s in the current version number of ColdFusion:  &lt;/p&gt;  &lt;p&gt;  &lt;img src=&quot;http://samfarmer.instantspot.com/userfiles/040107/117/cfversion.png&quot; alt=&quot;CF Version&quot; title=&quot;8,0,0,176276&quot; width=&quot;267&quot; height=&quot;82&quot; /&gt;  &lt;/p&gt;  &lt;p&gt;  (Wondering what the &amp;quot;Taxation Without Representation&amp;quot; refers to? Find out on this ColdFusion 8 powered &lt;a href=&quot;http://www.dcvote.org/&quot;&gt;site&lt;/a&gt;.)&lt;br /&gt;  &lt;/p&gt;  </description><pubDate>Wed, 19 Sep 2007 11:51:32 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/09/19/ColdFusion-8-License-Plate</guid><category>ColdFusion 8</category></item><item><title>ColdFusion 8: How to cfDump Vars</title><link>http://samfarmer.instantspot.com/blog/2007/09/05/ColdFusion-8-How-to-cfDump-Vars</link><description>&lt;p&gt;A while back I posted an undocumented way to &lt;a href=&quot;http://samfarmer.instantspot.com/blog/index.cfm/2007/4/11/How-to-Dump-Vars&quot;&gt;dump the var scope&lt;/a&gt;.  Well, ColdFusion 8 has changed its internals a bit and, as a consequence, that method no longer returns the actual var scope.  This is a good reminder to never use undocumented features in production.&lt;/p&gt; &lt;p&gt;There is still a way to dump the var scope in ColdFusion 8:&lt;/p&gt; &lt;p&gt;&amp;lt;cfdump var=&amp;quot;#getPageContext().getActiveFunctionLocalScope()#&amp;quot;&amp;gt;&lt;/p&gt; &lt;p&gt;Now, this will also return the arguments and this scope which may be overkill or may be usefull.  To see just the var scope use the hde attribute of cfdump and do this:&lt;/p&gt; &lt;p&gt;&amp;lt;cfdump hide=&amp;quot;arguments,this&amp;quot; var=&amp;quot;#getPageContext().getActiveFunctionLocalScope()#&amp;quot;&amp;gt;&lt;/p&gt;</description><pubDate>Wed, 05 Sep 2007 10:03:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/09/05/ColdFusion-8-How-to-cfDump-Vars</guid><category>ColdFusion 8</category></item><item><title>ColdFusion 8: AutoSaving with cfAjaxProxy</title><link>http://samfarmer.instantspot.com/blog/2007/08/27/ColdFusion-8-AutoSaving-with-cfAjaxProxy</link><description>&lt;p&gt;I&apos;ve &lt;a href=&quot;http://samfarmer.instantspot.com/blog/index.cfm/2007/8/15/ColdFusion-8-Auto-Saving-a-Form-is-Straightforward-&quot;&gt;written before&lt;/a&gt; about using the new ColdFusion 8 JavaScript cfform libraries to autosave a form.  Autosaving a form can also be accomplished using cfajaxproxy.  Lets delve into the code:&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfajaxproxy cfc=&amp;quot;Draft&amp;quot; jsclassname=&amp;quot;DraftObj&amp;quot;&amp;gt; &amp;lt;s.cript type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;autoSaveProxy.js&amp;quot;&amp;gt; &amp;lt;/s.cript&amp;gt; &amp;lt;h2&amp;gt;Auto Save Demo&amp;lt;/h2&amp;gt; &amp;lt;div id=&amp;quot;messageArea&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;form name=&amp;quot;auto&amp;quot; id=&amp;quot;auto&amp;quot;&amp;gt; Title: &amp;lt;input name=&amp;quot;title&amp;quot; id=&amp;quot;title&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&amp;lt;br&amp;gt; Radio: &amp;lt;input name=&amp;quot;question1&amp;quot; value=&amp;quot;yes&amp;quot; type=&amp;quot;radio&amp;quot;&amp;gt;Yes &amp;lt;input name=&amp;quot;question1&amp;quot; value=&amp;quot;no&amp;quot; type=&amp;quot;radio&amp;quot;&amp;gt;No&amp;lt;br&amp;gt; Checkbox: &amp;lt;input name=&amp;quot;question2&amp;quot; value=&amp;quot;cf7&amp;quot; type=&amp;quot;checkbox&amp;quot;&amp;gt;CF7 &amp;lt;input name=&amp;quot;question2&amp;quot; value=&amp;quot;cf8&amp;quot; type=&amp;quot;checkbox&amp;quot;&amp;gt;CF8&amp;lt;br&amp;gt; Entry: &amp;lt;textarea richtext=&amp;quot;true&amp;quot; toolbar=&amp;quot;Basic&amp;quot; name=&amp;quot;entry&amp;quot;&amp;gt;&amp;lt;/textarea&amp;gt; &amp;lt;/form&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;The first line creates the cfajaxproxy which makes remote functions in the Draft.cfc callable by JavaScript.  The rest is simply html (I&apos;ve added a dot in the script tag &amp;mdash; remove before running)&lt;/p&gt; &lt;p&gt;What functions do we have in Draft.cfc?&lt;/p&gt; &lt;p&gt;&lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfcomponent output=&amp;quot;false&amp;quot;&amp;gt;  &amp;lt;cffunction name=&amp;quot;saveDraft&amp;quot; access=&amp;quot;remote&amp;quot;&amp;gt;   &amp;lt;cfdump var=&amp;quot;#arguments#&amp;quot; output=&amp;quot;/misc/auto.txt&amp;quot;&amp;gt;   &amp;lt;cfreturn true=&amp;quot;&amp;quot;&amp;gt;         &amp;lt;/cffunction&amp;gt; &amp;lt;/cfcomponent&amp;gt;&lt;/pre&gt;&lt;/div&gt;&lt;/p&gt; &lt;p&gt;Just one that will handle saving a draft of the form.  Note, that I dump the arguments scope, last time it was the form scope.  Working with a cfajaxproxy is straightforward here is the Javascript:&lt;/p&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;pre&gt;&lt;code&gt;function autoSave(){&lt;br /&gt; var d = new DraftObj();&lt;br /&gt; d.setCallbackHandler(setSaveTime);&lt;br /&gt; d.setForm(&apos;auto&apos;);&lt;br /&gt; d.setHTTPMethod(&apos;POST&apos;)&lt;br /&gt; d.saveDraft();&lt;br /&gt; autoSaveEvery(120000);&lt;br /&gt;}&lt;br /&gt;function autoSaveEvery(ms) {&lt;br /&gt; var timeout=setTimeout(&amp;quot;autoSave()&amp;quot;,ms);&lt;br /&gt;}&lt;br /&gt;function setSaveTime(res) {&lt;br /&gt; if (res) {&lt;br /&gt;  document.getElementById(&apos;messageArea&apos;).innerHTML = &apos;Autosaved at &apos; + nowFormated();&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;function nowFormated(){&lt;br /&gt; var now = new Date();&lt;br /&gt; var ampm = &amp;quot;AM&amp;quot;;&lt;br /&gt; var hour = new Number(now.getHours());&lt;br /&gt; if (hour &amp;gt; 12) {&lt;br /&gt;  ampm = &amp;quot;PM&amp;quot;;&lt;br /&gt;  hour = hour - 12;&lt;br /&gt; } else if (hour == 0) {&lt;br /&gt;  hour = 12;&lt;br /&gt; }&lt;br /&gt; var minutes = new Number(now.getMinutes());&lt;br /&gt; if (minutes &amp;lt;= 9) {&lt;br /&gt;  minutes = &amp;quot;0&amp;quot; + minutes;&lt;br /&gt; }&lt;br /&gt; return hour + &amp;quot;:&amp;quot; + minutes + &amp;quot; &amp;quot; + ampm;&lt;br /&gt;}&lt;/code&gt;&lt;/pre&gt; &lt;p&gt;The only difference with the JavaScript for the &lt;a href=&quot;http://samfarmer.instantspot.com/blog/index.cfm/2007/8/15/ColdFusion-8-Auto-Saving-a-Form-is-Straightforward-&quot;&gt;previous examples&lt;/a&gt; is in the autoSave function. The cfajaxproxy creates the JavaScript to easily send data to and from a cfc.  setCallbackHandler, setForm, setHTTPMethod are all functions that come with the cfAjaxProxy as is the functionality for new DraftObj().  DraftObj is the value of the jsclassname attribute of cfAjaxproxy.  &lt;a href=&quot;http://samfarmer.instantspot.com/blog/index.cfm/2007/6/20/ColdFusion-8-Screencast-of-cfAjaxProxy-the-Tag-That-Blurs-The-Line-Between-CF-and-JS&quot;&gt;More on cfAjaxProxy&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Why use cfAjaxProxy and not one of the cfform methods?  If the page needs to do anything else, say, check a username or email is unique, via AJAX then cfAjaxProxy is probably the best way.&lt;/p&gt;</description><pubDate>Mon, 27 Aug 2007 11:04:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/08/27/ColdFusion-8-AutoSaving-with-cfAjaxProxy</guid><category>ColdFusion 8</category></item><item><title>ColdFusion 8: Auto Saving a Form is Straightforward </title><link>http://samfarmer.instantspot.com/blog/2007/08/15/ColdFusion-8-Auto-Saving-a-Form-is-Straightforward-</link><description>&lt;p&gt;Made popular by GMail the ability to auto save a draft of a form is becoming more and more commonplace.  And with ColdFusion 8 its very straightforward thanks to the included JavaScript libraries and in particular this line of code:&lt;/p&gt; &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;ColdFusion.Ajax.submitForm(&amp;quot;auto&amp;quot;, &amp;quot;draftform.cfm&amp;quot;,setSaveTime);&lt;/pre&gt;&lt;/div&gt;  &lt;p&gt;This will submit, via AJAX, the form with an id of &quot;auto&quot; to draftform.cfm and send any response from that page to the JavaScript function setSaveTime.  What does that function do?  It nicely displays a message saying a draft was autosaved at the current time (or at least the current time the users computer is set to).&lt;/p&gt;  &lt;p&gt;But, back to the ColdFusion.  How do we include the needed JavaScript libraries?  Well, if you use cfform it is automatically included as the example below shows (note also the use of a richtext area):&lt;/p&gt; &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;s.cript type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;autoSave.js&amp;quot;&amp;gt;&amp;lt;/s.cript&amp;gt; &amp;lt;h2&amp;gt;Auto Save Demo&amp;lt;/h2&amp;gt; &amp;lt;div id=&amp;quot;messageArea&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;cfform name=&amp;quot;auto&amp;quot; id=&amp;quot;auto&amp;quot;&amp;gt; Title: &amp;lt;input name=&amp;quot;title&amp;quot; id=&amp;quot;title&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&amp;lt;br&amp;gt; Radio: &amp;lt;cfinput type=&amp;quot;radio&amp;quot; name=&amp;quot;question1&amp;quot; value=&amp;quot;yes&amp;quot;&amp;gt;Yes &amp;lt;cfinput type=&amp;quot;radio&amp;quot; name=&amp;quot;question1&amp;quot; value=&amp;quot;no&amp;quot;&amp;gt;No&amp;lt;br&amp;gt; Checkbox: &amp;lt;cfinput type=&amp;quot;checkbox&amp;quot; name=&amp;quot;question2&amp;quot; value=&amp;quot;cf7&amp;quot;&amp;gt;CF7 &amp;lt;cfinput type=&amp;quot;checkbox&amp;quot; name=&amp;quot;question2&amp;quot; value=&amp;quot;cf8&amp;quot;&amp;gt;CF8&amp;lt;br&amp;gt; Entry: &amp;lt;cftextarea richtext=&amp;quot;true&amp;quot; toolbar=&amp;quot;Basic&amp;quot; name=&amp;quot;entry&amp;quot;&amp;gt;&amp;lt;/cftextarea&amp;gt; &amp;lt;/cfform&amp;gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;The other way is to use cfajaximport which will import the needed JavaScript libraries as this code shows:&lt;/p&gt; &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfajaximport tags=&amp;quot;cfform&amp;quot;&amp;gt; &amp;lt;s.cript type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;autoSave.js&amp;quot;&amp;gt;&amp;lt;/s.cript&amp;gt; &amp;lt;h2&amp;gt;Auto Save Demo&amp;lt;/h2&amp;gt; &amp;lt;div id=&amp;quot;messageArea&amp;quot;&amp;gt;&amp;lt;/div&amp;gt; &amp;lt;form name=&amp;quot;auto&amp;quot; id=&amp;quot;auto&amp;quot;&amp;gt; Title: &amp;lt;input name=&amp;quot;title&amp;quot; id=&amp;quot;title&amp;quot; size=&amp;quot;30&amp;quot;&amp;gt;&amp;lt;br&amp;gt; Radio: &amp;lt;input name=&amp;quot;question1&amp;quot; value=&amp;quot;yes&amp;quot; type=&amp;quot;radio&amp;quot;&amp;gt;Yes &amp;lt;input name=&amp;quot;question1&amp;quot; value=&amp;quot;no&amp;quot; type=&amp;quot;radio&amp;quot;&amp;gt;No&amp;lt;br&amp;gt;  Checkbox: &amp;lt;input name=&amp;quot;question2&amp;quot; value=&amp;quot;cf7&amp;quot; type=&amp;quot;checkbox&amp;quot;&amp;gt;CF7 &amp;lt;input name=&amp;quot;question2&amp;quot; value=&amp;quot;cf8&amp;quot; type=&amp;quot;checkbox&amp;quot;&amp;gt;CF8&amp;lt;br&amp;gt; Entry: &amp;lt;textarea richtext=&amp;quot;true&amp;quot; toolbar=&amp;quot;Basic&amp;quot; name=&amp;quot;entry&amp;quot;&amp;gt;&amp;lt;/textarea&amp;gt; &amp;lt;/form&amp;gt;&lt;/pre&gt;&lt;/div&gt;  &lt;p&gt;To fire off the autosave action the onLoad attribute of the body tag calls autoSaveEvery with an argument of milliseconds.  This function calls the JavaScript function setTimeout which after the specified number of milliseconds will call autoSave.  autoSave contains the ColdFusion.Ajax.submitform line and then calls autoSaveEvery to begin the cycle again.  Anyway here is the code:&lt;/p&gt; &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;function autoSave(){  ColdFusion.Ajax.submitForm(&amp;quot;auto&amp;quot;, &amp;quot;draftform.cfm&amp;quot;,setSaveTime);  autoSaveEvery(120000); } function autoSaveEvery(ms) {  var timeout=setTimeout(&amp;quot;autoSave()&amp;quot;,ms); } function setSaveTime(res) {  if (res) {   document.getElementById(&apos;messageArea&apos;).innerHTML = &apos;Autosaved at &apos; + nowFormated();  } } function nowFormated(){  var now = new Date();  var ampm = &amp;quot;AM&amp;quot;;  var hour = new Number(now.getHours());  if (hour &amp;amp;gt; 12) {   ampm = &amp;quot;PM&amp;quot;;   hour = hour - 12;  } else if (hour == 0) {   hour = 12;  }  var minutes = new Number(now.getMinutes());  if (minutes &amp;amp;lt;= 9) {   minutes = &amp;quot;0&amp;quot; + minutes;  }  return hour + &amp;quot;:&amp;quot; + minutes + &amp;quot; &amp;quot; + ampm; }&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;Oh, and what does draftform.cfm do?  Whatever you want it to!  I would suggest entering the form data into a database and have a column isDraft that would be set to 1 (or something like that).  While playing with this I just had it dump the form contents to a file and return true as seen here:&lt;/p&gt; &lt;div class=&quot;code&quot; &gt;&lt;pre&gt;&amp;lt;cfdump var=&amp;quot;#form#&amp;quot; output=&amp;quot;/misc/auto.txt&amp;quot;&amp;gt; &amp;lt;cfoutput&amp;gt;true&amp;lt;/cfoutput&amp;gt;&lt;/pre&gt;&lt;/div&gt; &lt;p&gt;There is also a way to do this with cfajaxproxy, once I play with that I will blog it as well. [UPDATE: 8/27/07 Here is &lt;a href=&quot;http://samfarmer.instantspot.com/blog/index.cfm/2007/8/27/ColdFusion-8-AutoSaving-with-cfAjaxProxy&quot;&gt;that entry&lt;/a&gt;. ]&lt;/p&gt;</description><pubDate>Wed, 15 Aug 2007 10:00:00 GMT</pubDate><guid>http://samfarmer.instantspot.com/blog/2007/08/15/ColdFusion-8-Auto-Saving-a-Form-is-Straightforward-</guid><category>ColdFusion 8</category></item></channel></rss>