Photo from Chile

Faking ColdFusion Component Types (and a Quick Way to Confuse ColdFusion)

MightyMock (MM) is a mocking framework for ColdFusion that is bundled with MXUnit. It allows you to create mocks, which are fake instances of ColdFusion components, for use in unit tests. More information on what MightyMock is and how you can use it to create awesome unit tests can be found on the MXUnit Wiki.

One thing that MM allows you to do is to create typesafe mocks, which are mock objects that ColdFusion will recognize as being of a specific type. Why might you need to do that? Let's say you have a setter defined in a component into which you want to pass your mock object, and that setter expects an argument of a certain type. For example, consider this setter in a Customer.cfc component:

view plain print about
1<cffunction name="setValidator" access="public" returntype="void">
2    <cfargument name="validator" type="model.util.validator" />
3    <cfset variables.validator = arguments.validator />
4</cffunction>

If we want to create a mock object and pass it into that method, it needs to have a type of model.util.validator or ColdFusion will throw an error as soon as we call setValidator(). MM allows us to create such a mock using the optional second parameter of the mock() method that is available in MXUnit. The code to create a test for our Customer component using a typesafe Validator mock would look something like this:

[More]

CFUnited is Almost Here - Learn about Validations and ORM

As I'm sure many of you are aware, the final CFUnited will be starting in a little over a week. Although I did attend a couple of CFUN's in the past (when they were a one-day event), this will be my first CFUnited, so I'm pretty excited about it. It will be great to meet even more people than I usually do at other conferences, such as cf.Objective() and NCDevCon, and I wanted to give a final plug to my sessions, as I think they will be of interest to a lot of developers. As well, I've made some last minute changes to both sessions to cover some new material.

What Your Mother Never Told You About CF9 ORM

The ColdFusion team at Adobe have done an outstanding job with ColdFusion ORM, which now provides ColdFusion developers with access to Hibernate, an enterprise-ready, open source, industry-standard Java ORM. The documentation on how to use CF ORM in the ColdFusion docs is also quite good, providing most of what you need to know to make use of the features. The problem, however, is that Hibernate is a pretty complex tool, and in order to use CF ORM successfully you really need to understand certain things about Hibernate. This session is designed to teach you some of those things - it will cover material that is not included in the ColdFusion documentation, but that is essential to understand when working with the ORM.

Topics covered will include Hibernate Session Management, Understanding Object States, Working with Detached Objects, Concurrency and Using a Base Persistent Object. We'll also be looking at the new Transaction Management model in the recently released ColdFusion 9.0.1. If you plan on working with CF ORM and are not already familiar with these concepts I think you'll really benefit from this session. It is, however, an advanced session, so if you are totally unfamiliar with CF ORM you may find it a bit confusing.

The session is scheduled for 5:30pm (ouch!) on Wednesday, July 28th.

Automagic Validations for ColdFusion Objects

This session will provide an overview of, as well as a detailed how-to about a Validation framework for ColdFusion. The title is a slight misnomer, as, although the framework was originally written to work inside an object-oriented application, and remains an ideal solution for that, it has recently been enhanced to work with simple ColdFusion structures as well. This means that anyone who is looking for a better way of addressing their validation requirements, both on the client side and on the server side, can now benefit from the framework, even if they are not using objects.

