Home arrow ColdFusion arrow Page 3 - Adobe ColdFusion Just Got More RAD

Adobe ColdFusion Just Got More RAD

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.

Author Info:
By: Brian Rinaldi
Rating: 5 stars5 stars5 stars5 stars5 stars / 20
August 25, 2009
  1. · Adobe ColdFusion Just Got More RAD
  2. · ColdFusion Builder: a New IDE
  3. · Extending ColdFusion Builder with CFML

print this article

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.

<cfsetting enablecfoutputonly="true" />   <cfparam name="ideeventinfo" />   <cftry>       <cfset xmldoc = XMLParse(ideeventinfo) />              <!--- get save location. if there is no location, just quit --->           <cfset saveLocation = XMLSearch(xmldoc, "/event/user/input[@name='location']") />       <cfif arrayLen(saveLocation) eq 0>           <cfabort />       </cfif>       <cfset tableNode = XMLSearch(xmldoc, "/event/ide/rdsview/database/table")>       <cfset database = XMLSearch(xmldoc, "/event/ide/rdsview/database")>       <cfset dbname=database[1].XMLAttributes.name />       <cfset userInputs = XMLSearch(xmldoc, "/event/user/input") />                    <cfset fields = XMLSearch(xmldoc, "/event/ide/rdsview/database/table/fields/field") />       <cfif listlen(tableNode[1].XMLAttributes.name,'.') eq 2>            <cfset table= listGetAt(tableNode[1].XMLAttributes.name,2,'.') >       <cfelse>            <cfset table = tableNode[1].XMLAttributes.name >       </cfif>              <cfset DBTypeMapping = CreateObject("component","Util") />       <cfset remoteCFC = XMLSearch(xmldoc, "/event/user/input[@name='remotecfcmapping']") />       <cfset IDFieldName = DBTypeMapping.getPK(dbname,table) />       <!--- generate Transfer mapping file --->       <cfsavecontent variable="ormConfigContent" ><cfoutput>   <transfer xsi:noNamespaceSchemaLocation="/transfer/resources/xsd/transfer.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">       <objectDefinitions>           <package name="#ucase(left(table,1))##lcase(right(table,len(table)-1))#">               <object name="#table#" table="#table#"<cfif len(remoteCFC[1].XMLAttributes.value)> decorator="#remoteCFC[1].XMLAttributes.value#"</cfif>><cfloop index="i" from="1" to="#ArrayLen(fields)#">                   <cfif listContainsnocase(IDFieldName,fields[i].XMLAttributes.name) neq 0><id name="#fields[i].XMLAttributes.name#" type="#trim(DBTypeMapping.getASDataType(fields[i].XMLAttributes.type))#" /><cfelse><property name="#fields[i].XMLAttributes.name#" type="#trim(DBTypeMapping.getASDataType(fields[i].XMLAttributes.type))#" /></cfif></cfloop>               </object>           </package>       </objectDefinitions>   </transfer></cfoutput>       </cfsavecontent>              <!--- save file --->       <cfset saveLocation = saveLocation[1].XMLAttributes.value />       <cffile action="write" file="#saveLocation#/#table#-transfer.xml" nameconflict="overwrite" output="#Trim(ormConfigContent)#" >       <cfcatch type="any">           <cfsavecontent variable="dumpError">   <cfdump var="#cfcatch#" />           </cfsavecontent>           <cffile action="write" file="#expandPath('/')#/error.txt" nameconflict="overwrite" output="#Trim(dumpError)#" >           <cfrethrow />       </cfcatch>   </cftry>  

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.

To download the ColdFusion 9 public beta, please go to http://adobe.com/go/coldfusion_beta_download. The ColdFusion Builder public beta is available here at http://adobe.com/go/coldfusion_builder_beta_download.

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.

blog comments powered by Disqus

- Adobe ColdFusion Just Got More RAD
- How to Access a SQL Anywhere Database with C...
- CFXML: Probing XMLDOM in ColdFusion
- Creating a Web Service with ColdFusion: the ...
- CFAjax: What it is and How to Use it
- Querying SQL 2000 Server from ColdFusion
- Introduction to ColdFusion Markup Language, ...
- Introduction to ColdFusion Markup Language
- Databases and Dreamweaver MX 2004, concluded
- Databases and Dreamweaver MX 2004
- Welcome to Coldfusion MX 6.1, concluded
- Welcome to Coldfusion MX 6.1
- What You Must Know About ColdFusion Flow-Con...
- What You Must Know About Operators in ColdFu...
- Everything You Must Know About ColdFusion Va...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 

Developer Shed Affiliates


© 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials