the singularity of being and nothingness
ColdFusion

Quick Update to Gloss
Jan 27th
Based on feedback from several users (thanks to Charlie and Tyler!), I’ve updated the search interface to Gloss a bit. It’s still a work in progress, but this newest fix has resolved the issue of lack of keyboard navigation to search results from the search field. Here’s what has changed:
- You can now tab out of the search field to the first search result, and then tab to subsequent search results.
- You can strike Enter or Spacebar on a highlighted search result to load its respective page
I do have a question for users regarding the “post-load” behavior. Currently, if you select a search result to load a page, focus is taken away from the search result and given to the item in the navigation tree that correlates to the search result. Is this desirable behavior, or would you rather have focus be retained on the search result?
Perhaps I’ll install a new configuration option to give the choice…:)
Thanks to everyone who uses the tool, and please feel free to let me know of any ideas/improvements/bugs/whatever.
Share this:
Using Java LinkedHashMap for Sorted Structures
Dec 17th
Chalk this one up to “I never thought I’d need this, but glad it’s there!”
I’m currently working on a little project where I wanted to have an honest-to-goodness struct of structs, but to have the structure retain the order of the child structures as they are created. Of course, ColdFusion structures do not have any particular ordering, so forget that route.
Fortunately, you can create a Java LinkedHashMap to accomplish this, and there’s very little impact to the normal course of development in working with structures. In fact, I think the only real difference is case sensitivity.
Anyway, here’s where I found this nugget. Enjoy 🙂
Share this:
So Apparently I Just Started Using ColdFusion Yesterday…
Dec 3rd
I’ve been using ColdFusion for probably about 5 years now. While I certainly do not consider myself an expert at it by any stretch of the imagination, I feel like I have a pretty good grasp of what CF can do and what some of the more standard features of it are.
Well, I did until today. While browsing the docs, I came across the isValid() method. I could have sworn that I’d used this in the past, but as I looked at its capabilities for validation, it was clear that I apparently missed that day in class.
So isValid() is super-sweet because you can use it to…well…validate whether or not some ColdFusion variable is of whatever type that you’re expecting it to be. Like an email address. Or a phone number. Or a flippin’ component. Or an integer…no, not just a numeric value, but a real INTEGER. There’s a bunch more goodness, so be sure to check it out when you have a chance.
As for me, perhaps I need to spend some more time in the docs every day to figure out what other awesomeness I’ve been missing… 🙂
Share this:
Quick ColdFusion Goodness: Case-Sensitive Column Name List
Nov 5th
Ok, so I should be working on my novel right now, but I thought I’d share a quick ColdFusion tip (not original with me).
Imagine that you want to use the column names from your query to populate the header row in an Excel file. If you use myquery.columnlist, you’ll get the list of column names, but they’ll be in alphabetical order…and in all caps.
An easy way around this is–surprise, surprise–to tap into some of the Java beneath the query object. The following will get you the column list as an array, in the proper order, and respect the column name casing:
columns = myquery.getMeta().getcolumnlabels()
Ok, back to the book! 🙂
Share this:
CFSpreadsheet Custom Colors: Part Deux
Nov 3rd
In another post on using custom colors in CFSpreadsheet, I think I might have given the wrong impression that using custom colors REQUIRES that you abandon the CF-native spreadsheet functions. This is not true, of course–my intention was to show how adding custom colors IN ADDITION to the default palette will push you into the direction of POI and away from the CF methods.
However, if you really don’t care about using the default palette, you can have the best of both worlds: custom colors in conjunction with CF spreadsheet methods.
To not belabor the point, here’s the full code:
// create new workbook excel = spreadsheetnew("My Worksheet",false); // get reference to object containing color-related methods palette = excel.getworkbook().getcustompalette(); // light blue color lb = { r = javacast("int",240).bytevalue(), g = javacast("int",248).bytevalue(), b = javacast("int",255).bytevalue()}; // using index 48 to overwrite HSSFColor.LIGHT_BLUE palette.setcoloratindex(48,lb.r,lb.g,lb.b); // now that we have a custom color that has overwritten one of the POI constants (LIGHT_BLUE), // we can use "LIGHT_BLUE" with CF methods and it will understand what we're talking about // specify format object for "odd" rows format = {}; format.fgcolor="light_blue"; format.topborder="thin"; format.topbordercolor="grey_40_percent"; format.bottomborder="thin"; format.bottombordercolor="grey_40_percent"; format.leftborder="thin"; format.leftbordercolor="grey_40_percent"; format.rightborder="thin"; format.rightbordercolor="grey_40_percent"; // apply style formatting to row spreadsheetformatrows(excel,format,1);
As you can More >

