Photo from Chile

ColdFusion ORM Gotcha - Non-String Struct Collection Keys

Here's another tricky issue when working with collections of child objects that are stored as structs. Just like last time, we'll look at a Department object with a one-to-many property that holds a collection of Users which is stored as a struct. The difference this time is that we'll use a numeric property as the key to the struct, rather than a string property:

component persistent="true" output="false" entityname="Department" {
    property name="DeptId" fieldtype="id" generator="native";
    property name="Name";
    property name="SIN" ormtype="int";
    property name="Users" fieldtype="one-to-many" type="struct"
        cfc="User" fkcolumn="DeptId" singularname="User"
        structkeycolumn="SIN" structkeytype="int" cascade="save-update";
}

The nice thing about having the collection of Users in a struct is that we can access them individually. For example, if we have a Department object and we know we want the User in that Department with a SIN of 12345, we could simply write:

Department = entityLoad("Department",1);
User = Department.getUsers()[12345];

If you're like me you'd probably think that would work, but it doesn't.

[More]

Running Multiple Copies of ColdFusion MultiServer with Apache on OS X

I've been trying, on and off, for nearly six months to get two versions of ColdFusion, CF 8 and CF 9, running in a MultiServer install of CF with JRun on my Mac. I've read all of the documentation that is available, as well as a good number of blog posts, but I always seem to get stuck at the point of deploying my CF9 EAR into my existing copy of JRun (which was installed during the MultiServer install of CF8). Everything I've read suggests that auto-deploy should work - you just copy your exploded EAR into a folder under JRun/servers/ and JRun will deploy CF9 for you. Well, for whatever reason, that simply does not work with my setup. I also tried to manually deploy (in spite of there seeming to be zero documentation on how to do that), but still could not get my instance of CF9 to start up in JRun.

After walking through all of the steps yet again yesterday, and coming up with the same result, I asked someone who in my mind is the most knowledgeable person about this topic, particularly when it comes to OS X, Sean Corfield. We discussed the steps I had taken, and he suggested that auto-deploy with JRun can be problematic. He then suggested a solution that worked perfectly for me, so I'm going to share it with you here.

[More]

Creating Eclipse (and CFBuilder) Keyboard Shortcuts for Subclipse

Here's another quick tip to keep your hands on the keyboard and off of the mouse. I currently use both Subversion and Git for version control of my code, but I definitely use Subversion more. One thing that I found myself using the mouse for time and again was to commit changes to my SVN repo using the Subclipse Eclipse plug-in. One of the worst things about that workflow is the number of steps it takes. You have to right-click, then select Team, and then select Commit from the menu. I'm not sure why I continued to do that for so long, but I finally got around to Googling "Subversion Keyboard Shortcuts" and came across a blog post by Mads Darø Kristensen, with a video no less, that shows exactly how to set these up. The steps are as simple as this:

  1. Open the Eclipse Preferences menu (command+, on a Mac).
  2. Choose General -> Keys.
  3. In the box where it says type filter text, type SVN.
  4. Choose the Commit command from the list of commands.
  5. Place your cursor in the box labelled Binding and type the key combination you wish to use. I use control+option+C.
  6. Click the Apply button.

Now, when you're done editing a file and you want to commit it to your SVN repo, just type the key combination and the Subclipse Commit dialog box will appear. If you want to commit all files in a project or a folder, rather than just the current file, then highlight the project or folder (which seems to require some mouse-work, unfortunately), and then type your combo. I've also assigned control+option+R to Revert and control+option+S to Synchonize with Repository. I'm finding that these shortcuts are saving me a lot of time, and allowing me to keep my hands on the keyboard, where they belong.

Funny ColdFusion Error Message

It's not often that a ColdFusion error message makes me chuckle, but this one did:

I guess ColdFusion's parser has different priorities than I would have expected. Either that, or there's an undocumented cfelseifvariables tag that I never knew about. ;-)

Awesome Training Available Before cf.Objective()

As you're no doubt aware, cf.Objective(), "The World's Only Enterprise Engineering Conference for ColdFusion Developers", is coming to Minneapolis, MN from April 22-24, 2010. It's an outstanding opportunity to learn a ton of stuff, and to network and socialize with like-minded developers. I am pleased and honoured to be speaking, twice, for the second year in a row. What you may not realize, however, is that in the days prior to the conference there is a boatload of training available.

Developing Applications with ColdFusion 9 Object Relational Mapping

Mark Mandel and I will be delivering a comprehensive hands-on workshop on Developing Applications with ColdFusion 9 Object Relational Mapping for two whole days, from April 20-21, and it's going to be fantastic, if I do say so myself. If the new features of ColdFusion's ORM integration don't interest you (buy why wouldn't they?), there are five other choices.

Something For Everyone

Here's the full list of all of the courses available:

  • Building Secure CFML Applications (April 21) - Jason Dean and Pete Freitag
  • Coldbox:100 Training (April 21) - Luis Majano
  • Developing Applications with ColdFusion 9 Object Relational Mapping (ORM) (April 20-21) - Bob Silverberg and Mark Mandel
  • Getting Started with Flex and AIR Development with the Flex SDK (April 21) - John Mason
  • Mach-II and OOP from the Ground Up (April 20-21) - Kurt Weirsma, Peter Farrell and Matt Woodward
  • Rapid Development with Model-Glue 3 (April 20-21) - Dan Wilson and Ezra Parker

There really is something for everyone, and the instructors are all top-notch.

Anyone Can Attend

Something else you might not realize; you don't have to attend cf.Objective() in order to sign up for and attend a pre-Conference training class. So, if you've been hankering to learn more about CF9 ORM, application security, ColdBox, Model-Glue, Mach-II, or Flex and AIR development, go for it!

The Early-Bird Ends Friday

I'll close with a reminder; the discounted early-bird rates, which apply to both the cf.Objective() conference fee and to most of the pre-conference training sessions, expires this Friday, January 29th. So why not save some cash and sign up right now? Registration is done via the cf.Objective() registration form.

I hope to see many of you there in April.

More Fun with ColdFusion ORM Struct-Based Collections

Ben Nadel asked a question in a comment to my last post about struct-based collections with ColdFusion ORM which I thought was quite interesting and deserved some investigation. To recap the previous post, it simply pointed out that in order to add an object to a struct-based collection, when calling the add method one must pass both the object to be added to the collection and the key to be used in the struct. This raised a great question from Ben, whom I quote:

Does the ORM system do any validation on the Key that you pass in? Does it affect the way the data is persisted to the database (or will the persistence use the value as defined by the CFProperty structKeyColumn)?

I'd never tested this myself, so I did just that, and what I found was somewhat surprising.

[More]

Three Eclipse (and CFBuilder) Shortcuts to Improve Your Life

OK folks, this is a big deal. I'm going to tell you about three keyboard shortcuts that you really need to incorporate into your routine. These are nothing new. Marc Esher blogged about these nearly a year ago, and there's a good chance that you're already using them, and if so, you know how amazing they are. But if you're not using them then you're really missing out.

If you're like me at first glance they won't seem like a big deal. You'll think, "How often do I need to do that?" But if you get yourself into the habit of using them, you won't believe how much more pleasant your time spent coding in Eclipse will be. Enough of the sales pitch, let's get on with it. The three shortcuts are:

  • Command+Option+Up/Down (Ctrl+Alt+Up/Down on a PC) - copy the selected line(s) above or below themselves
  • Option+Up/Down (Alt+Up/Down on a PC) - move the selected line(s) up or down
  • Command+D (Ctrl+D on a PC) - delete the selected line(s)

These commands blow cut/copy and paste out of the water. One of the best things about them is that you don't have to select an entire line to use them. Your cursor can be anywhere on the line(s) and it will work, so you don't have to bother hitting the Home key to move to the beginning of a line to copy, move or delete it. If this still doesn't seem like not a big deal to you, let's walk through a quick exercise. Take the following code and copy it into a file in Eclipse:

<cfif something>
    do something
    that takes 2 lines of code
<cfelseif somethingElse>
    do something else
    that takes 2 lines of code
</cfif>

<cfif anotherTest>
    do something different again
    that takes 2 lines of code
<cfelse>
    do something completely different
    that takes 2 lines of code
</cfif>

Let's say we want to add a similar cfelseif block into the second cfif block. Put your cursor anywhere on the existing cfelseif tag line and do shift+down x 2. You should now have part of the cfelseif line highlighted as well as all of the next line and part of the following line. Now do ctrl+alt+down. Your three lines of code have been duplicated immediately below the previously selected lines, and now they are selected. Now do alt+down x 5. Voila, you've copied your cfelseif block right where you needed it in very few keystrokes, and only had to lift your fingers from the keyboard once. Try that with copy and paste!

If you're still not with me on this one then I humbly suggest that you try doing it for a few days (or even just a few hours). Try to force yourself to use these shortcuts anytime that you need to copy, move or delete a line or block of code. I'm willing to bet you'll be hooked in very short order.

If you're wondering why I choose to blog about these now, I was inspired by a colleague. I only started using these shortcuts a few weeks ago and was kicking myself that I hadn't picked them up sooner. I was chatting with my friend and, somewhat , admitted that I had only started using them recently. "What do they do?" he asked. I was shocked that he too was not benefitting from their incredible usefulness, so I figured I should write this up to share this tidbit with everyone. Enjoy!

More Entries