Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at the New York ColdFusion User Group (Jun. 2008) with:

Kinky ColdFusion Calendar System Taking Shape

By Ben Nadel on
Tags: ColdFusion

Over the past week or two, I have been talking about calendar event scripting in ColdFusion. Previously, I showed you how to query for and populate repeating events as well as the theory behind updating or deleting repeating events. The code is getting a bit too complicated (and messy) to show you anything coherent at the moment. However, I want to assure that this ColdFusion calendar system is taking shape:


 
 
 

 
Kinky ColdFusion Calendar System - Event Scripting In ColdFusion Application  
 
 
 

To see what I have so far in action, view the most recent online ColdFusion calendar demo:

View Online Demo - 2007/08/06

Once I nail down the basic pages and clean up the code, then I can go into a bit more detail as to how it is working. What I am struggling with right now is the best way to maintain "state" while jumping from view to view. Meaning, when I jump from the year to the month view, I don't want to just end up in January by default (first month of the given year) - I would rather jump to August (the current month). However, if I went from November month view to Year view and then back to Month view, I might want to end up in November again. That's the kind of stuff I want to get down.

I am trying to keep the system as simple as possible. It doesn't have an Application.cfc/cfm file. It also has practically no configuration (all running through an index.cfm file). I am doing this because one day someone might want to integrate this into their application and I want the transition to be as easy as possible. Therefore, as much as possible, I am trying not to treat it as a stand-alone application, but rather as something that might be a sub-system of an existing application.




Reader Comments

I assume this demonstrates CF8 integration with MS Exchange.

If it gets too good people are going to start treating it as a finished product and start asking for features!

One of the key features of the Outlook client calendar is the ability to double-click on a day and enter an event and I notice that each day's box appears to have an object that represents the day and has a tooltip to display the full date. are you going to have an onclick event for the box or the day/number thingy?

@michael:

At the risk of getting inside Ben's decision-making process, I'd suggest just using a simple hyperlink vs. an onclick event. After all, why introduce JS if you don't need it?

Christian

@Christian: I would actually recommend building it out in a traditional fashion using little to no JS and then use Hijax/Progressive Enhancement to override some of the functionality with nice effects such as modal divs and Ajax. That way, you have a modern looking interface that fails over nicely in the event that JS isn't available.

And Ben, jQuery is very well suited for this. ;)

Yeah, I am gonna post up the code when it is done. I have posted some of the code already that has to do with the selecting of events. The rest of it right now is just not polished enough to post - I got a reputation to uphold ;)

@Josen,

Yeah, it is all CFMX 7 compatible. Really, the only high-level thing that it is doing is a query of queries. Other than that, there's really not a whole of magic happening here.

@Michael,

I don't have an Exchange server to even test on :D Maybe that can be phase II

@Christian / Rey,

Good suggestions. I will get it working in straight up HTML / CSS and then release it. Then, I can go back and make it snazzy. Hopefully not much longer.

@Rey,

I will give the link a look, but from my understanding, Hijax is basically just a fancy way of describing the whole $( fnOnDocumentLoad ) that jQuery provides, where you create a page that works normally, and then after it loads, you update all/some of the calls with Javascript.

Interesting stuff Ben, I actualy came to the site this evening specificaly looking for calendar type stuff :-D This is very exciting stuff mate, Cant wait to see the code behind it, this will bolt on perfectly to my current project.

Rob

@Rob,

That sounds good. I hope that this will be easy to bolt onto other applications - that is my primary goal here. Hopefully the wait shouldn't be too long.

Thanks Ben,

Its all stuff I've been looking to build in for ages but been too lazy to sit down and figure it all out. I've got all the event creation stuff working on mine, its just a case of displaying it in a calendar type view, and also the edit feature.

Now, tell me Ben, how does your repeat function work? do you create multiple intances of the record in the database? or just have a single record with a repeat pattern field? I'm hoping its the latter :-D

Thanks mate, look forward to some code.

Rob

**Oops, that was supposed to be "round-one" not two... that file has changed a bit, and actually extracted out into UDF style usage. It will all be changed / tweaked in the final release.

Looking very cool!

For keeping state, might want to just keep a "current date" URL/form variable. By default current date is today, so from month to year view and back you'll still be viewing August 2007. The question then is what is the intent when someone goes back a year or forward a month? Decide that intent and then implement it by just changing the "current date" and you'll have a really simple way of keeping state from day to view all the way to decade to view and back should you choose to implement them as you'll just display the day, work week, week, month, quarter, year or decade in which the currentdate resides - perhaps even with optional highlighting of the currentdate in all views using a style that is similar but different to the style used for the other days.

Ben,

Thats great news, I like the concept very much, I'll give this a thorough going over and see how it works for me this evening.

Thanks, your site is a great source of inspiration as always.

Rob

Hey Ben,

Another quick one buddy, I notice in your code snippets a load of try/catches around your params and sets, i've not ever really made the effort to wrap them myself, is there any specific reason for doing so? are they liable to fail on a regular basis?

Thanks mate, this is excelent stuff

*potters back of to continue playing with the code.

Rob

@Peter,

We are on the same page. I have a REQUEST.DefaultDate = Now() in my index.cfm. Then, on the individual action pages, I have a REQUEST.Attributes.date via CFParam which defaults to the REQUEST.DefaultDate if nothing else is sent via URL/FORM. It's getting there.

@Rob,

Glad to be of help and inspiration. As for the CFTry / CFCatch blocks, I only do that with ones that use a numeric param type. If someone where to use the system as-is, it should never fail. However, due to people trying to mess with URL or FORM variables, they could enter non-numeric data that would cause the CFParam typing to fail and throw an exception.

Now, I am apparently one of only a handful of people that actually uses CFParam in this manner. I LOVE using it this way, but I think there is a whole community of people who grew up with the Old School method of IsDefined() and end up using some craziness like:

<cfif IsDefined( "url.id" ) AND Val( url.id )>

Of course I say "craziness" in jest, not to offend people :) But I say, shouldn't the paraming take care of the data type as well? Why distribute the paraming and the type validation to two different places? Just my philosophy, but certainly not a best practice within the community. If you use my code, however, you will see that (try/catch around param) all over the place.

If you don't like it, its just one of the many trade-offs you have to take when using my code ;)

Thanks Ben!

I hadnt ever thought of tacking that issue using the param tag, but you're right, it does have that certain somthing, I like it. :-D

I've been modding this code a little over to my app to see how it works, I'll let you know how it goes :-D

Thanks mate,

Rob

Are you still working on this project, I am looking for a calendar plugin as I develop a new site structure.

When will you be ready to release the code?

Please lt me know if and when... thx.