<?xml version="1.0" encoding="utf-8"?>
			
			<rss version="2.0">
			<channel>
			<title>CFNewbie?com</title>
			<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm</link>
			<description>CFNewbie?com</description>
			<language>en-us</language>
			<pubDate>Wed, 08 Sep 2010 13:17:21-0700</pubDate>
			<lastBuildDate>Sat, 18 Aug 2007 12:04:00-0700</lastBuildDate>
			<generator>BlogCFC</generator>
			<docs>http://blogs.law.harvard.edu/tech/rss</docs>
			<managingEditor>tom.barr@gmail.com</managingEditor>
			<webMaster>tom.barr@gmail.com</webMaster>
			
			
			
			
			
			<item>
				<title>CFMAIL Attachment Missing</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/18/CFMAIL-Attachment-Missing</link>
				<description>
				
				I was working on a project to create an Excel spreadsheet from a form that need to be mailed off to an email address. I used CFFILE to create the file, CFMAIL to mail the file, and CFFILE to delete the file from a temp directory. It all seemed to be working except the attachment wasn&apos;t there.

My suspicion was that CFMAIL was still working when CFFILE deleted the file. This happens because CFMAIL spools the email by writing it to a text file that ColdFusion monitors and generates emails from. This is fine if you just want to send a bunch of emails the emails can be written to the spool and your template can go on with its business. If you want to send an attachment then you need to have CFMAIL complete its spooling and mailing operations before deleting. This might be tricky to do but CFMAIL has a parameter called spoolEnable which has a default of yes. So to avoid the file deletion during a spooling delay just add spoolEnable=&quot;no&quot; to your CFMAIL tag.

Example:
&lt;code&gt;
&lt;cffile action=&quot;upload&quot; 
   filefield=&quot;excel_upload&quot; 
   destination=&quot;C:\temp&quot; 
   accept=&quot;application/msexcel&quot;
   nameconflict=&quot;makeunique&quot; /&gt;

&lt;cfmail to=&quot;address@company.com&quot; 
   from=&quot;#sender#&quot; 
   subject=&quot;file attachment&quot; 
   spoolEnable=&quot;no&quot;&gt;
   mail message
&lt;cfmailparam file = &quot;C:\temp\#file.serverfile#&quot;    disposition=&quot;attachment&quot; /&gt;
&lt;/cfmail&gt;

&lt;cffile action=&quot;delete&quot; 
   file=&quot;C:\temp\#file.serverfile#&quot; /&gt;
&lt;/code&gt;
				
				</description>
						
				
				<category>CFMAILPARAM</category>				
				
				<category>CFFILE</category>				
				
				<category>CFMAIL</category>				
				
				<pubDate>Sat, 18 Aug 2007 12:04:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/18/CFMAIL-Attachment-Missing</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Let SQL Do The Data Work</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/17/Let-SQL-Do-The-Data-Work</link>
				<description>
				
				Many come to ColdFusion from HTML development and find out that CF is great for putting data into their beautiful web pages. The natural tendency is to select all the database and dump it into the page. As the data grows, the new developer will pick up some SQL skills to filter the list down and even do some grouping of data and then output it nicely on the page. ColdFusion does this well with its CFOUTPUT attribute GROUP. This is all just wonderful.

Then a requirement comes along. Our aspiring developer then figures out he can use CFLOOPS and CFIF statements to control the output with even more but he notices his code is getting messy and pages are loading more slowly. He is sensing that he might be asking ColdFusion to do things the database server is better suited for. He is right.

A good practice in web application development is to separate the data manipulation from the data presentation. Database servers are designed to crunch data efficiently and have functions built in to do most if not all of the data manipulation. A developer should strive to have the data all crunched and manipulated before it is presented back to ColdFusion for presentation.

