Wednesday, April 9, 2008

Java Server Pages integration_12

ColdFusion MX is built on top of the same platform that runs JSP (or Java Server Pages). You

can, therefore, include JSP pages in your application, and you can share variables between

ColdFusion and JSP! We can set a Session variable, for example, in MyCFPage.cfm as follows:

<cfset Session.myvar = 1>

And we can then output it on MyJSPPage.jsp as follows:

<%= session.getAttribute("myvar") %>

This example may illustrate only the general principle behind sharing data between the two

platforms, but imagine the possibilities. For more information about integrating ColdFusion

with Java technologies.

Simplified locking_11

Because ColdFusion MX is now built on Java, you no longer need to worry about data corruption

in the shared memory scopes: Session, Application, and Server. Unfortunately, this fact has been misinterpreted by some to mean

"Hey—I don't need to lock my Session variables anymore!" Nothing can be farther from the

truth.

You still need to lock shared memory scopes to prevent what are known as race conditions,

where one piece of code may interfere with another that is also trying to access the same

data in shared memory. Race conditions are more prevalent than you may think; all in all,

you're most likely to continue to lock shared memory scopes almost as much as you did in

earlier versions of ColdFusion.

The new locking rules do enable you to safely read and write "write-once" variables in shared

memory scopes without locking. So if you have a Session variable that is created only once

during a session, is never destroyed and recreated, is never modified under any conditions

whatsoever, and is never CFSET a second time—even with the same value that it had previously—

you do not need to lock access to it.

Simplified Verity administration_10

Verity is the name of the company who invented the full-text search technology use by

ColdFusion MX, so full-text searching in ColdFusion is commonly referred to as "Verity

searching." A full-text search is what you perform on popular search sites like Google and

Yahoo, where you can search for a word or phrase, the search engine looks inside collections

containing billions of web pages for that word or phrase, and returns a weighted list of results

that most likely best fit what you're looking for.

Expansions to the Verity full-text search system have made managing a site that uses Verity

easier than ever. You can now obtain a list of all the Verity collections on your server (as well

as some extra metadata, such as where they are stored and whether they are K2 Server (a

high performance standalone Verity server) collections) by using the CFCOLLECTION tag, as

follows:

<cfcollection action="LIST" name="GetCollections">

ColdFusion MX offers new Verity-related functions and still more improvements over earlier

versions of ColdFusion.

Sandbox Security_9

Available only in the Enterprise version of ColdFusion MX (although Professional has a similar

feature, named Resource Security), Sandbox Security is a great feature for shared hosts or people

running a department with multiple applications, because it enables a site administrator

to restrict what resources the code on his server can access. The administrator can, for

example, restrict the code in one directory from accessing specific tags and datasources, and

he can restrict code in another directory from accessing a completely different set of tags and

datasources.

Simplified security_7

Does anyone remember Advanced Security? Does anyone want to suffer through that again?

ColdFusion MX makes security easier to manage in two ways: application security by using the

new CFLOGIN tag (and its related tags and functions) and the new J2EE-integrated Sandbox

Security. The following sections briefly describe these two methods of security.

Native XML handling_6

Finally, ColdFusion can handle XML! If you've never heard of it before, XML stands for

eXtensible Markup Language, and it provides a way to structure data and encode it with

additional information using a plain text format that can be used by most modern application

servers and applications. Previously, data interchange with XML was limited to one of the

following two options in ColdFusion:

Use WDDX as an interchange format: This was a good start, but it was limited because

you were locked in to a data-centric flavor of XML. (WDDX is explained in detail in

Chapter 30.)

Use a COM object or third-part custom tag library: Some good libraries were on the

market, but they still are no match for the capability to natively use XML and XML

objects.

Now, by using ColdFusion MX, all you need do to create an XML object is use the new CFXML

tag, as follows:

<cfxml variable="XmlObj">

<my-xml-tag>

<my-child-tag />

</my-xml-tag>

</cfxml>

And that's only the beginning of an impressive array of XML handling features; in fact, the

only feature missing from ColdFusion's XML implementation is the capability to validate

against a DTD or XMLSchema document, which can be easily remedied by using COM. For

more information about validating XML with ColdFusion MX, see Chapter 29.

ColdFusion MX also natively handles XSLT transformations, so you can transform structured

XML documents into virtually any type of content. MX's XPath capabilities enable you to

query an XML object and extract data structures that match search criteria.

After you parse an XML document into an XML object, you can refer to its data elements by

using the same ColdFusion syntax used for handling arrays and structures, so your learning

curve remains relatively small.

Web services_5

A Web service exposes a software component to remote systems in a platform-independent

manner, meaning that any application server platform capable of consuming web services

can make use of the web services created with ColdFusion MX. ColdFusion MX truly rang the

bell with its implementation of Web services: To create a Web service in MX, you simply set

the Access attribute of a ColdFusion component function to Remote. No, really!

