User Guide

322 Developing Web Applications with ColdFusion
Sets a variable in the calling template. If the variable name specified already exists
in the template then its value is replaced. If it does not already exist then a new
variable is created.
For example, this code sets the value of a variable named ’MessageSent’ based on
the success of an operation performed by the custom tag:
boolean bMessageSent ;
...attempt to send the message...
if ( bMessageSent == true )
{
response.setVariable( "MessageSent", "Yes" ) ;
}
else
{
response.setVariable( "MessageSent", "No" ) ;
}
Parameters:
name — The name of the variable to set
value — The value to set variable to
Throws:
IllegalArgumentException — If the name parameter is not a valid CFML
variable name
addQuery
public Query addQuery(String name,
String[] columns)
throws IllegalArgumentException
Adds a query to the calling template. This query can then be accessed by CFML
tags within the template. Note that after calling addQuery the query exists but is
empty (i.e. it has 0 rows). To populate the query with data you should call the
Query member functions addRow and setData.
The following example adds a Query named 'People' to the calling template. The
query has two columns ('FirstName' and 'LastName') and 2 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 ) ;
// Add data to the query
int iRow = query.addRow() ;