I was recently asked by someone online how they could get maximum value from a group of items with the same id. This would be like finding the top sales rep where the database table (monthly_sales) has the region id (id) and the sales dollars (sales). A developer could query the database for all records for the month and sort by sales dollars and id and then loop through the results and use CFSET and CFIF to out put only the first sales rep in each region. This would be asking the database to send back more data then necessary and would be asking ColdFusion to a little too much crunching.

I thought about this problem for a bit and decided to use SELECT DISTINCT which brought back distinct items if I queried one column. But I was querying two columns so the database would return distinct combinations. I need to get each distinct ID and the maximum dollars so I used DISTINCT along with the MAX function. Here&apos;s my SQL that brought back each individual id along with the maximum dollars for each.

&lt;blockquote&gt;
SELECT DISTINCT id, MAX(sales) AS sales_dollars
FROM monthly_sales
GROUP BY id
&lt;/blockquote&gt;

The moral of the story is that you should get the database to do all the data work and have ColdFusion present the data.
				
				</description>
						
				
				<category>SQL</category>				
				
				<category>Basics</category>				
				
				<pubDate>Fri, 17 Aug 2007 23:51:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/17/Let-SQL-Do-The-Data-Work</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFDUMP even better in CF8</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/15/CFDUMP-even-better-in-CF8</link>
				<description>
				
				The CFDUMP tag allows you to get the elements, variables, and values of most kinds of ColdFusion scopes or objects. It&apos;s been a great debugging tool since it arrived in with ColdFusion MX (ColdFusion 6).  You could display the contents of queries, scopes like CGI, and supporting systems like the operation system and the web server. It is also great for displaying results from CFHTTP, CFERROR and other CF tags that return data.

With the release of ColdFusion 8, CFDUMP gains a number of new features.
&lt;blockquote&gt;
&lt;ul&gt;
    &lt;li&gt;Format - Output can be HTML as before in a collapsible HTML table or you can output it as plain text much like you see in ColdFusions debugging output.
    &lt;li&gt;Hide | Show - You can now display partial lists by hiding or showing a limited set of elements
    &lt;li&gt;Keys- Number of keys in a structure to show.
    &lt;li&gt;Metainfo - Displays query information including whether it was cached, the execution time, and the SQL script used.
    &lt;li&gt;Output - Allows you to display to a console (JRun console) or write to a log file or display to the browser as in the past.
    &lt;li&gt;showUDFs - Lists available user defined functions.
    &lt;li&gt;Top - Number of rows to show so you can show only a few rows of a query or array.
&lt;/ul&gt;
&lt;/blockquote&gt;
To use CFDUMP just include the following code in your page and adjust parameters. The only required parameter is var which can be a query, a scope, or any other object. Wrap in pound signs.

&amp;lt;cfdump &lt;br&gt;
    var = &quot;#variable#&quot;&lt;br&gt;
    expand = &quot;yes|no&quot; &lt;br&gt;
    format = &quot;text|html&quot;&lt;br&gt;
    hide = &quot;columns|keys&quot;&lt;br&gt;
    keys = &quot;number of keys to display for structures&quot;&lt;br&gt;
    label = &quot;text&quot;&lt;br&gt;
    metainfo = yes|no&quot;&lt;br&gt;
    output = &quot;browser|console|file&quot;&lt;br&gt;
    show = &quot;columns|keys&quot;&lt;br&gt;
    showUDFs = &quot;yes|no&quot;&lt;br&gt;
    top = &quot;number of rows|number of levels&quot;&amp;gt;
				
				</description>
						
				
				<category>ColdFusion 8</category>				
				
				<category>Basics</category>				
				
				<category>CFDUMP</category>				
				
				<pubDate>Wed, 15 Aug 2007 01:21:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/15/CFDUMP-even-better-in-CF8</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Custom Tags</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/Custom-Tags</link>
				<description>
				
				&lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt; &lt;a href=&quot;http://www.adobe.com/software/coldfusion/&quot; target=&quot;_blank&quot;&gt;ColdFusion&lt;/a&gt; 
        custom tags are ColdFusion templates just like any other CFML file but 
        are designed to be reused. Coders can save much time by packaging code 
        that is used frequently or can easily add functionality by using free 
        or inexpensive custom tags. There are two general categories of custom 
        tags, one uses only ColdFusion&apos;s CFML code. The other packages C++, Java, 
        or other languages into a custom tag that is used by ColdFusion. We&apos;ll 
        cover only CFML based tags in this article. For our discussion we will 
        be using &lt;strong&gt;&lt;a href=&quot;http://free.cftagstore.com/index.cfm/page/viewtag/tagId/8&quot; target=&quot;_blank&quot;&gt;CF_States&lt;/a&gt; 
        &lt;/strong&gt;from&lt;strong&gt; &lt;a href=&quot;http://www.aspiringgeek.com&quot; target=&quot;_blank&quot;&gt;AspiringGeek.com&lt;/a&gt;.&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;

&lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Simple Custom Tags&lt;/strong&gt;&lt;br&gt;
        A simple custom tag is one that is used in a page and adds code to that 
        template without using any inputs. To add a custom tag&apos;s functionality 
        to your page, you will place the custom tag in the custom tag directory 
        or in the same folder as the page that you call the custom tag in from. 
        For version control (managing updates to the custom tag) it is best to 
        place the custom tag in the custom tags folder which is assigned through 
        the ColdFusion Administration panel. If you are in a &lt;a href=&quot;hosting.cfm&quot;&gt;&lt;strong&gt; 
        shared hosting&lt;/strong&gt;&lt;/a&gt; environment, you may have to place in each 
        folder where the tag is used. &lt;/font&gt;&lt;/p&gt;

      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;After the tag is located on 
        the server, you can use it by simply adding a single tag to your template. 
        In the case of &lt;strong&gt;&lt;a href=&quot;http://free.cftagstore.com/index.cfm/page/viewtag/tagId/8&quot; target=&quot;_blank&quot;&gt;CF_States&lt;/a&gt; 
        , &lt;/strong&gt;the file name is states.cfm so we add cf_ to the start of the 
        file name and drop the .cfm extension place the result within mark up 
        brackets: &lt;strong&gt;&amp;lt;cf_states&amp;gt;&lt;/strong&gt;. In your sample you should 
        see a drop down select box listing all US states with California selected. 
        &lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Custom Tags with Attributes&lt;br&gt;
        &lt;/strong&gt;The previous example saves over 70 lines of code but it may not 
        produce a select box to you or your clients taste. Custom tags can have 
        attributes. Attributes are passed to the custom tag and are used within 
        the custom tag to vary the tag&apos;s output. In the &lt;strong&gt;&lt;a href=&quot;http://free.cftagstore.com/index.cfm/page/viewtag/tagId/8&quot; target=&quot;_blank&quot;&gt;CF_States&lt;/a&gt;&lt;/strong&gt; 
        example, we can change what state is pre-selected and also abbreviate 
        the state name to two letters. The attributes for &lt;strong&gt;&lt;a href=&quot;http://free.cftagstore.com/index.cfm/page/viewtag/tagId/8&quot; target=&quot;_blank&quot;&gt;CF_States&lt;/a&gt;&lt;/strong&gt; 
        are NONVERBOSE and SELECTED. By including these attributes, you can control 
        the look of the select box. To show only two letters with Virginia selected 
        use: &lt;/font&gt;&lt;/p&gt;

      &lt;blockquote&gt; 
        &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;&amp;lt;cf_states nonverbose=&amp;quot;yes&amp;quot; 
          selected=&amp;quot;va&amp;quot;&amp;gt;&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
      &lt;/blockquote&gt;
      &lt;p&gt;&lt;strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Creating Custom Tags&lt;br&gt;
        &lt;/font&gt;&lt;/strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Creating a simple 
        custom tag requires saving a portion of code as a ColdFusion template. 
        Creating a custom tag that use attributes, only requires that you reference 
        the attributes using the &lt;a href=&quot;scopes.cfm&quot;&gt;attributes scope&lt;/a&gt;. Within 
        CF_States, attributes.nonverbose and attributes.selected are used to reference 
        the nonverbose and selected attributes that are passed into the custom 
        tag. &lt;/font&gt;&lt;/p&gt;

      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Sources for Custom 
        Tags&lt;br&gt;
        &lt;/strong&gt;A great way to learn about ColdFusion code and custom tags is 
        to download sample tags and review the way they are coded. Free and inexpensive 
        custom tags and applications can be found at the following sites:&lt;/font&gt;&lt;/p&gt;
      &lt;ul&gt;
        &lt;li&gt; &lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;a href=&quot;http://www.adobe.com/cfusion/exchange/index.cfm&quot; target=&quot;_blank&quot;&gt;Adobe 
          Exchange&lt;/a&gt;&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt; &lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;a href=&quot;http://www.hotscripts.com&quot; target=&quot;_blank&quot;&gt;Hotscripts&lt;/a&gt;&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt; &lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;a href=&quot;http://www.cftagstore.com&quot; target=&quot;_blank&quot;&gt;CFTagstore&lt;/a&gt;&lt;/font&gt;&lt;/li&gt;

        &lt;li&gt; &lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;a href=&quot;http://www.cfxtras.com&quot; target=&quot;_blank&quot;&gt;CFXtras&lt;/a&gt;&lt;/font&gt;&lt;br&gt;
        &lt;/li&gt;
      &lt;/ul&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Various Ways to Include 
        CF Code&lt;/strong&gt;&lt;br&gt;
        There are several ways to include ColdFusion code. Two ways were addressed 
        above, they are summarized below with two other methods.&lt;/font&gt;&lt;/p&gt;
      &lt;table width=&quot;95%&quot; border=&quot;1&quot; cellspacing=&quot;2&quot; cellpadding=&quot;2&quot; align=&quot;center&quot;&gt;
        &lt;tr&gt; 
          &lt;td colspan=&quot;3&quot; bgcolor=&quot;#330099&quot;&gt;&lt;div align=&quot;center&quot;&gt;&lt;font color=&quot;#FFFFFF&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Ways 
              of Including CF Code&lt;/strong&gt;&lt;/font&gt;&lt;/div&gt;&lt;/td&gt;

        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td width=&quot;17%&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Type &lt;/font&gt;&lt;/td&gt;
          &lt;td width=&quot;34%&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Syntax&lt;/font&gt;&lt;/td&gt;
          &lt;td width=&quot;49%&quot;&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Consideration&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Custom &lt;br&gt;

            Tag&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;CF_filename&amp;gt;&lt;/font&gt;&lt;/td&gt;
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;This is the simplest syntax 
            for calling in a custom tag. The syntax is adding CF_ to the start 
            of the file name and dropping the .cfm.&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Custom &lt;br&gt;
            Tag&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;

          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;CF_filename&lt;br&gt;
            ATTRIBUTE-name =&amp;quot;attribute value&amp;quot;&amp;gt;&lt;/font&gt;&lt;/td&gt;
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Same as simple custom 
            tags but includes attribute/value pairs.&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;a href=&quot;http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-p63.htm#wp1100248&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;CFINCLUDE&lt;/strong&gt;&lt;/a&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;CFINCLUDE&lt;br&gt;

            TEMPLATE=&amp;quot;templatename&amp;quot;&lt;br&gt;
            &amp;gt; &lt;/font&gt;&lt;/td&gt;
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;CFINCLUDE places the content 
            of one template into another as a simple way to include code. &lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt; 
          &lt;td height=&quot;27&quot;&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;a href=&quot;http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-pb4.htm#wp1810047&quot; target=&quot;_blank&quot;&gt;&lt;strong&gt;CFMODULE&lt;/strong&gt;&lt;/a&gt;&lt;/font&gt;&lt;/td&gt;
          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;CFMODULE &lt;br&gt;

            NAME=&amp;quot;path&amp;quot;&lt;br&gt;
            TEMPLATE=&amp;quot;path&amp;quot;&lt;br&gt;
            ATTRIBUTE =&amp;quot;attribute value&amp;quot;&lt;br&gt;
            ATTRIBUTESCOLLECTION=&amp;quot;&amp;quot; &amp;gt; &lt;/font&gt;&lt;/td&gt;

          &lt;td&gt;&lt;font size=&quot;2&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;CFMODULE is an alternative 
            way to call a custom tag. It is required when calling a custom tag 
            from within a sub-directory of the custom tag directory. Either Name 
            or Template is used and attributes can be called in indivdually or 
            as a collection from a structure.&lt;/font&gt;&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/table&gt;
      
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;br&gt;
        Custom tags provide a great way to use your code or code from others. 
        Custom tags simplifies coding while improving quality by using tested 
        code. The use of attributes adds flexibility while maintaining reusibility. 
        ColdFusions server&apos;s central location for custom tags promotes version 
        control. &lt;/font&gt;&lt;/p&gt;
				
				</description>
						
				
				<category>Basics</category>				
				
				<pubDate>Wed, 08 Aug 2007 22:46:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/Custom-Tags</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFPARAM and How to Uncheck a Checkbox</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/CFPARAM-and-How-to-Uncheck-a-Checkbox</link>
				<description>
				
				&lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt; For anyone new to application 
        development, you may be perplexed when you create your form for editing 
        some data that should allow a user to uncheck a checkbox and update a 
        record to a status of not checked. You will sooner or later discover an 
        oddity about HTML forms. HTML forms won&apos;t allow you to uncheck like you 
        think you should be able to. If you uncheck the checkbox, the value becomes 
        NULL and the form doesn&apos;t bother to pass the field. You will find that 
        &lt;a href=&quot;http://www.adobe.com/software/coldfusion/&quot; target=&quot;_blank&quot;&gt;ColdFusion&lt;/a&gt; 
        does have a simple solution and much more with the CFPARAM tag.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;CFPARAM&lt;/strong&gt; primary 
        function is to provide a default value if one isn&apos;t provided from a requesting 
        form, a URL, or from some other expected variable like a session ID. It 
        also provides a nice way to check the passed values datatype which comes 
        in handy when you need to assure that a numeric value, date or other datatype 
        is passed.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;Setting Defaults without 
        CFPARAM&lt;br&gt;
        &lt;/strong&gt;You can set a default without using CFPARAM by using something 
        like:&lt;/font&gt;&lt;/p&gt;
      &lt;blockquote&gt; 
        &lt;blockquote&gt; 
          &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;CFIF NOT IsDefined(&amp;quot;MyVar&amp;quot;)&lt;br&gt;
            &amp;lt;cfset myvar=&amp;quot;&amp;quot;&amp;gt;&lt;br&gt;
            &amp;lt;/cfif&amp;gt; &lt;/font&gt;&lt;/p&gt;
        &lt;/blockquote&gt;
      &lt;/blockquote&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;This sets a MyVar to have a 
        NULL value. It now exists and has a NULL value.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Checking Datatypes 
        without CFPARAM&lt;br&gt;

        &lt;/font&gt;&lt;/strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Checking the 
        data before passing it into a template is often prefered. This can be 
        accomplished with client side validation using JavaScript that you code 
        or that ColdFusion creates with CFFORM and CFINPUT. Alternatively you 
        can use ColdFusion function like isNumeric() in the processing template 
        and handle datatype problems with your own conditional code&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Setting Defaults with 
        CFPARAM&lt;/font&gt;&lt;/strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;br&gt;
        To set a default variable with CFPARAM use the following format:&lt;/font&gt;&lt;/p&gt;
      &lt;blockquote&gt; 
        &lt;blockquote&gt; 
          &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;CFPARAM NAME=&amp;quot;MyVar&amp;quot; 
            DEFAULT=&amp;quot;&amp;quot;&amp;gt;&lt;/font&gt;&lt;/p&gt;

        &lt;/blockquote&gt;
      &lt;/blockquote&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;If MyVar is not passed to the 
        page it will be created with this tag. In this case it will exist with 
        a NULL value.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Checking Datatypes 
        with CFPARAM&lt;/font&gt;&lt;/strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;br&gt;
        A secondary function of CFPARAM is datatype checking. This makes checking 
        that the proper data type is passed to the template but it will produce 
        an error if the wrong type is passed. The may be OK for some in-house 
        applications or your own adminstration areas but for a public site, client 
        side checking with CFFORM, CFINPUT and Javascript is a better pracice.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Datatypes that can be checked 
        with CFPARAM&lt;/font&gt;&lt;/p&gt;
      &lt;ul&gt;

        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;any&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt; array&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;binary&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;boolean&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;date&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;numeric&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;query&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;string&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;struct&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;UUID&lt;/font&gt;&lt;/li&gt;
        &lt;li&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;variablename&lt;/font&gt;&lt;/li&gt;
      &lt;/ul&gt;

      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Summary&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;CFPARAM is a great tool in 
        setting defaults and dealing with form fields that are passed with no 
        value. It also helps in maintaining your data integrity by checking datatypes&lt;/font&gt;&lt;/p&gt;
				
				</description>
						
				
				<category>Basics</category>				
				
				<pubDate>Wed, 08 Aug 2007 22:38:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/CFPARAM-and-How-to-Uncheck-a-Checkbox</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>CFTIME: How to Make Content Appear and Disappear</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/CFTIME-How-to-Make-Content-Appear-and-Disappear</link>
				<description>
				
				&lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt; Content on the web often has 
        a shelf life. You may have information that you want up after a certain 
        point in time or you may want it to be gone after a certain time.You may 
        want to have it appear and disappear without having to be editing files 
        or changing out input in some back end system. You will find that you 
        can build a simple system for publishing and removing info with &lt;a href=&quot;http://www.adobe.com/software/coldfusion/&quot; target=&quot;_blank&quot;&gt;ColdFusion&lt;/a&gt;&apos;s 
        &lt;strong&gt;CFIF&lt;/strong&gt; tag and &lt;strong&gt;CreateDateTime()&lt;/strong&gt; and &lt;strong&gt;Now()&lt;/strong&gt; 
        functions.&lt;/font&gt;&lt;/p&gt;

 &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;CFIF&lt;/strong&gt; is one 
        of the most basic and commonly used tags in ColdFusion. We will use it 
        to hide or display content based on comparing a set date to the time that 
        the page is parsed for the visitor. &lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;The &lt;strong&gt;CreateDateTime()&lt;/strong&gt; 
        function takes date and time parameters and creates a ColdFusion date/time 
        object. The format is CreateDateTime(year,month, day, hour, minute, second). 
        An example would be CreateDateTime (2004, 7, 9,19,59, 0) for July 9, 2004 
        at 7:59pm. &lt;/font&gt;&lt;/p&gt;

      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;The &lt;strong&gt;Now()&lt;/strong&gt; 
        function takes no parameters and produces a ColdFusion date/time object 
        for the current date and time including seconds. &lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Example Code&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;The components are simple so 
        let&apos;s put it all together. Our first example is content that displays 
        until a future point in time. In this case if the date/time is less than 
        the target date your content will display. This would be usefull if yo 
        had a contest running and wanted to remove the content from your site 
        when the contest was over.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt; &lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;cfif #now()# lte #CreateDateTime 
        (2004, 7, 9,19,59, 0)#&amp;gt;&lt;br&gt;
        This content is displayed until July 7, 2004 at 7:59pm.&lt;br&gt;

        &amp;lt;/cfif&amp;gt; &lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt; Our next example is content 
        that displays after a future point in time. In this case if the date/time 
        is greater than the target date your content will display. This would 
        be handy if you had an announcement coming up so you could announce it 
        on your web site without having to sit at your computer and trigger the 
        new content.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;cfif #now()# gte #CreateDateTime 
        (2004,7,5,10,30, 0)# &amp;gt;&lt;br&gt;
        This content is displayed after July 5, 2004 at 10:30am.&lt;br&gt;
        &amp;lt;/cfif&amp;gt; &lt;/font&gt;&lt;/p&gt;

      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Our last example is content 
        that displays after a future point in time and ends at a later date. In 
        this case if the date/time is greater than the target date and it was 
        smaller than a second target date, your content will display. This would 
        be handy if you had an announcement coming up so you could announce it 
        on your web site without having to sit at your computer and trigger the 
        new content and it would also remove the announcement at the appropriate 
        time.&lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&amp;lt;cfif #now()# lte #CreateDateTime 
        (2004, 7, 9,19,59, 0)# &lt;br&gt;
        AND #now()# gte #CreateDateTime (2004,5, 2,10,30, 0)# &amp;gt;&lt;br&gt;
        This content is displayed after May 5, 2004 at 10:30am and disappears 
        after July 7, 2004 at 7:59pm .&lt;br&gt;
        &amp;lt;/cfif&amp;gt; &lt;/font&gt;&lt;/p&gt;
      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;Summary&lt;/font&gt;&lt;/p&gt;

      &lt;p&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;ColdFusion makes dealing with 
        times and dates easy with built in functions like CreateDateTime() and 
        Now(). Developers won&apos;t need to be on call for special announcements or 
        the end of a campaign. Test out some examples of your own making and then 
        don&apos;t let the clock and your computer dictate when you are making content 
        appear and disappear.&lt;/font&gt;&lt;/p&gt;
				
				</description>
						
				
				<category>CFIF</category>				
				
				<category>Basics</category>				
				
				<category>CFOUTPUT</category>				
				
				<pubDate>Wed, 08 Aug 2007 22:19:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/CFTIME-How-to-Make-Content-Appear-and-Disappear</guid>
				
			</item>
			
		 	
			
			
			<item>
				<title>Grouping Results with CFQUERY and CFOUTPUT</title>
				<link>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/Grouping-Results</link>
				<description>
				
				&lt;strong&gt;&lt;font face=&quot;Arial, Helvetica, sans-serif&quot;&gt;

