

|
In computing, ColdFusion is a tag-based, middleware programming language used chiefly for writing web-based applications. The language and its application server were originally created by JJ Allaire and his brother Jeremy Allaire. It was then subsequently purchased and owned by Macromedia for several years. Macromedia itself was acquired by Adobe on December 3, 2005.
ColdFusion is generally recognized to be fairly easy for people coming straight from HTML to learn. This is partly because it is tag based like HTML.
While ColdFusion is a programming language, many programmers think of it more as a scripting language, due to its very simple tag-based syntax, typeless variables and lack of support for programming anything but web-based applications.
Contents |
Cold Fusion 1.0 was officially released on July 10th of 1995 by Allaire. The tag-based programming language used was called DBML (DataBase Markup Language) and was later renamed to CFML (ColdFusion Markup Language). Beginning with version 1.5, ColdFusion contained compatibility with C++, allowing users to develop extensions to the language. Years later, this would be the basis for ColdFusion Extension (CFX) Tags, a method of extending the ColdFusion language. Later versions of the language allowed extending the language by writing custom tags in Java and CFML itself. The product was also renamed ColdFusion (one word) - most likely to make it trademarkable -- about this time. Starting in version 5.0, users could also define functions to extend the language (UDF = User Defined Function).
Meanwhile, Allaire began work on rewriting the basis of ColdFusion with Java (codenamed "Neo"), which would allow for greater portability among different platforms.
On January 16, 2001, Allaire announced that it would be merging with Macromedia. Shortly after the merger, Macromedia continued with the incremental release of ColdFusion 5.0 and in June 2002, Macromedia released Macromedia ColdFusion MX, extending the naming convention of Macromedia's line of products. ColdFusion MX was completely rebuilt from the ground up and was based on the Java 2 Enterprise Edition (J2EE) platform. ColdFusion MX was also designed to integrate well with Macromedia Flash using Macromedia Flash Remoting MX.
Starting from the MX (6.0) release, ColdFusion is compiled to an intermediate format (bytecode), like JSP and ASP.NET.
With the release of ColdFusion MX, the CFML language was also extended to support basic OOP. Apart from the tag-based CFML syntax, ColdFusion supports embedded scripts that can be written in a JavaScript-like language.
With the release of ColdFusion 7.0, the naming convention was amended, rendering the product name "Macromedia Coldfusion MX 7". CFMX 7 added Flash-based web forms and a report builder that output in PDF as well as Flash Paper, RTF and Excel. The PDF output is also available as a wrapper to any HTML page, converting that page to a quality printable document. The enterprise edition also added Gateways. (These provide interaction with such things as IM Services, SMS, Directory Watchers, and an asynchronous execution... or add your own gateways.) XML support was boosted in this version to include native schema checking.
ColdFusion runs as a web application and can be deployed in a number of supported servlet containers, including Jakarta Tomcat, Macromedia JRun, and IBM Websphere.
Because of ColdFusion's Java code-base, it is possible to mix Java classes with ColdFusion code to create a variety of applications and utilize existing Java libraries. ColdFusion has access to all the underlying Java classes, allowing usage of Java classes using a procedural coding style. ColdFusion also supports mixed usage of JSP custom tag libraries alongside CFML.
Prior to ColdFusion 7.0.1, it was only possible to utilize Java class in ColdFusion. However, beginning in ColdFusion MX 7.0.1, it is now possible to utilize ColdFusion components from within Java classes using the CFCProxy class.
ColdFusion is a proprietary technology based on Web technology industry standards. However, it is becoming a less closed technology through the potential availability of competing products. Products include New Atlanta's Blue Dragon, IgniteFusion, Railo and Coral Web Builder.
The acronym for the ColdFusion Markup Language is CFML. When ColdFusion templates are saved to disk, they are traditionally given the extension .cfm or .cfc for ColdFusion Components. The original extension was DBM or DBML, which stood for Database Markup Language. When talking about ColdFusion, most users use the Acronym CF and this is used for numerous ColdFusion resources such as user groups (CFUGs) and sites.
CFMX is the common abbreviation for ColdFusion versions 6 and 7 (aka ColdFusion MX).
Query your database:
<cfquery name="nameofquery" datasource="odbc_connection" username="simple" password="enough"> SELECT * FROM table WHERE field = 'whateveryouaresearchingfor' </cfquery>
Loop through your records:
<cfoutput query="nameofquery"> #nameofquery.field_from_query# <!---Above is called a variable, this text here is just comments ---> </cfoutput>
Set and display a variable:
<cfset sMyVar = "A Variable defined in CFML"> Here is the contents of the variable: <cfoutput>#sMyVar#</cfoutput>
Define and use a function:
<cffunction name="AddTwoNumbers" returntype="numeric" output="false" hint="I add two numbers."> <cfargument name="NumberOne" type="Numeric" required="true" hint="I am the first number."> <cfargument name="NumberTwo" type="Numeric" required="true" hint="I am the second number."> <cfreturn NumberOne + NumberTwo> </cffunction><cfoutput>#AddTwoNumbers(2, 2)#</cfoutput>
Define a component (class):
<cfcomponent> <cfset variables.someproperty = ""> <cffunction name="getSomeProperty"> <cfreturn variables.someproperty> </cffunction> <cffunction name="setSomeProperty"> <cfargument name="value" required="true"> <cfset variables.property = arguments.property> </cffunction> </cfcomponent>
Invoke a Java class:
<cfset myPath = "C:\MyFile.txt"/>
<cfset myFile = CreateObject("java","java.io.File").init(myPath)/>
<cfset fis = CreateObject("java","java.io.FileInputStream").init(myFile)/>
CFML provides two different syntax formats for you to use, each with their own pros and cons.
CFML follows an XML/HTML-like syntax in that all commands are written in the format:
<cfcommand argument="something">Some text</cfcommand> <cfset variable="some data">
Note the Coldfusion is not strictly XML because not all attributes have name value pairs and tags need not be well-formed. CFML more closely resembles HTML 4.0 syntax than XML.
An additional syntax format is available that is similar to Javascript:
<cfscript>
command('argument 1', 'argument 2');
</cfscript>
This second format provides a cleaner migration path for people with experience in C-style languages: C, C++, Java, Javascript, etc. One thing to remember is that to use this syntax you must include the cfscript command around the code block-- you can't just launch into cfscript. Whilst everything that can be done in CFSCRIPT can be done via tags, the converse is not true (for example, throwing exceptions).
The following tools and frameworks are available: