Download Extending ColdFusion with CFX
Transcript
Introducing the CFX API Table 30.8 C++ Methods for Working with String Sets METHOD DESCRIPTION stringset->AddString(string) Adds a LPCSTR value to the string set. Most commonly, this method is used to add column names to a string set that will later be passed to pQuery->AddQuery(). Returns the index position of the string that was just added. stringset->GetCount() Returns the number of strings in the string set, as an int. If you call this method on the result of the GetAttributes() method, you get the number of attributes passed to the tag. If you call it on the result of GetColumns(), you get the number of columns in the query. stringset->GetString(index) Returns the string (as a LPCSTR) at the index position you specify. The first string is at position 1, the second string is at position 2, and so on. stringset->GetIndexForString(string) Returns the index position of the string you specify. The search is not case sensitive. If the string is not in the set, the constant CFX_STRING_NOT_FOUND (defined as -1 in cfx.h) is returned. Working with Exceptions and Debugging If anything goes wrong while your CFX tag is doing its work, you need a way to display a helpful error message in the ColdFusion page that is using the tag. To that end, the CFX API provides mechanisms for throwing exceptions that behave just like ColdFusion’s own exceptions, and just like exceptions thrown by <cfthrow> tag in normal ColdFusion code. In addition, methods are provided that allow your tag to include debug messages that will be included in the current Web page when ColdFusion’s debugging options are turned on. Table 30.9 shows the Java version of this part of the CFX API, and Table 30.10 shows the C++ version. Table 30.9 Java Methods for Exceptions and Debugging METHOD DESCRIPTION throw new Exception(message) Creates an exception (error message), which will be displayed in ColdFusion just like any other error message. This is similar conceptually to the <cfthrow> tag in CFML. If it wishes, the calling template can use <cftry> and <cfcatch> to handle the exception gracefully. This isn’t really part of the CFX API; it’s standard Java syntax. I’m including it in this table for consistency’s sake. 7