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() ;
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...