User Guide

396 Chapter 21 Building Custom CFXAPI Tags
The default value is reload="Auto". This is appropriate for most applications. Use
reload="Always" during the development process when you must ensure that you
always have the latest class files, even when only a dependent class changed. Use
reload="Never" to increase performance by omitting the check for changed classes.
Note
The reload attribute applies only to class files located in the classes directory. The
ColdFusion server loads classes located on the Java class path once per server
lifetime. You must stop and restart ColdFusion Server to reload these classes. For
information on loading Java class files, see The class loading mechanism on page
384.
Life cycle of Java CFXs
A new instance of the Java CFX object is created for each invocation of the Java CFX
tag. This means that it is safe to store per-request instance data within the members
of your
CustomTag object. To store data and/or objects that are accessible to all
instances of your
CustomTag, use static data members. If you do so, you must
ensure that all accesses to the data are thread-safe.
Calling the CFX from a ColdFusion page
You call Java CFXs from within ColdFusion pages by using the name of the CFX that
is registered on the ColdFusion Administrator CFX tags page. This name should be
the prefix
cfx_ followed by the class name (without the .class extension). The
following CFML page calls the
HelloColdFusion custom tag:
<html>
<body>
<cfx_HelloColdFusion NAME="Les">
</body>
</html>
To test the CFX:
1 Create a new source file in your editor and enter the preceding CFML code.
2 Save the file in a directory configured to serve ColdFusion pages. For example,
you can save the file as C:\inetpub\wwwroot\cfdocs\testjavacfx.cfm on Windows
NT or /home/docroot/cfdocs/testjavacfx.cfm on UNIX.
3 If you have not already done so, register the CFS in the ColdFusion
Administrator, as described in Registering CFXs on page 404.
4 Request the page from your Web browser using the appropriate URL; for
example:
http://localhost/cfdocs/testjavacfx.cfm