I’m writing an application that uses ColdFusion’s ORM features heavily. Various fields in my database deal with Personally Identifiable Information (PII) and need to be encrypted to meet regulatory requirements. I’ve been mulling over the best way to deal with keeping the data encrypted while in the database but have it be readily usable when loaded into an entity. None of the scenarios that came to mind felt right or could be implemented without an extensive amount of “work-around” code and I just wasn’t willing to go down those paths.
I put the question out to the folks that follow me on Twitter and got a couple of responses, one of which was from Mark Mandel who suggested using annotations. Now, I’ve heard the word annotation mentioned, but had never had the time/opportunity to research what they were or how they were used. That was a few weeks ago and in the meantime, I’d gotten busy focusing on other things and just got around to thinking about the encryption thing again a few days ago. What I found out astonished me.
Read more…
For the last year or so, all of my ColdFusion development projects have been built using the Model-Glue MVC framework. Over time, you get to where you know the most commonly used methods that are used to interact with the framework by heart. Sometimes there are lesser-used methods that you have to go look up. All the time (for me at least) I’m trying to find a way to write code faster and with less errors.
ColdFusion Builder has done a very nice job of providing code insight for ColdFusion tags, functions and CFC methods. This is especially true if you have a server configured in the “Servers” panel and mapped to your CF Builder project as it then will provide code insight for your own CFCs that you create on the page. However, when using Model-Glue, the “event” object is created for you and is always there. Because it’s not explicitly created on the page, CF Builder can’t provide code insight when you need to interact with it. However, it only takes a couple of settings in your project to make CF Builder aware of the event object and start providing help for it.
Here’s the process:
- Right click on your project and choosing “Properties”.
- In the left pane of the window that comes up, click on “ColdFusion Variable Mappings”.
- On the right side, click the “New” button and enter the following values into the boxes
- Variable Name: event
- Mapped To: html.ModelGlue.gesture.eventrequest.EventContext
- Press the “New” button and enter the following values into the boxes
- Variable Name: arguments.event
- Mapped To: html.ModelGlue.gesture.eventrequest.EventContext
- Press the Apply button then the OK button
* Note that the value in the “Mapped To” box is the actual dot-notated path to the EventContext.cfc file from your CF Builder project root. I happen to have my webroot files in a folder named “html” under the project root (see screenshot #1 below).
Once you have those settings saved, any time you type “event.” or “arguments.event.” you’ll get the list of methods contained in the Event object. Of course, this doesn’t only work with Model-Glue. Any CFC that you regularly use the same name with can be configured this same way.
I’ve attached some screenshots for reference. If you have any questions or something isn’t working, feel free to ping me.
There have been some lively discussions on Twitter today centered around the adoption of open source CFML engines in various types of businesses. I can’t speak to any kind of trends anywhere, but I wanted to share my experience with a project I was involved in last year that used Railo as the CMFL engine.
Read more…
I’m a relative novice using ColdFusion’s ORM features having done just one “real” project so far that took advantage of it. I’m working on an application that needs to be able to set the datasource for each request based on the URL that the customer is using to access the site. For example, if a customer visits http://customera.demoapp.com I need the application to use the DSN named “dsn-customera”, http://customerb.demoapp.com gets “dsn-customerb” and so on.
Normally this wouldn’t be an issue–you’d do some sort of logic in the onRequestStart() method in Application.cfc and set a request or session scoped variable to the name of the DSN and go from there. However, when using ColdFusion’s ORM functions, this approach doesn’t work since “this.datasource” is configure in the pseudo-constructor at the top of Application.cfc like so:
Read more…
Last week I was working on a client’s project that makes heavy use of ColdFusion 9′s ORM features. Everything we’d done with ORM up to that point had been going really well and I continue to be impressed by the amount of time ORM saves me in development. I had gotten to a point in the project where I needed to be able to use AJAX calls from jQuery to manage some of the data in the database. Based on my experiences using a RemoteFacade.cfc to feed data to a Flex app, I thought it should be pretty easy. Several hours later, I realized that my particular use case for this was anything but easy.
Read more…