ColdFusion Builder Variable Mappings

So, I’ve been getting used to ColdFusion Builder and I was messing around with the variable mappings today for my ColdBox projects and wanted to throw what I have done out there and see what other people have done.

I was excited to hear that CFB would give me introspection into my CFC’s but was disappointed to find out that it only really worked if you had a createObject at the top of the page. So basically, Builder can’t figure out where variables came from that were injected by wirebox. (which is understandable)

Someone showed, me the “ColdFusion Variable Mappings” I could set for my ColdFusion project which told CFB the fully qualified dot-delimited path to my CFCs and the variable names I would (hopefully) be using to reference them with.

Firstly, it appears that setting up a userBean variable doesn’t do any good if your line of code says variables.userBean, or local.userBean. My solution was to set up a mapping for all the common scopes (or structs) I might need to access that object in. Someone please let me know if there is a work around for that. I think it’s kind of ironic that Adobe is perfectly willing to assert that EVERY instance of com.foo.bar.user in my app will be in a variable called userBean, but variables.userBean or local.userBean? nope, that’s a totally different object and it’s not at all safe to assume what it might be.

Secondly, since I am doing local development and have my local instance of ColdFusion set up in Builder on the servers tab, I hoped it would be able to use the CF mappings I have configured to resolve my component paths, but apparently that’s asking too much. Since my project root is not my web root, it can’t find my CFCs. I had to create a “Linked” folder in my project root that pointed to my com folder that my CF mapping points to. This works, but every time I Ctrl-click a component name, it pops two files that it has it mapped to. The real path, and the one in the "Linked " directory. Let me know if anyone has found a better solution to that.

And lastly, which is really where the ColdBox part comes in— I have over 200 components in my apps, 4 common scopes I access them in (userBean, variables.userBean, rc.userBean, local.userBean), and in some cases two different naming conventions for my variables. All told, that is over 1000 different mappings and I ain’t hand-entering those puppies! I found that my variable mappings are stored in the settings.xml file in the root of my project. I wrote the following bit of CF code (I removed a couple bits that are specific to my naming conventions) to automatically generate my mappings so I can copy and paste into my settings.xml file and restart CFB for it to pick them up. The output of the below code can be pasted between the tag.

Please give me any feedback, and/or let me know if there is another, more slick method to achieving this.

<cfset mappings = getPlugin(“BeanFactory”).getModelMappings()>
<cfset scopes = [“variables”,“rc”,"",“local”]>

#r##iif(len(trim(r)),de("."),de(""))##i##mappings[i]#

Thanks!

~Brad

I have had the same complaint about Builder not offering insight into my CFCs was unaware of the feature you shared.

I think I’ll give that a shot!

Thanks for sharing Brad!

Aaron Greenlee
http://aarongreenlee.com/