Ask a Jedi: Dynamic binds with cfdiv?

This post is more than 2 years old.

This was one of those perfect questions - and by perfect I mean that the reader sent the question in, and then figured it out before I even had a chance to reply. I cannot tell you how often that happens to me. It's like magic. You search for an answer - give up - ask a public group (or person) and immediately the answer becomes apparent. Anyway - here was Brian's question:

Quick question: Can the bind value in the CFDIV tag bedynamic (or variable-ized), or does it have to be hard-coded?

Looking at the ease of update between development and production for something like:

cfdiv bind="cfc:development.controller.function({kevvalue})


cfdiv bind="cfc:production.controller.function({kevvalue})

As you can see, he just wants to make it easy to swap between two paths to a component. Now looking at that, I'd probably consider using one mapping, but simply making the physical path different. With dynamic mappings in ColdFusion 8, that becomes fairly trivial. But outside of that - as Brian found - yes, you certainly plugin a variable: <cfdiv bind="cfc:#root#.controller.function{keyval})">

This is probably obvious, but it's not something I had tried myself, so I'm happy Brian shared this with me.

Raymond Camden's Picture

About Raymond Camden

Raymond is a senior developer evangelist for Adobe. He focuses on document services, JavaScript, and enterprise cat demos. If you like this article, please consider visiting my Amazon Wishlist or donating via PayPal to show your support. You can even buy me a coffee!

Lafayette, LA

Archived Comments

Comment 1 by Gary Funk posted on 7/24/2009 at 6:11 PM

And I'm gald to see I am in good company.