ColdFusion MX - Villanova University

download report

Transcript ColdFusion MX - Villanova University

ColdFusion MX
Rob Filardo and Lindsay Matteo
A Brief History
ColdFusion 1.0 was created in 1995 by Adam Berrey in order to help
HTML programmers create database-oriented web applications
Database connectivity established through a tag-based script called
Database Markup Language (DBML)
Version 1.5 was a dramatic improvement. Among other things, it
included email integration and C++ compatibility to allow for coding
Early on, ColdFusion faced competition from Microsoft, which was
developing the technology that would lead to ASP
Version 2.0 included such advances as 150 new functions, looping,
variables, typeless expression evaluation, and a number of other
language enhancements.
ColdFusion 3.1 offered greater support for Windows NT and Sun Solaris
systems, and also featured automated page generation and tag
completion. It also included enhanced security and a new multithreading service.
Now, ColdFusion applications can even be deployed on J2EE servers
About ColdFusion MX
• ColdFusion MX is a rapid scripting environment server for
creating dynamic Internet Applications. It enables developers
to easily build and deploy things such as dynamic websites,
self-service applications, and commerce sites.
• ColdFusion Markup Language (CFML) is a tag-based language,
similar to HTML, that uses special tags and functions.
• CFML looks similar to HTML--it includes starting and, in most
cases, ending tags, and each tag is enclosed in angle brackets.
All ending tags are preceded with a forward slash (/) and all
tag names are preceded with cf; for example:
<cftagname> tag body text and CFML</cftagname>
• CFML provides a layer of abstraction that hides many low-level
details involved with Internet application programming. It lets
you easily build applications that integrate files, databases,
legacy systems, mail servers, FTP servers, objects, and
ColdFusion Components
• CFML also includes a built-in scripting language, CFScript, that
lets you write code in a manner that is familiar to
programmers and JavaScript writers.
• You can extend CFML further by creating custom tags or userdefined functions (UDFs), or by integrating COM, C++, and
Java components (such as JSP tag libraries).
• You can also create ColdFusion components (CFCs), which
encapsulate related functions and properties and provide a
consistent interface for accessing them.
CFML Basics
• Functions - can use built in functions or define your own.
Used to manipulate data and return a result.
• Expressions
• Variables and constants
• Flow-control constructs such as if-then and loops. CFML is an
imperative language.
• CFML control tags are very similar to Java control words: cfif,
cfelse, cfelseif, cfswitch, cfbreak, cfcase, cfloop…recognize any
of those?
• The cf loop tag provides five types of loops: index (kind of like
a “for” loop), conditional, query (runs through loop once for
each row in a query), list (runs through loop once for each
entry in a list – perhaps like an iterator), and collection.
CFML Oddities
CFML is case insensitive
CFML is typeless – you do not specify variable data types. Although,
CFML data falls into the following categories: simple (boolean values,
numbers, strings, etc.), complex (arrays, structures, queries), binary
(such as the contents of a .gif file), object (like Java, CORBA or
ColdFusion component objects)
• CFML has a language within it! CFScript is a scripting language
that is similar to JavaScript but is simpler to use. Also, unlike
JavaScript, CFScript only runs on the ColdFusion server; it
does not run on the client system.
• Java now has interfaces for building ColdFusion custom CFX’s
in Java! Interfaces such as the Query interface allows the
user to iterate through query rows and columns.
How ColdFusion Pages are Processed
Common CFML Tags
Establishes a connection to a database (if one does
not exist), executes a query, and returns results to
the ColdFusion environment.
Displays output that can contain the results of
processing ColdFusion functions, variables, and
Sets the value of a ColdFusion variable.
Converts application data or query results into
graphs, such as bar charts or pie charts, in Flash,
JPG, or PNG format
Invokes objects written in other programming
languages, including Java objects such as Enterprise
JavaBeans or Common CORBA objects
Lets an application send SMTP mail messages using
application variables, query results, or server files.
(Another tag, cfpop, gets mail.)
There are CFML tags built in for…
Manipulating variables
Creating interactive forms
Accessing and manipulating databases
Displaying data
Controlling the flow of execution on the ColdFusion
Handling errors
Processing ColdFusion pages
Managing the CFML application framework
Manipulating files and directories
Using external tools and objects, including Verity
collections, COM, Java, and CORBA objects, and
executable programs
Custom Tags
• ColdFusion lets you create custom tags. You can create two
types of custom tags:
1. CFML custom tags that are ColdFusion pages
2. CFX tags that you write in a programing language such
as Java or C++
• Custom tags can encapsulate frequently used code. These tags
enable you to place this code in one place and call it from
many places.
• Custom tags also let you abstract complex logic into a single,
simple interface.
CF Application Example – Top
The top portion of the application has two text form fields. The
“Name” field accepts a name up to 20 characters long, while the “Zip
Code” field checks to see if integers are entered in a zip code pattern.
Both of these forms are required, and a popup notification appears
when information has not been entered.
CF Application Example – Middle
The center portion of the application comes into view once the submit
button has been pressed.
The form variables that were entered in the text fields are printed, as
shown in the upcoming code.
CF Application Example – Bottom
The bottom of the application displays the contents of a database
containing all of the previous entries of the form.
The buttons remove and show the custom tag contents to the
Above is what the custom tag
template looks like on its own.
On the right is what the
application looks like without the
code calling the Coldfusion custom