User Guide

782 Chapter 5: ColdFusion Java CFX Reference
Response interface
public abstract interface Response
Interface to response generated from a custom tag. This interface includes methods for writing
output, generating queries, and setting variables in the calling page.
Methods
addQuery
Description
Adds a query to the calling template. The query can be accessed by CFML tags in the template.
After calling
addQuery, the query is empty (it has 0 rows). To populate the query with data, call
the Query member functions
addRow and setData.
Returns the Query that was added to the template.
Category
Response interface
Syntax
public Query addQuery(String name, String[] columns)
Throws
IllegalArgumentException
If the name parameter is not a valid CFML variable name.
See also
addRow
, setData
Parameters
Example
The following example adds a query named People to the calling template. The query has two
columns (FirstName and LastName) and two rows:
// Create string array with column names (also track columns indexes)
String[] columns = { "FirstName", "LastName" } ;
int iFirstName = 1, iLastName = 2 ;
// Create a query which contains these columns
Query query = response.addQuery( "People", columns ) ;
Returns Syntax Description
Query
addQuery(String name, String[] columns)
Adds a query to the calling template.
void
setVariable(String name, String value)
Sets a variable in the calling template.
void
write(String output)
Outputs text back to the user.
void
writeDebug(String output)
Writes text output into the debug stream.
Parameter Description
name The name of the query to add to the template
columns The column names to use in the query