ColdFusion Markup Language
Encyclopedia
ColdFusion Markup Language, more commonly known as CFML, is a scripting language
for web development that runs on the JVM, the .NET
framework, and Google App Engine
. Multiple commercial and open source implementations of CFML engines are available, including Adobe
ColdFusion
, New Atlanta
BlueDragon
(who makes both a Java-based and a .NET-based version), Railo
, and Open BlueDragon as well as other CFML server engines.
The CFML language was guided by the CFML Advisory Committee beginning in 2009. This committee included representatives from Adobe, Railo, and Open BlueDragon, but the committee was disbanded in 2010. General language discussions and feature suggestions now tend to happen on the CFML Conventional Wisdom Google Group or on various other CFML mailing lists.
commands, conditional operators
, high-level formatting functions, and other elements to produce web applications. CFML also includes numerous other constructs including ColdFusion Components (CFCs), CFML's version of objects
, that allow for separation of business logic from presentation.
CFML can be written using either tags or CFSCript, which is an ECMA script style language.
The pages in a CFML application
include the server-side
CFML tags and functions in addition to HTML tags, and modern CFML applications also tend to have CFCs that are accessed by the CFML pages for executing business logic. When a web browser
requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion Application Server
.
CFML can also be used to generate other languages, aside from HTML, such as XML
, JavaScript
, CSS
, and so on.
Despite the name, CFML is not a markup language. It is also not SGML, since certain core CFML features prevent it from complying.
The CFML engine is configured in such a way that certain file extensions on the server (.cfm, .cfc) are handed off to the CFML engine for processing. In the case of the Java-based engines this is accomplished via Java servlets
. The CFML engine only processes CFML tags and functions; it returns text outside of CFML tags and functions to the web server unchanged.
, originally located in Minnesota but later moving to Cambridge, MA and finally Newton, MA. Allaire was acquired by Macromedia
in 2001, thus Allaire Cold Fusion became Macromedia Cold Fusion (the space was removed from the product name with the release of ColdFusion version 4). Adobe acquired Macromedia in 2005 and is still actively developing ColdFusion.
In 1998 Alan Williamson and his Scottish company n-ary began creating a templating engine for Java to simplify common programming tasks. Williamson was using curly-brace notation instead of tags, but when he saw an example of CFML and how it was solving similar problems (although not in Java) using a tag syntax, he started developing what would eventually become BlueDragon, which was the first Java implementation of the CFML language. (ColdFusion was written in C and C++ until version 6.0--the first Java-based version of ColdFusion--was released in 2002.) New Atlanta licensed BlueDragon around 2001 and made it available as a commercial product, eventually creating a .NET implementation of CFML. Open BlueDragon is a fork of the commerical BlueDragon product and was first released in 2008.
The Railo CFML engine began as a student project in 2002 and was first launched as a commercial project in 2005. Railo announced they were making the engine open source in 2008, and the first open source version was released in 2009.
On June 18 2009, Adobe
announced at the CFUnited conference that it had formed a CFML Advisory Committee that would be responsible for guiding and reviewing changes to the CFML language. This effort was disbanded in 2010. The Google Group CFML Conventional Wisdom was created as a forum for open, public discussions about language and engine features.
, though some tags (e.g. cfset, cfif) contain an expression rather than attributes. Many CFML tags have bodies; that is, they have beginning and end tags with text to be processed between them. For example:
Other tags, such as cfset and cfftp, never have bodies; all the required information goes between the beginning (<) character and the ending (>) character in the form of tag attributes (name/value pairs), as in the example below. If it is legal for tags not to have a body, it is syntactically acceptable to leave them unclosed as in the first example, though many CFML developers choose to self-close tags as in the second example to (arguably) make the code more legible.
Even if the tag can have a body, including a body may not be necessary in some instances because the attributes specify all the required information. In these cases, as with the second example above, the end tag (and hence, the tag body) may be ommitted and the tag may be self-closing as in the following example:
Various tags offer the ability to type-check input parameters (e.g. cffunction, cfparam, cfqueryparam) if the programmer
declares their type specifically. This functionality is used with cfqueryparam to secure
web applications and databases from hackers and malicious web requests such as SQL injection
.
as both a custom tag and a regular template. Custom tags are written in CFML and are typically invoked by prefixing the custom tag's file name with cf_, although there are other ways to invoke custom tags.
If a template is invoked as a custom tag, the attributes used to invoke that tag are available within the tag in a special attributes structure and the variables contained in the calling page are accessible via the caller structure.
For example, if writing an add tag which takes two attributes and adds them together, the sum.cfm page would look like this:
Assuming the template and tag are in the same directory, the tag can be invoked thus:
CFX tags are custom tags which are developed using Java or C++
, and are prefixed with cfx_ just like cf_. Java and C++ tags are added to the CFML runtime environment using the CFML engine's administrator or by editing configuration files.
On some CFML engines JSP
tags can also be included in CFML pages using the tag.
To create a CFC:
CFCs are plain CFML. Within a CFC any CFML tag, function, custom tag, other components, etc. may be used.
CFCs can be used in various ways. If a method contained in a CFC simply needs to be invoked, the tag will create an instance of the CFC, invoke the desired method, and then destroy the instance of the CFC. takes the name of the component (minus the.cfc extension) and the method to execute. To access any returned data, the RETURNVARIABLE attribute provides the name of a variable to contain whatever the function returns.
CFCs are created using four tags, saved as.CFC files, and invoked using the tag.
In the example below, component temperature.cfc has a method FtoC which converts temperature from Fahrenheit to Celsius. The test.cfm template invokes the method and converts 212 degrees Fahrenheit and outputs the result.
CFCs may also be instantiated as objects. Assuming a CFC file called Person.cfc, an instance of this CFC would be instantiated as follows:
CFCs also form the basis of the ability to create web services in CFML. A CFC is created in the usual way, and the attribute access="remote" added to any function within the CFC will make that function available to be called as a SOAP
-based web service. The CFML engine auto-generates a WSDL and creates all the necessary stubs for the web service to function.
Server-side scripting
Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the web server to generate dynamic web pages. It is usually used to provide interactive web sites that interface to databases or other data stores. This is different from...
for web development that runs on the JVM, the .NET
.NET Framework
The .NET Framework is a software framework that runs primarily on Microsoft Windows. It includes a large library and supports several programming languages which allows language interoperability...
framework, and Google App Engine
Google App Engine
Google App Engine is a platform as a service cloud computing platform for developing and hosting web applications in Google-managed data centers. It virtualizes applications across multiple servers,...
. Multiple commercial and open source implementations of CFML engines are available, including Adobe
Adobe Systems
Adobe Systems Incorporated is an American computer software company founded in 1982 and headquartered in San Jose, California, United States...
ColdFusion
ColdFusion
In computing, ColdFusion is the name of a commercial rapid application development platform invented by Jeremy and JJ Allaire in 1995. ColdFusion was originally designed to make it easier to connect simple HTML pages to a database, by version 2 it had...
, New Atlanta
New Atlanta
New Atlanta Communications, LLC is a software company specializing in products to ease creation of Web applications. Based in Alpharetta, Georgia, United States, and founded in 1998, the company markets 3 products: ServletExec, JTurbo, and BlueDragon....
BlueDragon
BlueDragon
BlueDragon is a ColdFusion Markup Language engine comparable to Adobe Systems's ColdFusion. It is licensed and distributed by New Atlanta from TagServlet Ltd based in Scotland...
(who makes both a Java-based and a .NET-based version), Railo
Railo
Railo is Open Source software which implements the general-purpose CFML server-side scripting language, often used to create dynamic websites, web applications and intranet systems...
, and Open BlueDragon as well as other CFML server engines.
The CFML language was guided by the CFML Advisory Committee beginning in 2009. This committee included representatives from Adobe, Railo, and Open BlueDragon, but the committee was disbanded in 2010. General language discussions and feature suggestions now tend to happen on the CFML Conventional Wisdom Google Group or on various other CFML mailing lists.
Synopsis
In its simplest form, like many other web scripting languages CFML augments standard HTML files with databaseDatabase
A database is an organized collection of data for one or more purposes, usually in digital form. The data are typically organized to model relevant aspects of reality , in a way that supports processes requiring this information...
commands, conditional operators
Operator (programming)
Programming languages typically support a set of operators: operations which differ from the language's functions in calling syntax and/or argument passing mode. Common examples that differ by syntax are mathematical arithmetic operations, e.g...
, high-level formatting functions, and other elements to produce web applications. CFML also includes numerous other constructs including ColdFusion Components (CFCs), CFML's version of objects
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
, that allow for separation of business logic from presentation.
CFML can be written using either tags or CFSCript, which is an ECMA script style language.
The pages in a CFML application
Application software
Application software, also known as an application or an "app", is computer software designed to help the user to perform specific tasks. Examples include enterprise software, accounting software, office suites, graphics software and media players. Many application programs deal principally with...
include the server-side
Server-side
Server-side refers to operations that are performed by the server in a client–server relationship in computer networking.Typically, a server is a software program, such as a web server, that runs on a remote server, reachable from a user's local computer or workstation...
CFML tags and functions in addition to HTML tags, and modern CFML applications also tend to have CFCs that are accessed by the CFML pages for executing business logic. When a web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...
requests a page in a ColdFusion application, it is automatically pre-processed by the ColdFusion Application Server
Application server
An application server is a software framework that provides an environment in which applications can run, no matter what the applications are or what they do...
.
CFML can also be used to generate other languages, aside from HTML, such as XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....
, JavaScript
JavaScript
JavaScript is a prototype-based scripting language that is dynamic, weakly typed and has first-class functions. It is a multi-paradigm language, supporting object-oriented, imperative, and functional programming styles....
, CSS
CSS
-Computing:*Cascading Style Sheets, a language used to describe the style of document presentations in web development*Central Structure Store in the PHIGS 3D API*Closed source software, software that is not distributed with source code...
, and so on.
Despite the name, CFML is not a markup language. It is also not SGML, since certain core CFML features prevent it from complying.
The CFML engine is configured in such a way that certain file extensions on the server (.cfm, .cfc) are handed off to the CFML engine for processing. In the case of the Java-based engines this is accomplished via Java servlets
Java Servlet
A servlet is a Java programming language class used to extend the capabilities of servers that host applications accessed via a request-response programming model. Although servlets can respond to any type of request, they are commonly used to extend the applications hosted by Web servers...
. The CFML engine only processes CFML tags and functions; it returns text outside of CFML tags and functions to the web server unchanged.
History
ColdFusion was originally created by the Allaire CorporationAllaire Corporation
Allaire Corporation was a computer software company founded by Jeremy and JJ Allaire in Minnesota, later headquartered in Cambridge, then Newton, Massachusetts...
, originally located in Minnesota but later moving to Cambridge, MA and finally Newton, MA. Allaire was acquired by Macromedia
Macromedia
Macromedia was an American graphics and web development software company headquartered in San Francisco, California that produced such products as Flash and Dreamweaver. Its rival, Adobe Systems, acquired Macromedia on December 3, 2005 and controls the line of Macromedia...
in 2001, thus Allaire Cold Fusion became Macromedia Cold Fusion (the space was removed from the product name with the release of ColdFusion version 4). Adobe acquired Macromedia in 2005 and is still actively developing ColdFusion.
In 1998 Alan Williamson and his Scottish company n-ary began creating a templating engine for Java to simplify common programming tasks. Williamson was using curly-brace notation instead of tags, but when he saw an example of CFML and how it was solving similar problems (although not in Java) using a tag syntax, he started developing what would eventually become BlueDragon, which was the first Java implementation of the CFML language. (ColdFusion was written in C and C++ until version 6.0--the first Java-based version of ColdFusion--was released in 2002.) New Atlanta licensed BlueDragon around 2001 and made it available as a commercial product, eventually creating a .NET implementation of CFML. Open BlueDragon is a fork of the commerical BlueDragon product and was first released in 2008.
The Railo CFML engine began as a student project in 2002 and was first launched as a commercial project in 2005. Railo announced they were making the engine open source in 2008, and the first open source version was released in 2009.
On June 18 2009, Adobe
Adobe Systems
Adobe Systems Incorporated is an American computer software company founded in 1982 and headquartered in San Jose, California, United States...
announced at the CFUnited conference that it had formed a CFML Advisory Committee that would be responsible for guiding and reviewing changes to the CFML language. This effort was disbanded in 2010. The Google Group CFML Conventional Wisdom was created as a forum for open, public discussions about language and engine features.
Syntax
CFML tags have a similar format to HTML tags. They are enclosed in angle brackets (< and >) and generally have zero or more named attributesAttribute (computing)
In computing, an attribute is a specification that defines a property of an object, element, or file. It may also refer to or set the specific value for a given instance of such....
, though some tags (e.g. cfset, cfif) contain an expression rather than attributes. Many CFML tags have bodies; that is, they have beginning and end tags with text to be processed between them. For example:
Other tags, such as cfset and cfftp, never have bodies; all the required information goes between the beginning (<) character and the ending (>) character in the form of tag attributes (name/value pairs), as in the example below. If it is legal for tags not to have a body, it is syntactically acceptable to leave them unclosed as in the first example, though many CFML developers choose to self-close tags as in the second example to (arguably) make the code more legible.
Even if the tag can have a body, including a body may not be necessary in some instances because the attributes specify all the required information. In these cases, as with the second example above, the end tag (and hence, the tag body) may be ommitted and the tag may be self-closing as in the following example:
Various tags offer the ability to type-check input parameters (e.g. cffunction, cfparam, cfqueryparam) if the programmer
Programmer
A programmer, computer programmer or coder is someone who writes computer software. The term computer programmer can refer to a specialist in one area of computer programming or to a generalist who writes code for many kinds of software. One who practices or professes a formal approach to...
declares their type specifically. This functionality is used with cfqueryparam to secure
Secure
Secure may refer to:* Security, being protected against danger or loss** Securitate , the secret service of Communist Romania* Security , e.g. secured loans...
web applications and databases from hackers and malicious web requests such as SQL injection
SQL injection
A SQL injection is often used to attack the security of a website by inputting SQL statements in a web form to get a badly designed website in order to dump the database content to the attacker. SQL injection is a code injection technique that exploits a security vulnerability in a website's software...
.
Built-in tags
Nearly 100 tags and many more functions make up the heart of the CFML language. The following lists CFML tags by their function or purpose.- Application framework
- Communications
- Control
- Flow-control
- Database manipulation
- Exception handlingException handlingException handling is a programming language construct or computer hardware mechanism designed to handle the occurrence of exceptions, special conditions that change the normal flow of program execution....
- Data output
- DebuggingDebuggingDebugging is a methodical process of finding and reducing the number of bugs, or defects, in a computer program or a piece of electronic hardware, thus making it behave as expected. Debugging tends to be harder when various subsystems are tightly coupled, as changes in one may cause bugs to emerge...
- Display management
- Extensibility
- File management
- formForm (web)A webform on a web page allows a user to enter data that is sent to a server for processing. Webforms resemble paper or database forms because internet users fill out the forms using checkboxes, radio buttons, or text fields...
- Internet protocolInternet ProtocolThe Internet Protocol is the principal communications protocol used for relaying datagrams across an internetwork using the Internet Protocol Suite...
- Page processing
- SecuritySecuritySecurity is the degree of protection against danger, damage, loss, and crime. Security as a form of protection are structures and processes that provide or improve security as a condition. The Institute for Security and Open Methodologies in the OSSTMM 3 defines security as "a form of protection...
- VariableVariable (programming)In computer programming, a variable is a symbolic name given to some known or unknown quantity or information, for the purpose of allowing the name to be used independently of the information it represents...
manipulation - Other tags (cfimage, cfregistry etc)
Custom tags
CFML allows language extensions in the form of custom tags, which are tags created by the developer that are not part of the CFML language itself. Custom tags are regular CFML files which are intended to be invoked as tags, although it is possible to treat a templateTemplate (programming)
Templates are a feature of the C++ programming language that allow functions and classes to operate with generic types. This allows a function or class to work on many different data types without being rewritten for each one....
as both a custom tag and a regular template. Custom tags are written in CFML and are typically invoked by prefixing the custom tag's file name with cf_, although there are other ways to invoke custom tags.
If a template is invoked as a custom tag, the attributes used to invoke that tag are available within the tag in a special attributes structure and the variables contained in the calling page are accessible via the caller structure.
For example, if writing an add tag which takes two attributes and adds them together, the sum.cfm page would look like this:
Assuming the template and tag are in the same directory, the tag can be invoked thus:
CFX tags are custom tags which are developed using Java or C++
C++
C++ is a statically typed, free-form, multi-paradigm, compiled, general-purpose programming language. It is regarded as an intermediate-level language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell...
, and are prefixed with cfx_ just like cf_. Java and C++ tags are added to the CFML runtime environment using the CFML engine's administrator or by editing configuration files.
On some CFML engines JSP
JavaServer Pages
JavaServer Pages is a Java technology that helps software developers serve dynamically generated web pages based on HTML, XML, or other document types...
tags can also be included in CFML pages using the
Functions
ColdFusion Markup Language includes a set of functions that you use to perform logical and arithmetic operations and manipulate data.function | code |
---|---|
Array | (ArraySort, ArrayAppend, ArrayDeleteAt...) |
Conversion | (URLEncodedFormat, ToString...) |
Date and time | (LsTimeFormat, DateAdd, DateDiff...) |
Decision | (IsDefined, IIF...) |
Display and formatting | (CJustify, NumberFormat...) |
Dynamic evaluation | (DE, Evaluate...) |
Extensibility | (CreateObject, ToScript...) |
Image Image An image is an artifact, for example a two-dimensional picture, that has a similar appearance to some subject—usually a physical object or a person.-Characteristics:... |
(ImageRotate, ImageAddBorder...) |
International functions | (SetLocale, GetTimeZoneInfo...) |
List | (FindOneOf, ListSetAt...) |
Mathematical | (Randomize, Sqr...) |
Other functions | (WriteOutput, GetBaseTemplatePath...) |
Query | (QueryAddColumn, QuerySetCell...) |
Security | (Encrypt, Decrypt...) |
String String (computer science) In formal languages, which are used in mathematical logic and theoretical computer science, a string is a finite sequence of symbols that are chosen from a set or alphabet.... |
(Reverse, HTMLCodeFormat...) |
Structure Structure Structure is a fundamental, tangible or intangible notion referring to the recognition, observation, nature, and permanence of patterns and relationships of entities. This notion may itself be an object, such as a built structure, or an attribute, such as the structure of society... |
(StructKeyExists, StructDelete...) |
System System System is a set of interacting or interdependent components forming an integrated whole.... |
(GetTickCount, GetTempFile...) |
XML XML Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards.... |
(XMLParse, GetSOAPResponse...) |
ColdFusion Components (CFCs)
CFCs provide some (not all) of the typical features and functionality that are provided by object-oriented (OOP) languages.To create a CFC:
- Create a file with a.CFC extension (this distinguishes CFCs from ColdFusion templates, which have a.CFM extension).
- Use four tags to create the components, define their functions and arguments, and return a value.
: Defines a CFC : Defines the functions (methods) within a CFC : Defines the arguments (parameters) that a function accepts : Returns a value or result from a function
CFCs are plain CFML. Within a CFC any CFML tag, function, custom tag, other components, etc. may be used.
CFCs can be used in various ways. If a method contained in a CFC simply needs to be invoked, the
CFCs are created using four tags, saved as.CFC files, and invoked using the
In the example below, component temperature.cfc has a method FtoC which converts temperature from Fahrenheit to Celsius. The test.cfm template invokes the method and converts 212 degrees Fahrenheit and outputs the result.
CFCs may also be instantiated as objects. Assuming a CFC file called Person.cfc, an instance of this CFC would be instantiated as follows:
CFCs also form the basis of the ability to create web services in CFML. A CFC is created in the usual way, and the attribute access="remote" added to any function within the CFC will make that function available to be called as a SOAP
SOAP
SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks...
-based web service. The CFML engine auto-generates a WSDL and creates all the necessary stubs for the web service to function.