Grouping Results                                                           
&lt;/font&gt;&lt;/strong&gt;&lt;/h2&gt;
&lt;p&gt;&lt;a href=&quot;http://www.adobe.com/software/coldfusion/&quot; target=&quot;_blank&quot;&gt;ColdFusion&lt;/a&gt; 
  makes it easy to select data out of a database and display it on a page. As 
  soon as you feel good about your success in crossing the divide from static 
  to dynamic, someone will say &amp;quot;That&apos;s nice, can you group the list by author?&amp;quot;. 
  Whether you are asked to group things by author, make, brand, year or whatever, 
  ColdFusion has you covered with its grouping capabilities.&lt;/p&gt;

&lt;p&gt;To present things in groups, we first rely on SQL to group the data before 
  it is presented to ColdFusion. This is done with a GROUP BY or ORDER BY clause. 
&lt;/p&gt;
&lt;table width=&quot;60%&quot; border=&quot;1&quot; align=&quot;center&quot; cellpadding=&quot;5&quot; cellspacing=&quot;5&quot;&gt;
  &lt;tr bgcolor=&quot;#003399&quot;&gt; 
    &lt;td width=&quot;24%&quot;&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;CLAUSE&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
    &lt;td width=&quot;76%&quot;&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;QUERY&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt; 
    &lt;td&gt;GROUP BY&lt;/td&gt;

    &lt;td&gt;SELECT Author, Title, Publisher&lt;br&gt;
      GROUP BY Publisher, Author, Title&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt; 
    &lt;td&gt;ORDER BY&lt;/td&gt;
    &lt;td&gt;SELECT Author, Title, Publisher&lt;br&gt;
      ORDER BY Publisher, Author, Title&lt;/td&gt;

  &lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;ColdFusion will then display grouped data by using nested CFOUTPUT tags. In 
  both cases the outter most CFOUTPUT will indicate the QUERY and each CFOUTPUT 
  that is used to group will use a GROUP parameter except the innermost CFOUTPUT. The code below will group authors by publisher and then group books by author. &lt;/p&gt;
