Building Pages with a Page Object

I was reading through PHP and MySQL Web Development at the local bookstore the other night when I noticed that their example code for explaining object oriented concepts was a Page class that basically built a page based on its properties. While the concept of directly building the return code string by string is a little foreign to ColdFusion, I was very interested in the idea of an extensible Page object that could help me manage my applications. Read more to see what I came up with.

 

Functions at CFLib.og

Three of my functions have made it onto CFLib.org. These probably aren't new to you if you've been following by blog, but since I don't think there is anyone watching me that close, check out GetSecureURL(), IsColor(), and IsSQLServerDate() at CFLib.org. While you're there check out some of the many awesome functions that other people have submitted too.

 

Object-Oriented Value Caching

An inheritance diagram. Like every other developer out there, I often find myself repeating the same kind of functionality over and over again, and like every other programmer (or at least a lot of you), I apply the DRY principal and abstract it away into a function for reuse. Recently though, I've noticed that its not just specific bits of code that I'm reusing, but patterns for performing actions, and I've wanted to start looking for better solutions.

 

Session Is Invalid Error

A bug I first got this error a few weeks back, and when it showed up again this week, I thought I should look into it and see how this could be happening, and I thought that I'd post the results here so that it might aid the next person trying to stitch together the details.

 

Looping over Date Ranges

Learned something new today: <cfloop> can be used to loop over date ranges. This is because dates are represented as integer values in ColdFusion, so incrementing a date by 1 day is really incrementing the underlying value by 1. This means that you can do this:

<cfset startDate = Now() />
<cfset endDate = DateAdd("ww", 1, startDate) />

<cfloop from="#startDate#" to="#endDate#" index="date">
    <cfoutput>#DateFormat(date, "mm-dd-yyyy")#</cfoutput><br />
</cfloop>

And get this:

    04-16-2009<br />

    04-17-2009<br />

    04-18-2009<br />

    04-19-2009<br />

    04-20-2009<br />

    04-21-2009<br />

    04-22-2009<br />

    04-23-2009<br />

Everyone else probably knew this, but I thought it was really nifty :)

 

Unexpected Structure Behavior with {}

A gearYesterday I ran into an interesting issue with one of my applications that lead to an even more interesting discovery about how CF8 executes the {} notation for creating structures.

 

More Entries

Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me on LinkedIn.