3 March 2011
Watch this video tutorial to learn about what's new in using extensions in ColdFusion Builder 2. Raymond Camden presents several extensions he has created in ColdFusion Builder 2 that are powerful and effective coding time-savers. Watch the video tutorial and follow along with the transcript and source files provided in this article.
Note: While this video refers to ColdFusion Builder 2 as "Storm", the code-name for the latest beta, all features described in this tutorial work as described in the most recent release of ColdFusion Builder 2.
Video: What's new with extensions in ColdFusion Builder 2 (7:02)
If you don't know what extensions are, this is an API within Adobe ColdFusion Builder that allows you to add features to the editor. Typically, adding these types of things within Eclipse requires Java, but within Adobe ColdFusion Builder, you can just use ColdFusion. There's already a great community of free extensions out there. And what's nice is that "Storm" makes this feature better by adding a lot more power to them. Keep in mind that everything I'm showing you here is beta, and things can definitely change between now and the final release date.
So let's start off showing some ways "Storm" provides additional data to your extensions. This additional data can help your extensions run better. I'm going to start off by showing the Mirror extension.
Mirror is an extension I wrote to basically help me write other extensions. All it does is spit back out the XML, that ColdFusion Builder had sent to the extension. It's a good way to debug what the editor is sending along to it.
So, I'm going to right-click and run the Mirror extension. This is the XML packet returned. Now, there's a couple new things here:
- First is that we actually sent the version number. So what's nice is that I can actually write an extension that supports both ColdFusion Builder 1 and Storm, and going forward, version 3.
- We also sent the server as well. Now this was something that your extension could kind of sniff via CGI variables, but now it's a bit easier to get at.
Right away we're seeing that "Storm" is basically sharing more data with the Extensions. If your extensions need this type of information, it's a lot easier to get to. Now there's even more stuff you can do. Check out this
callbackurl. There's this set of new features where you can request data via the
callbackurl.Let me show you an example of that.
I have an extension right here—this is a handler. And what I've done is I've gotten a URL on line 5 of test.cfm , and then I have constructed some basic XML. This XML is going to ask ColdFusion Builder for the data sources see right there on line 9 . All I do is send that XML to the
callbackurl. Now I'll get a nice set of XML data back. You see I'm looping over that in lines 18-20. So I will run this extension real quick and you will see I get all the data sources that are defined within my editor. There are a lot more commands you can run. You can get tables, you can get detailed information about a particular table, and so forth.
One of the cooler ones though, and I'll show it running and then explain how it works. I can right-click in my "fancy" CFC file, and run that. You can see that Storm was able to parse this file and tell me all of the variables and all of the functions. If I go in here and just add on line 4, a variable for name2 with a value of "Jacob" and save it and run the extension again, and we'll see that it picked up on the new variable. Again, there's a whole set of commands that can provide a lot of data to your extensions to make them more powerful.
Let's look at another cool feature—out of the box ColdFusion Builder has Code Assist. So if you're using any ColdFusion function like
imageNew , imageResize ,or whatever, ColdFusion Builder can provide syntax and information about those functions. But what if you had something custom? What you see here on line 1 is
event.LinkTo, that is a Model Glue function that's used to create links to events defined within an XML file. Wouldn't it be cool if Storm could actually get my Model Glue application, tell me what events are available, and actually provide that? Check this out. I'm going to go into my function, and ask for the Code Assist, you can see I have a list of events provided that I can pick from. How does this work? In this example, what I did was hard-coded some results back. Normally what this would need to do is look at your Model Glue XML and figure out the events in there. Luckily, ColdFusion makes XML parsing really easy, so it's not a big deal.
On the configuration side, all this Extension did was say, "you know what, when there is this variable called 'event', I can provide some assistance for that." All that it's doing is saying, "run this handler." That goes back to the file I just showed. Normally this would be dynamic. You can imagine all the frameworks out there that can provide support like this. So now the Code Assist is not just saying that "the first argument takes a string…" but actually provides you what the string value could be. I think that's really darn neat!
Now let's look at another example. One of my favorite extensions is the VarScoper. This allows me to right-click a folder, and find out what files are not properly "varscoped" are not properly scoped as variables . As you can see here, here is the report. I see we have 11 unscoped variables. Now the problem with this particular extension is that if I want to start working on it, if I start trying to click back in the editor, I can't. It's because this is a Model dialogue window. It's above everything else. But what's nice is that Storm allows you now to create views.
Now, run the same Extension, but a new version. And you will see, that we have a "view" version of that same extension. So what's nice is that I can now start working on these files, make corrections, and then simply re-run that view version of that same extension to see that I'm updating and fixing problems. You can create views on the fly, you can also create extensions that have the "find views" show up in your window, by going to Window > Show View menu. You can also do toolbars for these as well.
So that's it for now, though, there are more things coming, for example being able to register how a CFM should run, what the start page is, and again, this is still in beta, so we might expect Storm to have a bit more when it gets released. I hope this gets you excited about Storm, and I hope to see you when it is released.