Adobe ColdFusion 8

setVariable

Description

Sets a variable in the calling template. If the variable name specified exists in the template, its value is replaced. If it does not exist, a new variable is created.

Category

Response interface

Syntax

public void setVariable(String name, String value)

Throws

IllegalArgumentException If the name parameter is not a valid CFML variable name.

Parameters

Parameter

Description

name

The name of the variable to set

value

The value to set the variable to

Example

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" ) ;
    }