
725
DEVELOPING
COLDFUSION 9 APPLICATIONS
Requesting and Presenting Information
Las
t
upda
te
d 8/5/2010
Because the controls use JavaScript to return data to ColdFusion, if you disable JavaScript in your browser, it cannot
properly run forms that contain these controls. In that case, the controls still display, but data return and validation
does not work and you can receive a JavaScript error.
Because Java is handled by the plug-in and not directly by the browser, disabling Java execution in the browser does
not affect the operation of the controls. If for some other reason, however, the browser is unable to render the controls
as requested, a "not supported" message appears in place of the control.
You can use the
cfform
tag’s
notsupported
attribute to specify an alternative error message.
You can avoid browser Java and JavaScript issues with the
cfgrid
and
cftree
controls by using the Flash format
versions of these controls. These controls work on Windows, Mac OS X, and Linux, and do not rely on Java support.
There is no Flash version of the
cfslider
control, and there is no applet version of the
cfcalendar
control.
Building tree controls with the cftree tag
The
cftree
tag lets you display hierarchical information within a form in a space-saving collapsible tree populated
from data source queries. To build a tree control with the
cftree
tag, you use individual
cftreeitem
tags to populate
the control.
You can create trees in three formats:
Applet
Creates a Java applet that the client must download. Downloading an applet takes time; therefore, using the
cftree
tag can be slightly slower than using an HTML form element to retrieve the same information. In addition,
browsers must be Java-enabled for the
cftree
tag to work properly.
Flash
Generates a Flash control that you can include in an HTML or Flash form. For more information on Flash
Forms see “
Creating Forms in Flash
” on page 765.
Object
Creates a hierarchical ColdFusion structure that represents the tree data and many of the
cftree
and
cftreeitem
attributes.
The different formats support different sets of features and attributes. The information here discusses general
techniques that apply to all three formats, and indicates any techniques that do not apply to a specific format. It uses
applet format for all examples, which use applet-specific attributes. For details on the features and attributes supported
in each format, see the
cftree
entry in the
CFML Reference
.
Create and populate a tree control from a query
1
Create a ColdFusion page with the following content:
<cfquery name="engquery" datasource="cfdocexamples">
SELECT FirstName || ' ' || LastName AS FullName
FROM Employee
</cfquery>
<cfform name="form1" action="submit.cfm">
<cftree name="tree1"
required="Yes"
hscroll="No">
<cftreeitem value="FullName"
query="engquery"
queryasroot="Yes"
img="folder,document">
</cftree>
</cfform>
2
Save the page as tree1.cfm and view it in your browser.