cfscript
377
You cannot use the
elseif
construct within a
cfscript
tag. You can use code such as the
following:
else if ( condition )
{
...
}
Exception handling with the cfscript tag
To handle exceptions with this tag, use
try
and
catch
statements, which are equivalent to the
cftry
and
cfcatch
tags. For each
try
statement, you must have a
catch
statement. In the
catch
block, the variable
exceptionVariable
contains the exception type. This variable is the
equivalent of the
cfcatch
tag built-in variable
cfcatch.Type
. For more information, see
Chapter 6, “Extending ColdFusion Pages with CFML Scripting” in
ColdFusion MX Developer’s
Guide
.
Invoking ColdFusion components with the cfscript tag
CFScript invokes component methods using the
CreateObject
function.
The following example shows how to invoke a component object with the
cfscript
tag, using
ordered arguments:
<cfscript>
quote = CreateObject( "component", "nasdaq.quote" ) ;
<!--- Invocation using ordered arguments. --->
res = quote.getLastTradePrice( "macr" ) ;
</cfscript>
The following example shows how to use an attribute collection within the
cfscript
tag to pass
parameters when invoking a component object. An attribute collection is a structure in which
each key corresponds to a parameter name and each value is the parameter value passed for the
corresponding key.
<cfscript>
stArgs = structNew();
stArgs.translationmode = "en_es";
stArgs.sourceData= "Hello world, friend";
</cfscript>
...
<cfinvoke
webservice = "http://www.xmethods.net/sd/2001/BabelFishService.wsdl"
method = "BabelFish"
argumentCollection = "#stArgs#"
returnVariable = "varName">
<cfoutput>#varName#</cfoutput>
In this example, the structure is created in a
cfscript
block, but you can use any ColdFusion
method to create the structure.
Содержание COLFUSION MX 7 - INSTALLING AND USING COLDFUSION MX
Страница 1: ...COLDFUSION MX7 CFML Reference...
Страница 20: ...20 Chapter 1 Reserved Words and Variables...
Страница 50: ...50 Chapter 2 ColdFusion Tags cfelse br Searching cfif cfloop cfif...
Страница 101: ...cfdefaultcase 101 cfdefaultcase cfswitch cfoutput Your grade is grade cfoutput...
Страница 115: ...cfdocumentsection 115 cfdocumentsection cfoutput cfdocument...
Страница 311: ...cfNTauthenticate 311 Please Try again H2 cfif cfoutput cfinclude template loginform cfm cfabort cfif cfif cflogin...
Страница 411: ...cftable 411 cftable body html...
Страница 515: ...Chr 515 maxlength 5 p input type Submit name input type RESET cfform...
Страница 605: ...GetEncoding 605 WriteOutput The encoding is theEncoding cfscript cfif...
Страница 629: ...GetProfileString 629 tr td input type Submit name Submit value Submit td td td tr table form...
Страница 655: ...IIf 655 cfoutput IIf Hour Now GTE 12 DE It is afternoon or evening DE It is morning cfoutput b...
Страница 664: ...664 Chapter 3 ColdFusion Functions cfelse h3 Conversion error h3 cfif...
Страница 687: ...IsStruct 687 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Страница 693: ...IsWDDX 693 struct data wddxPacket hr xmp cfoutput packet xmp IsWDDX returns IsWDDX packet br cfoutput...
Страница 751: ...LSDateFormat 751 hr noshade cfoutput cfloop...
Страница 861: ...StructFind 861 cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Страница 869: ...StructIsEmpty 869 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...
Страница 903: ...Val 903 value Is the beginning numeric name form...
Страница 932: ...932 Chapter 3 ColdFusion Functions...
Страница 944: ...944 Chapter 4 ColdFusion MX Flash Form Style Reference...
Страница 962: ...962 Chapter 5 Application CFC Reference...
Страница 1008: ...1008 Chapter 6 ColdFusion MX Event Gateway Reference cfset retValue Reason reason cfreturn retValue cffunction...
Страница 1054: ...1054 Chapter 6 ColdFusion MX Event Gateway Reference...