User Guide
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" } } ;