CFSpreadsheet Custom Colors (and more)
Nov 1st
In my last post on CFSpreadsheet, I showed how you can easily create a custom row striping mechanism for your Excel data. The one downside of the approach I outlined, however, is that it relied on the limited number of functions that CF exposes from POI, the Java magic that makes CFSpreadsheet work.
While the OOTB method is all well and good, there are a number of limitations. One of the most severe is the limited number of colors that are available to use in spreadsheet styles. There are a couple of dozen “named” colors that can be used, but that’s it: tough luck if you want 3 light shades of grey 😉
However, like most things in ColdFusion, you don’t necessarily have to limit yourself to what is available through CF’s tags and methods. Rather, you can tap into the Java goodness underlying it, and modify, modify, modify to your heart’s content…including creating custom colors for CFSpreadsheet styles!
Creating a ColorFirst, let’s set up our workbook:
// create new workbook excel = spreadsheetnew("My Worksheet",false); // get underlying java methods goodness workbook= excel.getworkbook();
As before, we create a new spreadsheet with spreadsheetnew(). However, immediately following this, we invoke the getworkbook() method.
Now I don’t want More >

CFScript Alternative to CFHeader
Oct 30th
In another post, I wrote about how you can replicate the functionality of cfcontent’s “reset” attribute in CFScript. The other day, I came across a related issue of needing to be able to do the same thing (all code in CFScript, that is) for cfheader. Fortunately, by using the same approaching of tapping into the underlying Java methods, this is extremely easy.
Setting StatusTo set the status code for the page request, simply do the following:
pc = getpagecontext().getresponse(); pc.getresponse().setstatus(301);
No big deal there. Also, be aware that the setstatus() method can take an optional second string attribute, so if you wish to define a message to accompanying the status code, feel free 🙂
Setting HeadersHonestly, I use headers in CF mostly for downloading files, or returning certain content types. Just as with setting the status, it’s pretty freaking simply to do in CFScript:
pc = getpagecontext().getresponse(); pc.getresponse().setcontenttype('application/vnd-ms.excel'); pc.setHeader("Content-Disposition","inline;filename=MyFile.xls");Share this:

CFSpreadsheet Row Striping
Oct 20th
Today I was trying to get CF9’s new spreadsheet functionality to stripe the rows in the spreadsheet I was generating. From what I could find, there’s nothing inherent to the tag (cfspreadsheet) or any of the related functions to do this. I find this a bit curious, but stewing over should-have-been’s doesn’t get the job done. So I decided to roll my own solution.
The first thing to check out is the documentation for the spreadsheetformatrows() function. This takes 3 arguments:
- spreadsheetObj: This is the spreadsheet in which the rows exist
- format: An object of appropriate formatting rules to apply to the selected rows
- row: The rows to which the formatting specification is applied
The “row” argument is the most important. While you can’t specify something like “please stripe the rows with these two formatting objects” (wish list), you can either specify a range of rows (e.g., “3-12”) or a list of rows (e.g., “3,5,7,9”).
Ah, so if we can use a list of rows, the answer becomes apparent: all we have to do is roll through the query and create some lists of odd and even numbers!
To do this, I created a simple function:
function getnumlist(start,end) { // create structure to hold odd and even number lists numbers = structnew(); More >

Gotcha with Dynamic Component Method Invocation
Sep 30th
In an app I’m currently working on, I came across the need to be able to invoke methods from a particular component dynamically. On the surface, this is pretty simple:
myComp = createobject("component","com.utils").init(); dyn = myComp[methodvariable]; dyn();
While this technically *works*, there is one huge gotcha: there does not appear to be any persistence of the initialized component from init() to dyn(). That is, if the init method, say, sets up datasource names and other component properties, these will no longer be available in the invocation of dyn(). Not a big deal, I guess, if you don’t have need of the init function…but a killer if you do.
Fortunately, it’s easy enough to work around this. After you’ve instantiated the component, just use to call the dynamic method:
<cfinvoke component="#myComp#" method="#methodvariable#" /> (cfinvoke is still tag-bound...sorry! :))
Anyway, easy enough, but something a person can easily spend FAR too much time trying to work out. Uggh.
Share this:
Quick Note About Data Validation
Sep 1st
All developers, of course, give lip-service to the importance of data validation. But how many do a ridiculously thorough job of it? If you’re like me, the answer is probably that you do the obvious validations that come to mind during development, and then wait for the other, less probable ones when an issue actually comes up.
This happened to me today at work. I was working on a form that accepts–from the same field (not my design)–either an integer or a string. The way the validation was setup is that if the search term evaluated as numeric, the resulting query would look to match on primary keys in the db; for strings, well, a simple “like” search of the title field.
The validations worked fine for months and months, but today through an error. Here’s a simple recreation of the query:
<cfquery name="getstuff"> select field1, field2 from thetable where id = <cfqueryparm value="#arguments.searchterm#" cfsqltype="cf_sql_integer" /> </cfquery>
And the error I received was to the effect that the value of “#arguments.searchterm#” was not a valid integer based on the queryparam restraint.
So what happened? Basically, the validation for “numeric” failed. Well, it didn’t really fail…it just wasn’t looking for all the right stuff. After More >