
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.
2
Within 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.
Содержание COLDFUSION 5-DEVELOPING
Страница 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Страница 58: ...38 Chapter 3 Querying a Database ...
Страница 134: ...114 Chapter 7 Updating Your Database ...
Страница 210: ...190 Chapter 10 Reusing Code ...
Страница 232: ...212 Chapter 11 Preventing and Handling Errors ...
Страница 238: ...218 Chapter 12 Using the Application Framework ...
Страница 262: ...242 Chapter 12 Using the Application Framework ...
Страница 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Страница 320: ...300 Chapter 15 Indexing and Searching Data ...
Страница 336: ...316 Chapter 16 Sending and Receiving E mail ...
Страница 374: ...354 Chapter 18 Interacting with Remote Servers ...