User Guide
Approaches to Debugging Java CFXs 399
If you need to debug a Java CFX while running against a live production server, this is
the technique you must use. In addition to outputting debug text using the
Response.write method, you can also call your Java CFX tag with the debug="On"
attribute. This attribute flags the CFX that the request is running in debug mode and
therefore should output additional extended debug information. For example, to call
the
HelloColdFusion CFX in debug mode, use the following CFML code:
<cfx_HelloColdFusion" name="Robert" debug="On">
To determine whether a CFX is invoked with the debug attribute, use the
Request.debug method. To write debug output in a special debug block after the tag
finishes executing, use the
Response.writeDebug method. For details on using these
methods, see the CFML Reference.
Using the debugging classes
To develop and debug Java CFXs in isolation from the ColdFusion Server, you use
three special debugging classes that are included in the
com.allaire.cfx package.
These classes enable you to simulate a call to the
processRequest method of your
CFX within the context of the interactive debugger of a Java development
environment. The three debugging classes are:
•
DebugRequest An implementation of the Request interface that enables you to
initialize the request with custom attributes, settings, and a query.
•
DebugResponse An implementation of the Response interface that enables you
to print the results of a request once it has completed.
•
DebugQuery An implementation of the Query interface that enables you to
initialize a query with a name, columns, and a data set.
To use the debugging classes:
1 Create a main method for your Java CFX class. You use this method as the testbed
for your CFX.
2Within the main method, initialize a DebugRequest and DebugResponse, and a
DebugQuery if appropriate, with the attributes and data you want to use for your
test.
3 Create an instance of your Java CFX and call its processRequest method, passing
in the
DebugRequest and DebugResponse objects.
4 Call the
DebugResponse.printResults method to output the results of the
request, including content generated, variables set, queries created, and so forth.
After you implement a main method as described previously, you can debug your
Java CFX using an interactive, single-step debugger. Just specify your Java CFX class
as the main class, set breakpoints as appropriate, and begin debugging.