Thoughts, ideas, tips, musings, and pontifications (not necessarily in that order) by Ben Forta ...
NOTE: This is my personal blog, and the opinions and statements voiced here are my own.
November 30, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
We've all had to embed debugging code into our pages only to have to take it all out, and then reinsert it again. The new ColdFusion IsDebugMode() function lets you programmatically determine if debugging is enabled, allowing you to leave debugging code in your pages knowing that it'll only be executed when debugging is enabled. (Of course, you should use this technique only during development, when you deploy the finished application you'd not want the unnecessary overhead, no matter how minimal). (Applies to: ColdFusion 4.5 (or later))
November 29, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
ColdFusion supports the internationalization of numbers, dates, currencies, and more using the LS functions. These functions generate output that varies based on the currently selected locale (set using the SetLocale() function). A list of supported locales is stored in the Server.ColdFusion.SupportedLocales variable. You can use the standard list functions to access the elements in this list. (Applies to: ColdFusion 4 (or later))
November 28, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
ColdFusion features a whole set of list manipulation functions (all beginning with the word "list" and all of which take a list as the first parameter). By default these functions manipulate comma-delimited lists, but you are not limited to this delimiter. In fact, every one of the list functions takes an optional last attribute containing the characters to be used as delimiters. And you can use multiple delimiters too (in which case any one of the characters will delimit elements, not all of them). (Applies to: ColdFusion All)
November 27, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
ColdFusion usually processes requests received from clients (such as Web browsers or WAP devices). But should you ever need ColdFusion to process a page without initiating it from a browser you can do so via CF's CGI interface - cfml.exe. Although intended to provide support for Web servers not natively supported by ColdFusion, this command-line program has another use in that it lets you initiate CF requests on demand. (Applies to: ColdFusion 2 (or later))
November 26, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
ColdFusion allows you to list all available variables within the APPLICATION, CLIENT, and SESSION scopes (the latter two relative to the currently logged in user). But the way you access these lists is not consistent across all three scopes. APPLICATION and SESSION are structures, so you can use standard structure functions to access them (as well as ). CLIENT variables are returned via the GetClientList() function (and that list can be accessed via the list functions and ). (Applies to: ColdFusion 4 (or later))
November 25, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Using SQL Server and tables with identity fields (auto increment primary keys)? Then you have probably needed to know that assigned id and have resorted to using follow-up queries (probably within a transaction block). Well, here's a much simpler (as well as safer) solution. Create a trigger on the table containing the code "SELECT @@IDENTITY AS id". Now every time you do an INSERT operation the INSERT query will return a single row containing a single column called id which will contain the newly assigned id. (Applies to: ColdFusion All)
November 24, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Developers are always looking for better ways to uniquely identify clients, and many try to use the remote IP address (which you can get from a CGI variable) for this purpose. Unfortunately, this does not work safely, IP addresses can never be assumed to be unique. Why? Different users of some online services often share the same IP address (or appear to do so). Similarly, users behind a proxy server or firewall might appear to you as the same IP address. As such, assuming IP addresses are unique is asking for trouble. (Applies to: ColdFusion All)
November 23, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
If you are using Windows 2000 Server on your network you probably have Active Directory installed. Active Directory is Win2K's Directory Service, and it'll typically store data on users, groups, and more. ColdFusion users can access the data in Active Directory without having to use any special API's. How? Active Directory has an LDAP interface, and so you can use the standard CFML tag to access the valuable data that it contains. (Applies to: ColdFusion 3 (or later))
November 22, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
When the expression is evaluated, what will the value of x be? Is it 50 (9 times 6 is 54, minus 4 is 50), or 18 (6 minus 4 is 2, times 9 is 18)? The value is actually 50, but as you can see, order of evaluation makes a big difference. For this reason you should always use parenthesize to explicitly define the order of evaluation. If you had wanted the 9*6 evaluated first you should code , and if you wanted the 6-2 evaluated first you should code . Parenthesize are always evaluated first, and this will prevent any ambiguity. (Applies to: ColdFusion All)
November 21, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Familiar with the REQUEST scope? This variable type (introduced in ColdFusion 4.01) is much like the VARIABLES scope in that it persists until a request has finished processing, but unlike VARIABLES it is visible to all pages that are part of a request (even Custom Tags). And you can use REQUEST just like any other scope too. (Applies to: ColdFusion 4.01 (or later))
November 20, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
ColdFusion has two division operators, / and \, and they are not the same. / is the standard division operator, \ divides a number and returns whole numbers only (integers, no fractions). So if you code x will be 3.33333333333, but if you code x will be 3. (Applies to: ColdFusion All)
November 19, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Custom tags are an important part of writing organized, structured, and reusable code. And basic Custom Tags are easy to write too. But when you find that you end up with long lists of tag attributes, to attributes with multiple values, then it might be time to take your Custom Tags to the next level. As of ColdFusion 4 you can create tag pairs and even tags sets (tags within tags), and you can (and should) use this functionality to create better Custom Tags. (Applies to: ColdFusion 4 (or later))
November 18, 2000
Ever wondered what to do with those VTM files that come with many of the Custom Tags out there? VTM files are used by ColdFusion Studio (and HomeSite) to display Tag Editors - the dialogs that are displayed when you right click on a tag and select Edit. How do you use VTM files? Simply drop them under the Extension\TagDefs directory under the ColdFusion Studio directory (usually C:\Program Files\Allaire\ColdFusion Studio 4.5 or something similar). Studio will detect the presence of the VTM file, and will use it to display appropriate Tag Editors. (Applies to: ColdFusion Studio 4 (or later))
November 17, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
The ColdFusion tag is used to group a set of SQL statements that need to be executed as a batch (allowing for rollbacks and explicit commits). But before you use this tag, stop and think - do you really need to do this? Could you process the entire set of statements within a stored procedure instead? If so, you'll see significant performance gains, and the code will be far more manageable. Of course, not all block can be replaced with stored procedures, but many can (and should be). (Applies to: ColdFusion All)
November 16, 2000
ColdFusion Studio caches VTM files (to improve performance). If you are creating and testing VTM's you'll need to flush the cache frequently so as to be able to test your changes. Instead of quitting and restarting Studio, you can use the following keystrokes to flush the cache: Ctrl + Alt + Shift + C. (Applies to: ColdFusion Studio 4 (or later))
November 15, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
If you are running ColdFusion on a Unix system (Linux, for example) then you must pay special attention to file names and their case-sensitivity. This is especially important when using special files like "Application.cfm" in which case the file must be spelled like that exactly, any other spelling (including "APPLICATION.CFM" and "application.cfm") will not be recognized as an application template and the file will not be processed. If you are writing code that need be portable keep this in mind. (Applies to: ColdFusion All)
November 14, 2000
Need immediate help with an HTML or CFML tag in Studio? Press F1 at any time to display help about the tag being edited. And newer versions of Studio also provide help for CFML functions this way too. (Applies to: ColdFusion Studio All)
November 13, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
The ColdFusion tag is used to interact with COM, CORBA, and EJB components. ColdFusion 4.5 added a new function, CreateObject(), which does the exact same thing. If you are using , and find yourself having to play with long lists of tags, take a look at this new function. (Applies to: ColdFusion 4.5 (or later))
November 12, 2000
The best way to learn HTML (and JavaScript, and all client side technologies) is by looking at what someone else has done. You can do this in any Web browser (just do a View Source), but ColdFusion Studio has a better way. Select "Open From Web" from the File menu, and then specify a URL - Studio will open it and display it for you in the Editor window. (Applies to: ColdFusion Studio All)
November 11, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
As of ColdFusion 4.5 FORM and URL are structures. As such, you can use all the Struct functions to access these variables, and can loop through them using . (Applies to: ColdFusion 4.5 (or later))
November 10, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Using to invoke paired tags or tags with child tags? Be careful to match your and tags carefully. And if you are using associated tags, make sure that each has a matching , or use the XML style syntax . (Applies to: ColdFusion 4 (or later))
November 9, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Have a long list of statements? Lots of loops and conditional processing? Take a look at the tag - it can greatly simplify some kind of scripting by allowing you to perform assignments, and conditional and loop processing using JavaScript style scripting. (Applies to: ColdFusion 4 (or later))
November 8, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
November 7, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Any time you use an expression or variable to build a URL parameter, use the URLEncodedFormat() function to ensure that that value is URL safe. You should do this even if you know the value is safe (for example, a simple number). The function will do no harm if the value does not need encoding (it'll spit it out as is), and you'll be protected if at some point the values change (they will). (Applies to: ColdFusion All)
November 6, 2000
Posted At : 12:00 AM
Related Categories:
Tips (CF) :
Using FORM forms or URL parameters and expecting specific data types (for example, a number)? Make sure you verify that the variable contains the correct type before you use it. You can do this using the CFML decision functions, or you could use the TYPE attribute. The latter is a more efficient solution, but it will throw an error if the data type is incorrect. So, if you use this method you'll also want to use and to elegantly handle error conditions. (Applies to: ColdFusion 4 (or later))
|