ColdFusion has always focused on making difficult things easy, and with the new features and tools announced for its public beta on July 13, 2009, Adobe seems set to deliver on that goal in a variety of different ways. Keep reading for a close look at how this beta will help simplify the lives of ColdFusion programmers.
Adobe ColdFusion Just Got More RAD - Extending ColdFusion Builder with CFML (Page 3 of 3 )
In this example, I will add a menu item to the RDS Dataview that will list the option "Generate Transfer Config Snippet" when you right-click on a table. This will generate and save the basic XML snippet necessary to configure this table to be managed by the open-source Transfer ORM (http://www.transfer-orm.com/), saving you from having to hand code the ID and properties configuration for this table.
To begin, we need to create a configuration XML file that will tell ColdFusion Builder where to add this menu option and what user input you may need in order to complete the task. The configuration will also identify the CFML template associated with each task listed. This file must be called ide_config.xml.
<application> <name>Transfer Config Generator</name> <author>Brian Rinaldi</author> <version>1.0</version> <email></email> <description>Generate Transfer Config Snippet</description> <menucontributions> <contribution target="rdsview"> <menu name="Generate Transfer Config Snippet"> <action name="Generate Transfer Config" handlerid="DB_TRANSFER"> <input name="location" label="Enter location" tooltip="Location where generated XML will be stored" type="dir"/> <input name="remotecfcmapping" label="Decorator CFC path (Optional)" tooltip="Use Dot Notation from wwwroot." type="string"/> </action> </menu> </contribution> </menucontributions> <handlers> <handler id="DB_TRANSFER" type="CFM" filename="DB_Transfer_Config.cfm" /> </handlers> </application>
Our configuration file has a single task (or action). It also requests the user to input two items: a) a save location for the file that will prompt a user to choose a save location within their Eclipse projects, and b) a dot-notation path to a facade if necessary. As you can see in the handler's block, I call a single CFML template to process this task called DB_Transfer_Config.cfm. Let's take a look at that template.
Now, there is a lot going on here, but overall it's fairly generic CFML code, which I have based upon the examples provided with ColdFusion Builder. The first portion of the code block sets a bunch of values based upon parsing the XML sent to the CFML page by ColdFusion Builder (i.e. the ideventinfo variable). The cfsavecontent block outputs the Transfer config XML, filling in the properties as necessary from the data provided. Finally, the file is saved into the save location that the user specified within the input window.
And, if there is an error, I save information into a file within the web root. This is done mostly because it helps with debugging while building the extension. Eclipse will notify you if an error occurs, but doesn't actually provide you any debugging information. I simply write out the error file to simplify the debugging process -- saving me from having to browse the logs. This simplified the development process for me and can provide a simple file that users can send you should the extension fail on their system. The install file is simple a zip archive of the handlers folder and the ide_config.xml file.
As you can see, one of the beauties of ColdFusion Builder is that any ColdFusion developer can write extensions; no need to learn the Java or the intracacies of the Eclipse framework. Not only that, but these extensions are easily shared among coworkers or within the community at large.
Public Betas Now Available
So the first question you may ask is, when will all this be available? Well, thankfully, I have been authorized to tell you "now!" And there are far more new features to ColdFusion 9 and ColdFusion Builder than the few features I managed to cover here. For example, I could have discussed the ColdFusion services like email or PDF generation made directly available to Flex or Flash applications. I could have gone feature through feature into the incredibly enhanced Flex and AIR integration features.
In fact, I suspect there will a lot of articles covering all of these and more features. So, if you are already a ColdFusion developer, the future looks bright. If you aren't, then you might want to take another look...or watch as we breeze on by.
DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.