The main benefit of the framework is that it will automatically generate all of your client-side and server-side validations for you, from a simple set of metadata. This frees you from the drudgery of writing similar validation code over and over again, and also eliminates the possibility of adding bugs into your application via your validation code. The framework, called ValidateThis, is being actively developed by myself and a number of other contributors, so not only is it extremely functional and flexible right now, but new features are being added continually. If you are interested in finding out more about it, including exactly how to implement it in a new or existing application (and it's dead easy), I encourage you to attend my session. It will be held at 3:15pm on Friday, July 30th, and is being repeated at 2:45pm on Saturday, July 31st.

I hope to see you at one, or both, of my sessions. If we haven't met before please come by and say hi.

ColdFusion 9.0.1 Now Available - With ORM Goodies

ColdFusion 9.0.1 is now available for download at http://www.adobe.com/go/getcf901, and, in addition to fixing a number of issues with ColdFusion 9.0, it's packed full of goodies as well. The details of all the new features can be found in the New Feature Notes, and the bug fixes and outstanding items can be found in the Release Notes. I think my favourite single new feature is the ability to do a for - in loop with an array, as looping through an array using script has always been a pain. I'm also very happy with some of the improvements to ORM. Here's a high-level summary of the new features, followed by some details on the ORM changes:

  • Language enhancements - including for-in loops for arrays.
  • New script functions implemented as CFCs - including dbinfo, imap, pop, ldap, and feed.
  • Caching enhancements - including the ability to get a handle on the ehCache session.
  • Support for IIS 7
  • ColdFusion Ajax enhancements - including updates cfmap, cfgrid, file uploading and JavaScript functions.
  • ORM enhancements - more details below.
  • Amazon S3 support - the ability to use Amazon S3 storage with most tags and functions that use a file or directory as input or output.
  • Various other enhancements covering areas such as Spreadsheets, AIR Integration, Flash Remoting, Blaze DS, Solr, Logging, Server Monitoring, and more.

ORM Enhancements

Here's a summary of the ORM enhancements in ColdFusion 9.0.1, followed by some details about each one:

  • Support for Multiple Datasources
  • Transaction Management Improvements
  • skipCFCWithError Flag in ormSettings
  • mappedSuperClass Attribute for Components
  • Use EntityNew to Populate a New Entity
  • Support for HQL in cfquery

[More]

Send Push Notifications to an iPhone from ColdFusion

Notifo is a relatively new service which allows you to send push notifications to mobile clients via a REST interface. Currently notifications can only be sent to the iPhone, but they plan to add support for Android and Blackberry in the future. Because it is based on a REST API, it's very easy to interact with from a ColdFusion application, and I wanted to give it a try, so I whipped up a quick API wrapper for it. It all seems to work extraordinarily well, and is quite cool.

CFNotifo is Born

I found out about Notifo from the GitHub blog, which describes a Notifo service hook that was just added. This service hook allows you to receive push notifications on your iPhone any time someone commits to your Git repo. Of course I had to try this right away, and was duly impressed. The next step was to write some CFML that interacts with the API, so, as I mentioned above, I decided to create a simple API wrapper to make it even easier for others to do the same. In a matter of minutes I was able to create a single cfc which implements all of the current API. This wasn't that challenging as there are only two API methods right now, subscribe_user and send_notification, but as Notifo adds more, I will follow suit.

How Does Notifo Work

Paul Stamatiou, co-founder of Notifo, wrote up a detailed post about Notifo on his blog, which is well worth reading. If you don't feel like following the link, here are the highlights:

  • Allows you to send push notifications to a mobile client from a server.
  • Currently iPhone is supported, via an app available in the app store. Android is up next, with other smartphones to be added in the future.
  • To subscribe to services you need a Notifo account, which can be set up via the Notifo site, or via the iPhone app.
  • To receive notifications you need to have the iPhone app installed.
  • Once you've subscribed to a service you can set various options for it via a web interface, including what type of notifications you want to receive (normal, silent and stealth), and you can unsubscribe, block and report spam on a service.
  • You can also set some global options for notifications, such as silent hours, during which notifications will be sent silently.

[More]

My Interview on WebDevRadio

I had the honour and pleasure of being interviewed by Michael Kimsal for his WebDevRadio podcast a few weeks ago. The episode was published last week and is now available for listening and/or downloading from the podcast website, as well as via iTunes.

For those of you that don't know Michael, you're missing out. I met him at NCDevCon and found him to be an extremely pleasant, funny and smart individual. I enjoyed my chats with him at the conference, and really enjoyed discussing all sorts of topics with him for the podcast, including, but not limited to, how I came to develop using ColdFusion, contributing to open source projects, test-driven development and unit testing in general, and object-relational mapping (ORM) in ColdFusion. I also really appreciated the opportunity to have my voice heard outside of the ColdFusion community.

ValidateThis Futures from cf.Objective()

I returned from cf.Objective() a few days ago and have been catching up on all sorts of things. I hope to post a review/discussion of the conference as a whole soon, but for now I just want to touch on some things that came up around ValidateThis.

I gave a presentation entitled Easy and Flexible Validations for Objects during which I described what ValidateThis is, and showed how easy it is to work with. I demonstrated that you can add client-side validations to a form with a single line of code, and can perform server-side validations with just a few lines. I also discussed the different types of validation scenarios that VT is designed to address. There were some questions and suggestions which have prompted me to think of future enhancements to the framework, so I wanted to discuss them here.

[More]

I'll Be Presenting at NCDevcon in May

I'm tickled pink to announce that I will be presenting a couple of sessions at the upcoming NCDevCon, dubbed North Carolina's Premier Web Conference, which is being held in beautiful Raleigh, North Carolina on May 22nd and 23rd. As I discussed in a previous post NCDevCon is being organized by the Triangle Area ColdFusion User's Group and is a sequel to the hugely successful and wildly talked about CFinNC.

I will be presenting two sessions:

  • Getting Started with ColdFusion ORM
  • Creating a Twitter / Google Maps Mashup with CF and Open Source Tools

The first session is one that I have presented before, but ColdFusion ORM is an important topic and therefore the committee considered it worth presenting again. The second session will be a fun one. In it I will demonstrate how I used a number of freely available open source tools to generate a Google Map showing the locations of all of my Twitter friends. This is a project that I built some time ago, and is currently available via my site. I'll be making some updates to it prior to the conference and my hope is that the session will illustrate two points:

  1. There are pre-existing ColdFusion open source projects that can be used to fulfill many of your application's requirements.
  2. It's very easy to create something cool using ColdFusion.

The conference itself is still chock full of ColdFusion, Flex and AIR goodness, but also includes a healthy dose of JavaScript, CSS and other web development topics. The schedule with a full list of sessions has been published, and it's top notch. I'm particularly pleased to see some folks whom I met last year presenting this year, including Daria Norris and Jim Leether. There will also be a number of hands-on ColdFusion sessions for beginners, so if you know someone who would benefit from a bit of a ColdFusion kick-start, send them down North Carolina way.

Registration is open, and, just like last year's CFinNC, it's absolutely free. I hope to see many of you there.

Previous Entries / More Entries