&lt;table width=&quot;80%&quot; border=&quot;1&quot; align=&quot;center&quot; cellpadding=&quot;5&quot; cellspacing=&quot;5&quot;&gt;
  &lt;tr valign=&quot;top&quot; class=&quot;tablerow1&quot;&gt; 
    &lt;td width=&quot;51%&quot; bgcolor=&quot;#003399&quot;&gt;&lt;font color=&quot;#FFFFFF&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;&lt;strong&gt;CODE&lt;/strong&gt;&lt;/font&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign=&quot;top&quot;&gt; 
    &lt;td&gt;&amp;lt;CFOUTPUT Query=&amp;quot;myquery&amp;quot; GROUP=&amp;quot;Publisher&amp;quot;&amp;gt;&lt;br&gt; 
      &amp;nbsp;&amp;nbsp;&amp;lt;p&amp;gt;#Publisher#&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;lt;CFOUTPUT GROUP=&amp;quot;Author&amp;quot;&amp;gt;&lt;br&gt; 
      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;br&amp;gt;#Author#&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;CFOUTPUT&amp;gt;&lt;br&gt; 
      &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;br&amp;gt;~&amp;nbsp;#Title#&lt;br&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/CFOUTPUT&amp;gt;&lt;br&gt; 
      &amp;nbsp;&amp;nbsp;&amp;lt;/CFOUTPUT&amp;gt;&lt;br&gt; &amp;lt;/p&amp;gt; &lt;br&gt; &amp;lt;/CFOUTPUT&amp;gt;&lt;/td&gt;

  &lt;/tr&gt;
  &lt;tr valign=&quot;top&quot;&gt; 
    &lt;td bgcolor=&quot;#003399&quot;&gt;&lt;strong&gt;&lt;font color=&quot;#FFFFFF&quot; face=&quot;Arial, Helvetica, sans-serif&quot;&gt;OUTPUT&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr valign=&quot;top&quot;&gt; 
    &lt;td&gt;&lt;p&gt;Macromedia Press&lt;br&gt;
        Forta&lt;br&gt;
        ~CF WACK Third Edition&lt;br&gt;

        ~Reality ColdFusion MX&lt;/p&gt;
      &lt;p&gt;Newbie Press&lt;br&gt;
        Barr&lt;br&gt;
        ~Instant Messenger for Dummies&lt;br&gt;
        Gates&lt;br&gt;
        ~Dominating the World with Software Patches&lt;/p&gt;&lt;/td&gt;

  &lt;/tr&gt;
&lt;/table&gt;
&lt;p&gt;If you use a GROUP BY clause with a WHERE clause the GROUP BY clause most come 
  after the WHERE clause. Think of this as the SQL engine finding all of the results 
  that match the WHERE statement and then it groups the results. &lt;/p&gt;
&lt;p&gt;If you use a GROUP BY clause with an ORDER BY, use the GROUP BY before the 
  ORDER BY clause. The SQL engine will create the groups and then order the groups, 
  this reduces the amount of ordering that is done by SQL since the number of 
  groups is the same or less than the number of members of the groups.&lt;/p&gt;

&lt;/p&gt;
				
				</description>
						
				
				<category>SQL</category>				
				
				<category>Basics</category>				
				
				<category>CFOUTPUT</category>				
				
				<pubDate>Wed, 08 Aug 2007 22:01:00-0700</pubDate>
				<guid>http://www.cfnewbie.com/cfnewbie/client/index.cfm/2007/8/8/Grouping-Results</guid>
				
			</item>
			
		 	
			</channel></rss>