It's pretty common to use the application scope to cache components. If your component is a collection of methods or data access functions it's often faster to put them into the application scope than it is to create an instance with each request. Now you probably know that you should quality all of the variables in a function with the "var" key word. This insures that the variable exists inside the "scope" of the function call. This allows multiple function calls to be made to the same instance without one set of variables over writing the other.
One of the areas where this can be difficult to manage is when using a ColdFusion tag that creates its own scope. Take CFHTTP as an example.Read More
Here's a quick public service announcement for all the muse readers. Apparently Coldfusion Weekly (a popular podcast) is ending its run. To pick up the slack, community member and CF Guru Brian Meloche has started a new podcast called CF Conversations. His first release is a round table discussion with Rick Mason, Adam Haskell, Aaron West, and Jeff Coughlin. There is also an i Tunes link.
Recently on CF Talk Bobby Hartsfield presented an interesting problem. A vendor required a submission of data as an XML packet. Since the data all came from a form post Bobby wanted to simply loop through the form fields to build his XML file. Each of the form field names would become a node in his XML doc. Sounds simple right?
Actually there is a problem with this approach. XML is typically case sensitive. If the vendor uses all upper or all lower case that's not a problem because you could simply UCASE() or LCASE() the field names. But what if the XML node names need to be mixed-case? For example, what if a node name was AdminUserName? You could add a form element to the form called AdminUserName, but when it is posted Coldfusion turns it into all upper case - as in ADMINUSERNAME. It's too bad there is no way to access the original case of the form elements before ColdFusion intervened. As it turns out (and thanks to some nifty code from both Bobby and the very bright Barney Boisvert) there is a way....Read More
From a reference on an email list I stumbled onto Pete Freitag's cheat sheet for CFSCRIPT and I thought it was worth mentioning. I use Cfscript for any largish block of logic. With the advent of CFC's it has become even more useful. I think the inline commenting is more readable and the syntax translates to other languages with a few modifications. To Pete's tips I would add the following:Read More
Here is one of those finicky nuances that might surprise you about Coldfusion. Many languages have list functions or something similar to list functions. In many of these languages there is some version of split or splitf that allows you to specify any string as a delimiter regardless of length. This might lead you to believe that you can use a multi-character string as a delimiter in list functions in Coldfusion. Not only is this not the case but the way delimiters behave can cause you to believe it is working when in fact it is not. Let me explain.Read More
This is an old tip that I had forgotten. Before I mention please know(as you should already know from the title) that this is a Homesite tip. It also applies to the old "Coldfusion studio" if that's your cup of tea. I know I know - I should always use CF eclipse. I have it and I use it but my trusty Homesite is an old friend and I can't seem to completely say goodby. Plus at 43 it's hard to teach an old dog new tricks :)Read More
I have had a great many readers calling me and asking about the 2D barcode CFC mentioned in a recent post. You will be happy to know that it has been released. You can use this CFC to create 2D barcodes for printing and to read 2D barcodes containined in images. You can find the download link and read more about it on Ryan's blog. Keep in mind that the CFC is specific to CF8 and it uses a commercial (albeit inexpensive) Java library from Java4Less. Ryan and I would both be interested in any reviews or comments. If you end up using the tag we'd love to hear some follow-up on how it is being used.
One of the nice things about Coldfusion is the easy access to all that lovely Java stuff under the hood. Check out this network function listed at cflib.org. the basic syntax is: