Chapter 18: Building Custom CFAPI Tags
287
•
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. This method will be used 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.
Once you have implemented a
main
method as described above, 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.
Debugging Classes Example
The following example demonstrates the use of the debugging classes.
import java.util.Hashtable ;
import com.allaire.cfx.* ;
public class OutputQuery implements CustomTag
{
// debugger testbed for OutputQuery
public static void main(String[] argv)
{
try
{
// initialize attributes
Hashtable attributes = new Hashtable() ;
attributes.put( "HEADER", "Yes" ) ;
attributes.put( "BORDER", "3" ) ;
// initialize query
String[] columns =
{ "FIRSTNAME", "LASTNAME", "TITLE" } ;
String[][] data = {
{ "Stephen", "Cheng", "Vice President" },
{ "Joe", "Berrey", "Intern" },
{ "Adam", "Lipinski", "Director" },
{ "Lynne", "Teague", "Developer" } } ;
Summary of Contents for COLDFUSION 4.5-DEVELOPING WEB
Page 1: ...Allaire Corporation Developing Web Applications with ColdFusion ColdFusion 4 5...
Page 14: ...xiv Developing Web Applications with ColdFusion...
Page 26: ...xxvi Developing Web Applications with ColdFusion...
Page 34: ...8 Developing Web Applications with ColdFusion...
Page 70: ...44 Developing Web Applications with ColdFusion...
Page 84: ...58 Developing Web Applications with ColdFusion...
Page 114: ...88 Developing Web Applications with ColdFusion...
Page 148: ...122 Developing Web Applications with ColdFusion...
Page 174: ...148 Developing Web Applications with ColdFusion...
Page 208: ...182 Developing Web Applications with ColdFusion...
Page 244: ...218 Developing Web Applications with ColdFusion...
Page 274: ...248 Developing Web Applications with ColdFusion...
Page 288: ...262 Developing Web Applications with ColdFusion...
Page 300: ...274 Developing Web Applications with ColdFusion...
Page 350: ...324 Developing Web Applications with ColdFusion...
Page 362: ...336 Developing Web Applications with ColdFusion...