You need to pay attention to a few details, of course, but creating a Web service is a natural

extension to ColdFusion's component functionality. Whenever a ColdFusion component is

accessed as a Web service, the remote consumer of the Web service receives the result in the

native format of the consumer's platform, so .NET consumers receive ColdFusion arrays as

.NET arrays, and Java consumers receive them as Java arrays.

Some incompatibilities do exist between certain ColdFusion complex data types and specific

consumer platforms, but these hurdles can be cleared by exchanging complex data as XML

documents that the consumer may then transform as needed.

One piece of advice: Learn Web services, XSLT transformations

, and how to validate XML documents against DTDs by using COM. These

skills may sound foreign to you now, but they're soon to be in very high demand, and we

want you there to provide the necessary solutions.

Flash Remoting services_4

For anyone who has succeeded in interfacing Flash movies with ColdFusion, MX's new Flash

Remoting Services are a true godsend. What used to require a good bit of knowledge in Flash

ActionScripting (the language of Flash), plus hours or days of laboring in Flash and ColdFusion

MX, now takes only a basic understanding of ActionScript and a few lines of code to link a

Flash movie with ColdFusion. If you're new to ColdFusion, you'll still be amazed at how easy

Flash Remoting makes creating Flash movies that use the functionality built into your

ColdFusion applications.

Where earlier versions of Flash were basically crude animation tools that could be forced into

exchanging data with ColdFusion, Flash Remoting turns the Flash MX authoring environment

into a true client-application development environment that is designed from the ground up

to work directly with ColdFusion MX. Flash MX applications communicate with ColdFusion by

using a new and very efficient binary format named AMF (Action Message Format), which is

not only faster but requires only a fraction of the bandwidth previously taken up by XMLbased

data exchanges.

Flash Remoting enables you to develop applications with truly interactive graphical user

interfaces. The best that you could do before Flash Remoting came along was to create an

overly complicated DHTML convolution that either cached data locally or made constant

page requests from ColdFusion each time that the user touched a form control.

Chapter 26 shows you how to create a basic Flash Remoting interface with interactive controls,

but it is not a comprehensive lesson. If you are interested in developing serious Flash

MX applications—and we hope that you are—you should also obtain the Flash MX Action

Script Bible, by Robert Reinhardt and Joey Lott (Wiley Publishing) and digest it thoroughly. I

recommend this book not because it comes from the same publisher as this one, but because

Robert Reinhardt and Joey Lott have done an excellent treatment of Flash MX that should not

be missed.

ColdFusion components_3

ColdFusion components, also known as CFCs, bring some object-like behavior to ColdFusion.

(For a basic understanding of objects, read "The Nickel Tour of Objects" in Chapter 22.)

In their simplest implementation, components are formal containers for interrelated functions

created by using CFFUNCTION. By encapsulating all functions related to a specific process or

entity in a single component, you take your first step toward thinking in terms of objects

rather than in terms of individual pieces of code.

Components can also be implemented as persistent objects that "live" between page requests

and contain both user-defined functions and properties (data). ColdFusion components are

not true objects, as you find in other languages such as Java or C++, but they do enable some

"object-like" capabilities, such as basic inheritance.

Powerful new functionality in ColdFusion MX, such as Web services and Flash Remoting, use

ColdFusion components as well.

Tag-based user defined functions_2

ColdFusion MX introduces a new CFFUNCTION tag for creating user-defined functions (UDFs)

containing CFML tags, which means that you can now declare your own functions that use

databases, external systems, or anything else accessible by the ColdFusion language.

Functions declared with CFFUNCTION are more formally structured than their CFSCRIPT UDF

counterparts. CFFUNCTION formally defines the data type that it returns as the result of the

function, and a new child tag—CFARGUMENT—formally defines the names and data types of

the arguments passed into the function, as well as whether those arguments are required or

optional.

The new CFINVOKE and CFINVOKEARGUMENT tags provide a new way to invoke user-defined

functions. Functions can now be invoked through a formally declared interface into the function's

arguments, and those arguments can now be declared as either required or optional.

An Overview of What’s New in ColdFusion MX _1

The MX release of ColdFusion is without doubt the most eagerly anticipated software release

in Macromedia's history. Everything—every single thing—has been completely rewritten

from the ground up, in Java. Not only that, but the ColdFusion software itself now runs on top

of JRun, Macromedia's J2EE server engine. You still write your ColdFusion applications in

CFML, but behind the scenes, ColdFusion Server translates your CFML into Java source code,

compiles it into Java bytecode, and then JRun kicks in and runs the compiled Java byte code.

This whole translation-and-compilation process is entirely transparent to you, but the performance

gains are very obvious in most cases.

Along with these changes in platform and architecture came big enhancements in the

ColdFusion language and some truly powerful new technologies, some of which change the

very way that you write ColdFusion applications from now on.