This document lists new and changed functions/tags in Adobe ColdFusion (2016 release).
New functions
The following is a list of new functions in Adobe ColdFusion (2016 release):
ArrayContainsNoCase
ArrayDeleteNoCase
1
BooleanFormat
Floor
IsPDFArchive
QuerySort
QueryEach
QueryFilter
QueryKeyExists
QueryMap
QueryReduce
ReplaceListNoCase
SpreadsheetGetColumnCount
ValueArray
SpreadsheetAddRows
There is a new parameter, includeColumnNames, in this function. For more information, see SpreadsheetAddRows
function description and examples.
ReplaceList
There is a new parameter, includeEmptyFields, in this function. For more information, see ReplaceList function
description and examples.
Last updated 2/17/2016
cfapplication
There are two new attributes in the <cfapplication> tag:
1 passArrayByReference
2 searchImplicitScopes
For more information, see cfapplication .
cfsearch
The verity types, simple, explicit, internet, internet_basic, and natural no longer exist. There are two new verity types,
Standard and DisMax, in the tag. For more information, see
cfsearch .
cfloop
There is a new attribute, item, in <cfloop>. The attribute, index, is now optional.
For more information, see cfloop .
cfmailparam
There is a new, optional attribute, filename, in cfmailparam.
2
For more information, see cfmailparam .
cfoutput
There is a new, optional attribute, encodefor in this tag.
For more information, see cfoutput .
cfpdf
In Adobe ColdFusion (2016 release), you can use two additional 256-bit encryption algorithms when protecting a PDF
document. The algorithms are:
The TimeFormat function has new masks to represent time zones in different formats. For more information, see
Time For mat function description and examples.
Last updated 2/17/2016
DateFormat
The DateFormat function has new masks to represent time zones in different formats. For more information, see
DateFormat function description and examples.
Replace
The Replace function has an updated description and syntax. This function can take either string or callback function
as an argument instead of the argument to replace the string. For more information, see
Replace function description.
StructNew
The function has a new parameter, structType, that represents the type of struct to be created.
For more information, see StructNew .
WriteOutput
The function, WriteOutput, has a new parameter, encodefor. encodefor applies encoding on the input string.
For more information, see Wri te O ut pu t .
3
Elements of CFML
The basic elements of CFML, including tags, functions, constants, variables, expressions, and CFScript, make it a
powerful tool for developing interactive web applications.
CFML Basics
Comments
Ta gs
Functions
ColdFusion components
Constants
Va ri a bl e s
Expressions
Data types
Flow control
Character case
Special characters
Reserved words in ColdFusion
cfscript tag
Last updated 2/17/2016
Elvis operator
4
Using Arrays and Structures
Adobe ColdFusion supports dynamic multidimensional arrays. Using arrays can enhance your ColdFusion application
code. Adobe ColdFusion also supports structures for managing lists of key-value pairs. Because structures can contain
ot her str uct ures or compl ex d ata typ es a s it values , th ey p rovid e a fl exi ble and pow erf ul t ool for manag ing compl ex d ata .
About arrays
Basic array techniques
Populating arrays with data
Array functions-Developing guide
About structures
Creating and using structures
Structure examples
Structure functions - Developing guide
Last updated 2/17/2016
Chapter 2: Reserved Words and Variables
Reserved Words and Variables
Adobe ColdFusion language includes reserved words and scope variables.
Reserved words
Scope-specific built-in variables
Custom tag variables
ColdFusion tag-specific variables
CGI environment (CGI Scope) variables
6
Scope-specific built-in variables
ColdFusion returns variables, such as those returned in a cfdirectory or cfftp operation. A variable is usually referenced
by scoping it according to its type: naming it according to the code context in which it is available; for example,
Session.varname, or Application.varname. For more information on ColdFusion scopes, see Using ColdFusion
Variables in the Developing ColdFusion Applications You use the cflock tag to limit the scope of CFML constructs
that modify shared data structures, files, and CFXs, to ensure that modifications occur sequentially. For more
information, see cflock , and Using Persistent Data and Locking in the Developing ColdFusion Applications.
See also
• Var iab l e sc o pe
• Caller scope
• CGI variables
• Client variables
• Server variables
• Application and session variables
Last updated 2/17/2016
Custom tag variables
A ColdFusion custom tag returns the following variables:
A custom tag can set a Caller variable to provide information to the caller. Set the Caller variable as follows:
<cfset Caller.variable_name = "value">
The calling page can access the variable with the cfoutput tag, as follows:
7
<cfoutput>#variable_name#</cfoutput>
See also
• Request variable
• Form variable
ColdFusion tag-specific variables
Some ColdFusion tags return data as variables. For example, the cffile tag returns file size information in the FileSize
variable, referenced as CFFILE.FileSize. The following tags return data that you can reference in variables:
When a browser makes a request to a server, the web server and the browser create environment variables. In
ColdFusion, these variables are referred to as CGI environment variables. CGI Environment variables contain data
about the transaction between the browser and the server, such as the IP Address, browser type, and authenticated
username. The available CGI variables depend on the browser and server software. The CGI variables are available to
ColdFusion pages in the CGI scope. They take the CGI prefix regardless of whether the server uses a server API or CGI
to communicate with the ColdFusion server. You can reference CGI environment variables for a given page request
anywhere in the page. CGI variables are read-only. By default, when you use the cfdump tag to display the CGI scope,
or when you request debug output of the CGI scope, ColdFusion attempts to display a fixed list of standard CGI
environment variables. Because the available variables depend on the server, browser, and the types of interactions
between the two, not all variables are normally available. They are represented by empty strings in the debug output.
You can request any CGI variable in your application code, including variables that are not in the list variables displayed
by dump and debug output. ColdFusion checks for the following variables for the cfdump tag and debug output:
The following sections describe how to test for CGI environment variables and provide information on some of the
more commonly used CGI environment variables
Test i ng f o r C G I v a r ia b les
CGI server variables
CGI client variables
CGI client certificate variables
9
Last updated 2/17/2016
Chapter 3: ColdFusion Tags
ColdFusion Tags
ColdFusion Markup Language (CFML) includes a set of tags that you use in ColdFusion pages to interact with
data sources, manipulate data, and display output. CFML tag syntax is similar to HTML element syntax.
Tags in ColdFusion 10
Tag summary
Tags by function
Tag changes since ColdFusion 5
Tags a-b
10
Tags c
Tags d-e
Tags f
Tags g-h
Tags i
Tags j-l
Tags m-o
Tags p-q
Tags r-s
Tags t
Tags u-z
Last updated 2/17/2016
Tags in ColdFusion 10
The following table briefly describes CFML tags added in ColdFusion 10:
CFML tagCategoryDescription
11
cfexchangeconversationCommunications tagsHelps users organize and manage
cfexchangefolderCommunications tagsAllows you to perform various actions on the
cfwebsocketWeb Socket tagsLets you create the WebSocket object in your
conversations from a Microsoft Exchange
account.
mail folder, such as get folder information,
find folders, or create, copy, modify, move,
delete, and empty the contents of a folder.
CFM template. The tag creates a reference to
the WebSocket JavaScript object at the clientside.
Tag summary
The following table briefly describes CFML tags:
CFML tagCategoryDescription
cfabortFlow-control tagsStops the processing of a ColdFusion page at
cfajaximportInternet protocol tagsControls importation of JavaScript files used
cfajaxproxyInternet protocol tagsGenerates an AJAX proxy class on the client
the tag location
for ColdFusion AJAX-based features
page for a ColdFusion component
cfappletForms tagsEmbeds Java applets in a cfform tag
cfapplicationApplication framework tagsDefines an application name; activates client
cfargumentExtensibility tagsCreates a parameter definition within a
cfswitchFlow-control tagsEvaluates passed expre ssion; passes control to
cftableData output tagsBuilds a table in a ColdFusion page
cftextareaForms tagsPuts a multiline text box in a form
cfthreadApplication framework tagsCreates and manages ColdFusion threads,
cfthrowException handling tags , Flow-control tagsThrows a developer-specified exception
cftimerDebugging tagsDisplays execution time for a block of code
cftooltipDisplay management tagsSpecifies text to display when the mouse
cftraceDebugging tagsDisplays and logs application debugging data
cftransactionDatabase manipulation tagsGroups cfquery operations into one
cftreeForms tags Creates tree control element; used in cfform
cftreeitemForms tagsPopulates a tree control element in a form;
cftryException handling tags , Flow-control tagsCatches exceptions in ColdFusion pages
cfupdateDatabase manipulation tagsUpdates rows in a database data source
identifies a stored procedure to execute
matching cfcase tag
independent streams of execution.
pointer hovers over the tag body elements
transaction; performs rollback processing
used with cftree
cfwebsocketWeb Socket tagsLets you create the WebSocket object in your
cfwddxExtensibility tagsSerializes and deserializes CFML data
cfwindowDisplay management tagsCreates a pop-up window in the browser
cfxmlExtensibility tagsCreates an XML document object
cfzipFile management tagsManipulates ZIP and JAR files
cfzipparamFile management tagsManipulates ZIP and JAR files
CFM template. The tag creates a reference to
the WebSocket JavaScript object at the clientside.
structures to XML-based WDDX format
Tags by function
This section lists tags by their function or purpose.
Application framework tags
Communications tags
Database manipulation tags
Data output tags
Last updated 2/17/2016
Debugging tags
Display management tags
Exception handling tags
Extensibility tags
File management tags
Flow-control tags
Forms tags
Internet protocol tags
Page processing tags
Security tags
Variable manipulation tags
Web S oc k et t ag s
Other tags
18
Last updated 2/17/2016
Tag changes since ColdFusion 5
The following section lists tags, attributes, and values that have changed since ColdFusion 5, and indicate the specific
release in which the change was made.
New tags, attributes, and values
Deprecated tags, attributes, and values
Obsolete tags, attributes, and values
Tags a-b
This section lists tags starting with alphabets A-B with their description.
19
cfabort
cfajaximport
cfajaxproxy
cfapplet
cfapplication
cfargument
cfassociate
cfauthenticate
cfbreak
Last updated 2/17/2016
Tags r-s
This section lists tags starting with alphabets R-S with their description.
cfregistry
cfreport
cfreportparam
cfrethrow
cfreturn
cfsavecontent
cfschedule
cfscript
cfsearch
cfselect
cfservlet
20
cfservletparam
cfset
cfsetting
cfsharepoint
cfsilent
cfslider
cfspreadsheet
cfsprydataset
cfstoredproc
cfswitch
Last updated 2/17/2016
Tags t
21
This section lists tags starting with alphabet T with their description.
cftable
cftextarea
cftextinput
cfthread
cfthrow
cftimer
cftooltip
cftrace
cftransaction
cftree
cftreeitem
cftry
Last updated 2/17/2016
Tags u-z
This section lists tags starting with alphabets U-Z with their description.
cfupdate
cfwddx
cfwebsocket
cfwindow
cfxml
22
cfzip
cfzipparam
Tags m-o
This section lists tags starting with alphabets M-O with their description.
cfmail
cfmailparam
cfmailpart
cfmap
cfmapitem
cfmediaplayer
cfmenu
Last updated 2/17/2016
cfmenuitem
cfmessagebox
cfmodule
cfNTauthenticate
cfoauth
cfobject
cfobject: .NET object
cfobject: COM object
cfobject: component object
cfobject: CORBA object
cfobject: Java or EJB object
cfobject: web service object
cfobjectcache
cfoutput
23
Last updated 2/17/2016
Tags g-h
This section lists tags starting with alphabets G-H with their description.
cfgraph
cfgraphdata
cfgrid
cfgridcolumn
cfgridrow
cfgridupdate
cfheader
cfhtmlhead
cfhtmltopdf
24
cfhtmltopdfitem
cfhttp
cfhttpparam
Tags f
This section lists tags starting with alphabet F with their description.
cffeed
Last updated 2/17/2016
cffile
cffile action = "append"
cffile action = "copy"
cffile action = "delete"
cffile action = "move"
cffile action = "read"
cffile action = "readBinary"
cffile action = "rename"
cffile action = "upload"
cffile action = "uploadAll"
cffile action = "write"
cffileupload
cffinally
cfflush
25
cfformgroup
cfformitem
cfftp
cfftp: Opening and closing FTP server connections
cfftp: Opening and closing secure FTP server connections
cfftp: Connection: file and directory operations
cfftp action = "listDir"
cfform
cffunction
Last updated 2/17/2016
26
Tags d-e
This section lists tags starting with alphabets D-E with their description.
cfdbinfo
cfdefaultcase
cfdirectory
cfdiv
cfdocument
cfdocumentitem
cfdocumentsection
cfdump
cfelse
cfelseif
cferror
cfexchangecalendar
cfexchangeconnection
cfexchangecontact
cfexchangeconversation
cfexchangefilter
cfexchangefolder
Last updated 2/17/2016
cfexchangemail
cfexchangetask
cfexecute
cfexit
27
Tags p-q
This section lists tags starting with alphabets P-Q with their description.
cfparam
cfpdf
cfpdfform
cfpdfformparam
cfpdfparam
Last updated 2/17/2016
cfpdfsubform
cfpod
cfpop
cfpresentation
cfpresentationslide
cfpresenter
cfprint
cfprocessingdirective
cfprocparam
cfprocresult
cfprogressbar
cfproperty
cfquery
cfqueryparam
28
Last updated 2/17/2016
Tags j-l
This section lists tags starting with alphabets J-L with their description.
cflayout
cflayoutarea
cfldap
cflocation
cflock
cflog
cflogin
cfloginuser
cflogout
cfloop
cfloop: index loop
29
cfloop: conditional loop
cfloop: looping over a date or time range
cfloop: looping over a query
cfloop: looping over a list, a file, or an array
cfloop: looping over a COM collection or structure
Last updated 2/17/2016
Tags i
This section lists tags starting with alphabet I with their description.
cfif
cfimage
cfimap
cfimapfilter
cfimpersonate
cfimport
cfinclude
cfindex
cfinput
30
cfinsert
cfinterface
cfinvoke
cfinvokeargument
Last updated 2/17/2016
Tags c
This section lists tags starting with alphabet C with their description.
cfcache
cfcalendar
cfcase
cfcatch
cfchart
cfchartdata
cfchartseries
cfcol
cfcollection
cfcomponent
cfcontent
31
cfcontinue
cfcookie
cfclient
cfclientsettings
Last updated 2/17/2016
32
Chapter 4: Co
ldFusion Functions
ColdFusion Functions
The following list shows the ColdFusion Markup Language (CFML) functions. New Functions in
The following section list functions by their category or purpose.
Array functions
Cache functions
Conversion functions
Date and time functions
Data output functions
Debugging functions
Decision functions
Display and formatting functions
Dynamic evaluation functions
Exception handling functions
Extensibility functions
Flow control functions
Full-text search functions
Image functions
International functions
List functions
Mathematical functions
Microsoft Office integration functions
ORM functions
Last updated 2/17/2016
Other functions
Query functions
Security functions
Spreadsheet functions
String functions
Structure functions
System functions
Tran s action funct i o ns
XML functions
Mobile Functions
34
Last updated 2/17/2016
Function changes since ColdFusion 5
The tables in the sub-section lists functions, parameters and values that have changed since ColdFusion 5 and indicate
the specific release in which the change was made.
New functions, parameters, and values
Deprecated functions, parameters, and values
Obsolete functions, parameters, and values
35
Functions a-b
Abs
ACos
AddSOAPRequestHeader
AddSOAPResponseHeader
AjaxLink
AjaxOnLoad
ApplicationStop
ArrayAppend
ArrayAvg
ArrayClear
ArrayContains
ArrayDelete
ArrayDeleteAt
ArrayDeleteNoCase
ArrayEach
Last updated 2/17/2016
ArrayFilter
ArrayFind
ArrayFindAll
ArrayFindAllNoCase
ArrayFindNoCase
ArrayInsertAt
ArrayIsDefined
ArrayIsEmpty
arrayLen
ArrayMap
ArrayMax
ArrayMin
ArrayNew
ArrayPrepend
36
ArrayReduce
ArrayResize
ArraySet
ArraySlice
ArraySort
ArraySum
ArraySwap
ArrayToList
Asc
ASin
Atn
AuthenticatedContext
AuthenticatedUser
BinaryDecode
BinaryEncode
BitAnd
BitMaskClear
BitMaskRead
BitMaskSet
BitNot
Last updated 2/17/2016
BitOr
BitSHLN
BitSHRN
BitXor
37
Last updated 2/17/2016
38
Functions c-d
CacheIdExists
CacheGet
CacheGetAllIds
CacheGetMetadata
Last updated 2/17/2016
cacheGetSession
CachePut
CacheRegionExists
CacheRegionNew
CacheRegionRemove
CacheRemove
CacheRemoveAll
CacheSetProperties
CallStackGet
CallStackDump
CacheGetProperties
CanDeSerialize
Canonicalize
CanSerialize
39
Ceiling
CharsetDecode
CharsetEncode
Chr
CJustify
Compare
CompareNoCase
Cos
CreateDate
CreateDateTime
CreateObject
CreateObject: .NET object
CreateObject: COM object
CreateObject: component object
CreateObject: CORBA object
CreateObject: Java or EJB object
CreateObject: web service object
CreateODBCDate
CreateODBCDateTime
CreateODBCTime
Last updated 2/17/2016
CreateTime
CreateTimeSpan
CreateUUID
CSRFGenerateToken
CSRFVerifyToken
DateAdd
DateCompare
DateConvert
DateDiff
DateFormat
DateTimeFormat
DatePart
Day
DayOfWeek
40
DayOfWeekAsString
DayOfYear
DaysInMonth
DaysInYear
DE
DecimalFormat
DecodeForHTML
DecodeFromURL
DecrementValue
Decrypt
DecryptBinary
DeleteClientVariable
DeserializeJSON
DirectoryCopy
DirectoryCreate
DirectoryDelete
DirectoryExists
DirectoryList
DirectoryRename
DollarFormat
Last updated 2/17/2016
DotNetToCFType
Duplicate
Deserialize
DeserializeXML
41
Last updated 2/17/2016
43
Functions h-im
Hash
HMac
HQLMethods
Hour
HTMLCodeFormat
HTMLEditFormat
IIf
ImageAddBorder
ImageBlur
ImageClearRect
ImageCopy
ImageCreateCaptcha
ImageCrop
ImageDrawArc
ImageDrawBeveledRect
ImageDrawCubicCurve
ImageDrawLine
ImageDrawLines
Last updated 2/17/2016
ImageDrawOval
ImageDrawPoint
ImageDrawQuadraticCurve
ImageDrawRect
ImageDrawRoundRect
ImageDrawText
ImageFlip
ImageGetBlob
ImageGetBufferedImage
ImageGetEXIFMetadata
ImageGetEXIFTag
ImageGetHeight
ImageGetMetadata
ImageGetIPTCMetadata
44
ImageGetIPTCTag
ImageGetWidth
ImageGrayscale
ImageInfo
ImageMakeColorTransparent
ImageMakeTranslucent
ImageNegative
ImageNew
ImageOverlay
ImagePaste
ImageRead
ImageReadBase64
ImageResize
ImageRotate
ImageRotateDrawingAxis
ImageScaleToFit
ImageSetAntialiasing
ImageSetBackgroundColor
ImageSetDrawingColor
ImageSetDrawingStroke
Last updated 2/17/2016
ImageSetDrawingTransparency
ImageSharpen
ImageShear
ImageShearDrawingAxis
ImageTranslate
ImageTranslateDrawingAxis
ImageWrite
ImageWriteBase64
ImageXORDrawingMode
45
Last updated 2/17/2016
Functions m-r
Max
Mid
Min
Minute
Month
MonthAsString
Now
NumberFormat
ObjectEquals
47
ObjectLoad
ObjectSave
OnWSAuthenticate
ORMClearSession
ORMCloseAllSessions
ORMCloseSession
ORMEvictCollection
ORMEvictEntity
ORMEvictQueries
ORMExecuteQuery
ORMFlush
ORMFlushall
ORMGetSession
ORMGetSessionFactory
ORMIndex
ORMIndexPurge
ORMReload
ORMSearch
ORMSearchOffline
ParagraphFormat
Last updated 2/17/2016
ParameterExists
ParseDateTime
Pi
PrecisionEvaluate
Quarter
PreserveSingleQuotes
QueryAddColumn
QueryAddRow
QueryExecute
QueryGetRow
QueryNew
QueryConvertForGrid
QuerySetCell
QuotedValueList
48
Rand
Randomize
RandRange
ReEscape
REFind
REFindNoCase
REMatch
REMatchNoCase
ReleaseComObject
RemoveCachedQuery
RemoveChars
RepeatString
Replace
ReplaceList
ReplaceNoCase
REReplace
REReplaceNoCase
RestDeleteApplication
RestSetResponse
RestInitApplication
Last updated 2/17/2016
Reverse
Right
RJustify
Round
RTrim
49
Last updated 2/17/2016
51
Functions in-k
IncrementValue
InputBaseN
Insert
Int
InvalidateOauthAccesstoken
Invoke
InvokeCFClientFunction
IsArray
IsAuthenticated
IsAuthorized
IsBinary
IsBoolean
IsClosure
IsCustomFunction
IsDate
IsDDX
IsDebugMode
IsDefined
IsImage
Last updated 2/17/2016
IsImageFile
IsInstanceOf
IsIPv6
IsJSON
IsK2ServerABroker
IsK2ServerDocCountExceeded
IsK2ServerOnline
IsLeapYear
IsLocalHost
IsNull
IsNumeric
IsNumericDate
IsObject
isOnline
52
IsPDFFile
IsPDFObject
IsProtected
IsQuery
isSafeHTML
IsSimpleValue
IsSOAPRequest
IsSpreadsheetFile
IsSpreadsheetObject
IsStruct
IsUserInAnyRole
IsUserInRole
IsUserLoggedIn
IsValid
IsValidOauthAccesstoken
IsWDDX
IsXML
IsXmlAttribute
IsXmlDoc
IsXmlElem
Last updated 2/17/2016
IsXmlNode
IsXmlRoot
JavaCast
JSStringFormat
53
Last updated 2/17/2016
54
Functions l
LCase
Left
Last updated 2/17/2016
Len
ListAppend
ListChangeDelims
ListContains
ListContainsNoCase
ListDeleteAt
ListEach
ListFilter
ListFind
ListFindNoCase
ListFirst
ListGetAt
ListInsertAt
ListLast
55
ListLen
ListMap
ListPrepend
ListQualify
ListReduce
ListRemoveDuplicates
ListRest
ListSetAt
ListSort
ListToArray
ListValueCount
ListValueCountNoCase
LJustify
Location
Log
Log10
LSCurrencyFormat
LSDateFormat
LSDateTimeFormat
LSEuroCurrencyFormat
Last updated 2/17/2016
LSIsCurrency
LSIsDate
LSIsNumeric
LSNumberFormat
LSParseCurrency
LSParseDateTime
LSParseEuroCurrency
LSParseNumber
LSTimeFormat
LTri m
56
Last updated 2/17/2016
57
Functions t-z
Ta n
ThreadJoin
ThreadTerminate
Throw
Time For mat
To B as e 6 4
To Bi n a r y
Last updated 2/17/2016
To S cr i p t
To St r i ng
Tra ce
Transactionandconcurrency
Tran s ac ti on Co mm it
Tran s ac ti on Ro ll ba ck
TransactionSetSavePoint
Tr im
UCase
URLDecode
URLEncodedFormat
URLSessionFormat
Va l
Va lu e L is t
58
Ve ri f y C li e nt
We ek
Wr ap
Wr it eD u mp
Wr it eL o g
Wr it eO ut p ut
WSGetAllChannels
WSGetSubscribers
WSPublish
WSSendMessage
XmlChildPos
XmlElemNew
XmlFormat
XmlGetNodeType
XmlNew
XmlParse
XmlSearch
XmlTransform
XmlValidate
Ye a r
Last updated 2/17/2016
Ye s N o F o r m a t
59
Last updated 2/17/2016
Functions s
Second
60
SendGatewayMessage
SerializeJSON
SessionInvalidate
SessionRotate
SessionGetMetaData
SetEncoding
SetLocale
SetProfileString
SetVariable
Sgn
Sin
Sleep
SpanExcluding
SpanIncluding
SpreadsheetAddColumn
SpreadsheetAddImage
SpreadsheetAddFreezePane
SpreadsheetAddInfo
SpreadsheetAddRow
SpreadsheetAddRows
Last updated 2/17/2016
SpreadsheetAddSplitPane
SpreadsheetCreateSheet
SpreadsheetDeleteColumn
SpreadsheetDeleteColumns
SpreadsheetDeleteRow
SpreadsheetDeleteRows
SpreadsheetFormatCell
SpreadsheetFormatColumn
SpreadsheetFormatCellRange
SpreadsheetFormatColumns
SpreadsheetFormatRow
SpreadsheetFormatRows
SpreadsheetGetCellComment
SpreadsheetGetCellFormula
61
SpreadsheetGetCellValue
SpreadsheetInfo
SpreadsheetMergeCells
SpreadsheetNew
SpreadsheetRead
SpreadsheetReadBinary
SpreadsheetRemoveSheet
SpreadsheetSetActiveSheet
SpreadsheetSetActiveSheetNumber
SpreadsheetSetCellComment
SpreadsheetSetCellFormula
SpreadsheetSetCellValue
SpreadsheetSetColumnWidth
SpreadsheetSetFooter
SpreadsheetSetHeader
SpreadsheetSetRowHeight
SpreadsheetShiftColumns
SpreadsheetShiftRows
SpreadsheetWrite
Sqr
Last updated 2/17/2016
StripCR
StructAppend
StructClear
StructCopy
StructCount
StructDelete
StructEach
StructFilter
StructFind
StructFindKey
StructFindValue
StructGet
StructInsert
StructIsEmpty
62
StructKeyArray
StructKeyExists
StructKeyList
StructNew
StructSort
StructUpdate
SpreadSheetAddPagebreaks
SpreadSheetAddAutofilter
StructReduce
StructMap
Serialize
SerializeXML
Last updated 2/17/2016
Functions e-g
EncodeForCSS
EncodeForHTML
EncodeForHTMLAttribute
EncodeForXMLAttribute
EncodeForJavaScript
65
EncodeForURL
EncodeForXML
EncodeForXpath
Encrypt
GetTempDirectory
GetApplicationMetadata
EncryptBinary
EntityDelete
EntityLoad
EntityLoadByExample
EntityLoadByPK
EntityMerge
EntityNew
EntityReload
EntitySave
EntityToQuery
Evaluate
Exp
ExpandPath
FileClose
Last updated 2/17/2016
FileCopy
FileDelete
FileExists
FileGetMimeType
FileIsEOF
FileMove
FileOpen
FileRead
FileReadBinary
FileReadLine
FileSeek
FileSetAccessMode
FileSetAttribute
FileSetLastModified
66
FileSkipBytes
FileUpload
FileUploadAll
FileWrite
FileWriteLine
Find
FindNoCase
FindOneOf
FirstDayOfMonth
Fix
FormatBaseN
GenerateSecretKey
GetAuthUser
GetBaseTagData
GetBaseTagList
GetBaseTemplatePath
GetClientVariablesList
GetComponentMetaData
GetContextRoot
GetCPUUsage
Last updated 2/17/2016
GetCurrentTemplatePath
GetDirectoryFromPath
GetEncoding
GetException
GetFileFromPath
GetFileInfo
GetFreeSpace
GetFunctionCalledName
GetFunctionList
GetGatewayHelper
GetHttpRequestData
GetHttpTimeString
GetK2ServerDocCount
GetK2ServerDocCountLimit
67
GetLocale
GetLocaleDisplayName
GetLocalHostIP
GetMetaData
GetMetricData
GeneratePBKDFKey
GetPageContext
GetPrinterInfo
GetPrinterList
GetProfileSections
GetProfileString
GetReadableImageFormats
GetSafeHTML
GetSOAPRequest
GetSOAPRequestHeader
GetSOAPResponse
GetSOAPResponseHeader
GetSystemFreeMemory
GetSystemTotalMemory
GetTempFile
Last updated 2/17/2016
GetTemplatePath
GetTickCount
GetTimeZoneInfo
GetToken
GetTotalSpace
GetUserRoles
GetVFSMetaData
GetWriteableImageFormats
68
Last updated 2/17/2016
Chapter 5: Ajax JavaScript Functions
Ajax JavaScript Functions
You can use the JavaScript functions listed below on pages that use ColdFusion Ajax features.
Function summary Ajax
ColdFusion.Ajax.submitForm
ColdFusion.Autosuggest.getAutosuggestObject
ColdFusion.Layout.enableSourceBind
ColdFusion.MessageBox.getMessageBoxObject
ColdFusion.MessageBox.isMessageBoxDefined
72
ColdFusion.ProgressBar.getProgressBarObject
Function summary Ajax
The following table briefly describes the JavaScript functions that you can use in ColdFusion pages that use
Ajax features:
FunctionDescription
ColdFusion.Ajax.submitFormSubmits form data without refreshing the entire page when the results
are returned.
ColdFusion.Autosuggest.getAutosuggestObjectLets you access underlying YUI AutoComplete object thereby
ColdFusion.FileUpload.cancelUploadCancels the file upload at any point during the file upload.
ColdFusion.FileUpload.clearAllFilesClears all the files selected for upload.
Last updated 2/17/2016
providing fine-grained control over the object, for example attaching
an event.
Coldfusion.fileUpload.setUrlSets URL for the fileupload control dynamically.
ColdFusion.FileUpload.startUploadStarts uploading the selected files.
ColdFusion.getElementValueGets the value of an attribute of a bindable ColdFusion control.
ColdFusion.grid.clearSelectedRowsClears the selected rows in the grid.
73
ColdFusion.Grid.getBottomToolbarGets bottom toolbar that can be used to add a control, for example
ColdFusion.Grid.getGridObjectGets the underlying Ext JS - JavaScript Library object for the specified
ColdFusion.grid.getSelectedRowsFetches data for the selected rows in the grid.
ColdFusion.Grid.getTopToolbarGets the top toolbar that can be used to add a control, for example
ColdFusion.Grid.hideBottomToolbarHides the bottom toolbar that can be used to add a control, for
ColdFusion.Grid.hideTopToolbarHides the top toolbar that can be used to add a control, for example
ColdFusion.Grid.refreshManually refreshes a displayed grid.
ColdFusion.Grid.refreshBottomToolbarRefreshes the bottom toolbar that can be used to add a control, for
ColdFusion.Grid.refreshTopToolbarRefreshes the top toolbar that can be used to add a control, for
ColdFusion.Grid.showBottomToolbarShows bottom toolbar that can be used to add a control, for example
ColdFusion.Grid.showTopToolbarDisplays the top toolbar that can be used to add a control, for example
ColdFusion.Grid.sortSorts the specified HTML grid.
icon or button.
HTML cfgrid control.
icon or button.
example icon or button.
icon or button.
example icon or button.
example icon or button.
icon or button.
icon or button.
ColdFusion.JSON.decodeConverts a JSON-encoded string into a JavaScript variable
ColdFusion.JSON.encodeconverts a JavaScript variable into a JSON string.
ColdFusion.Layout.collapseAccordionCollapses an area of an accordion layout.
ColdFusion.Layout.collapseAreaCollapses an area of a border layout (cflayout tag with a type attribute
ColdFusion.Layout.createAccordionPanelCreates a panel in an existing accordion layout (cflayout tag with a
ColdFusion.Layout.createTabCreates a tab in an existing tabbed layout (cflayout tag with a type
ColdFusion.Layout.disableSourceBindDisables the source bind.
ColdFusion.Layout.disableTabDisables the specified tab so it cannot be selected.
ColdFusion.Layout.enableSourceBindIf disabled, enables the source bind.
ColdFusion.Layout.enableTabEnables the specified tab so users can select it and display the area
ColdFusion.Layout.expandAccordionExpands a collapsed area of an accordion layout.
ColdFusion.Layout.expandAreaExpands a collapsed area of a border layout.
of border).
type attribute of accordion).
attribute of tab).
contents.
Last updated 2/17/2016
74
ColdFusion.Layout.getAccordionLayoutGets the underlying Ext JS - JavaScript Library object for the specified
ColdFusion.Layout.getBorderLayoutGets the underlying Ext JS - JavaScript Library object for the specified
ColdFusion.Layout.getTabLayoutGets the underlying Ext JS - JavaScript Library object for the specified
ColdFusion.Layout.hideAccordionHides an accordion.
ColdFusion.Layout.hideAreaHides a bordered layout area.
ColdFusion.Layout.hideTabHides a tab.
ColdFusion.Layout.selectAccordionSelects an accordion and displays the layout area contents.
ColdFusion.Layout.selectTabSelects a tab and displays the layout area contents.
ColdFusion.Layout.showAccordionShows an accordion that was hidden using the inithide attribute or the
ColdFusion.Layout.showAreaShows an area of a border layout that was hidden using the inithide
ColdFusion.Layout.showTabShows a tab that was hidden using the inithide attribute or the
ColdFusion.Log.debugDisplays a debug-level message in the log window.
ColdFusion.Log.dumpDisplays information about a complex variable in the log window.
ColdFusion.Log.errorDisplays an error-level message in the log window.
accordion type cflayout control.
border type cflayout control.
tab type cflayout control.
hideArea() function.
attribute or the hideArea() function.
hideTab() function.
ColdFusion.Log.infoDisplays an information-level message in the log window.
ColdFusion.Map.addEventEnables event handling in a map.
ColdFusion.Map.addMarkerAdds a marker to the map.
ColdFusion.Map.getLatitudeLongitudeGets the latitude/longitude coordinates for a given address.
ColdFusion.Map.getMapObjectGets the Google map component.
ColdFusion.Map.hideHides the map if displayed.
ColdFusion.Map.refreshReloads the map.
ColdFusion.Map.setCenterSets the center of map to the address that you specify.
ColdFusion.Map.setZoomlevelSets the zoom level of the map to the new value.
ColdFusion.Map.showShows the map if it is hidden.
ColdFusion.Mediaplayer.resizeChanges the current size of the media player.
ColdFusion.Mediaplayer.setMuteMutes or unmutes the sound of the media player.
ColdFusion.Mediaplayer.setSourceSets the URL of the FLV file.
ColdFusion.Mediaplayer.setVolumeSets the volume of sound of the media player.
ColdFusion.Mediaplayer.startPlayPlays the FLV file.
ColdFusion.Mediaplayer.stopPlayStops playing the FLV file.
ColdFusion.MessageBox.createCreates a ColdFusion message box. Equivalent to the cfmessagebox
tag.
Last updated 2/17/2016
75
ColdFusion.MessageBox.getMessageBoxObjectGets the underlying Ext JS - JavaScript Library object for the specified
ColdFusion.MessageBox.isMessageBoxDefinedChecks if a message box is defined.
ColdFusion.MessageBox.showDisplays a ColdFusion message box.
cfajaxproxy , ColdFusion.navigate , Using the ColdFusion.Ajax.submitForm function in Using Ajax form controls and
features in the Developing ColdFusion Applications
History
ColdFusion 8: Added this function.
Parameters
ParameterDescription
76
formIdThe ID or name attribute of the form.
URLThe URL to which to submit the form.
callbackhandlerThe JavaScript function to handle a normal response. The function
errorHandlerThe JavaScript function to handle an HTTP error response. The
httpMethodThe HTTP method to use for the submission, must be one of the
must take a single argument, that contains the response body. This
method is used only if the form submission is asynchronous.
function must take two arguments: the HTTP status code, and the
error message. This method is used only if the form submission is
asynchronous.
following:
• GET
• POST (the default)
asynchA Boolean value specifying whether to submit the form
asynchronously. The default value is true.
Returns
If the asynch argument is false, returns the response body. Otherwise, the function does not return a value.
Usa ge
If the page that calls this function does not have any ColdFusion AJAX-based controls, use a cfajaximport tag on the
page to ensure that the page includes the JavaScript definition for this function.
Note: This function does not submit the contents of file fields.
Example
See Using the ColdFusion.Ajax.submitForm function in Using Ajax form controls and features in the Developing
ColdFusion Applications.
Last updated 2/17/2016
ColdFusion.Autosuggest.getAutosuggestObject
Description
Lets you access underlying YUI AutoComplete object thereby providing fine-grained control over the object, for
example attaching an event.
See usage in ColdFusion.Layout.disableSourceBind .
Example
79
See example in ColdFusion.Layout.disableSourceBind .
ColdFusion.FileUpload.getSelectedFiles
Description
Returns an array of objects containing the filename and size of the files selected for upload. The file size is returned in
bytes. The function also returns file upload status as YES|NO|Error.
Function syntax
ColdFusion.FileUpload.getSelectedFiles(Id)
Parameters
• Id: Name of the cffileupload control.
Usa ge
In a real life scenario, you normally use the uploader with other controls. For example, a form with three fields: name,
emai l, and uploa der. Assume that you up load t he f iles, but forget to c lick Submit or yo u sele ct the f iles, subm it the form ,
but forget to click Upload. You can use this function to inform the user that there are files that have been selected for
upload and provide the following details:
• FILENAME: Name of the file selected for upload.
• SIZE: Size of the file in bytes.
• STATUS: YES|NO|Error; YES indicates a successful upload, NO indicates that the upload is yet to occur, and Error
indicates that an exception has occurred during the upload operation.
Example
The following example illustrates a scenario where the user clicks Submit and is informed about the files selected for
upload:
Last updated 2/17/2016
<html> <head> <script language="javascript"> var formatNumber = function(num){ if(num < 1024) return num + " bytes"; if(num < (1024 *
As sum e that you are usi ng Col df usi on. nav igat e to p opul ate c ont ent int o tab or a ccor dion pane ls. You can hav e ins tanc es
where content comes from the source bind call if the source attribute is defined for cflayoutarea (and is not from
ColdFusion.navigate).In such instances, you might disable the source bind to get content using Coldfusion.navigate.
Example
layout.cfm uses the templates Tab1_Src.cfm, Tab2_Src.cfm, and Tab3_Src.cfm. If you run layout.cfm, you notice that
clicking
• navigate populates content of tab2_src.cfm instead of navigate.cfm
• Disable Source bind ensures that the content of navigate.cfm is populated in tab2_src
• Enable Source Bind and then clicking tab2_src would again populate the content of tab2_srcTab 1 _S r c. c f m
<br><cfdump var="#server.coldfusion#" label="[Showing key coldfusion in server scope]"><br>
Ta b4 _ Sr c . cf m __
<br><cfdump var="#server.os#" label="[Showing key OS in server scope]"><br>
layout.cfm
<script> var navigateToTab = function(layoutId,tabId){ alert("Navigating to " + tabId); ColdFusion.Layout.selectTab(layoutId,tabId);
ColdFusion.navigate('navigate.cfm',tabId); } var disableBind = function(tabId){ alert("Disabling binding on source for " + tabId);
ColdFusion.Layout.disableSourceBind(tabId); } var enableBind = function(tabId){ alert("Enabling binding on source for " + tabId);
ColdFusion.Layout.enableSourceBind(tabId); } </script> <cflayout type="tab" name="layout1"> <cflayoutarea name = "tab1" overflow =
"auto" refreshonactivate = "yes" title = "Tab 1" source = "tab1_src.cfm"/> <cflayoutarea name = "tab2" overflow = "auto" refreshonactivate
= "false" title = "Tab 2" source = "tab2_src.cfm" bindonload=false /> <cflayoutarea name = "tab3" overflow = "auto" refreshonactivate =
"yes" title = "Tab 3" source = "tab3_src.cfm" /> </cflayout> <cfform name="myform"> <cfinput type="button" name="disable"
value="Disable Source Bind" onClick="javascript:disableBind('tab2')"> <cfinput type="button" name="b" value="Navigate"
onClick="javascript:navigateToTab('layout1','tab2')"> <cfinput type="button" name="disable" value="Enable Source Bind"
onClick="javascript:enableBind('tab2')"> </cfform>
ColdFusion.Layout.enableSourceBind
Description
If disabled, enables the source bind.
Function syntax
ColdFusion.Layout.enableSourceBind(Id)
Parameters
• Id: Name of the layout area.
Last updated 2/17/2016
Usa ge
See usage in ColdFusion.Layout.disableSourceBind .
Example
See example in ColdFusion.Layout.disableSourceBind .
ColdFusion.FileUpload.getSelectedFiles
Description
Returns an array of objects containing the filename and size of the files selected for upload. The file size is returned in
bytes. The function also returns file upload status as YES|NO|Error.
Function syntax
ColdFusion.FileUpload.getSelectedFiles(Id)
Parameters
• Id: Name of the cffileupload control.
Usa ge
In a real life scenario, you normally use the uploader with other controls. For example, a form with three fields: name,
emai l, and uploa der. Assume that you up load t he f iles, but forget to c lick Submit or yo u sele ct the f iles, subm it the form ,
but forget to click Upload. You can use this function to inform the user that there are files that have been selected for
upload and provide the following details:
88
• FILENAME: Name of the file selected for upload.
• SIZE: Size of the file in bytes.
• STATUS: YES|NO|Error; YES indicates a successful upload, NO indicates that the upload is yet to occur, and Error
indicates that an exception has occurred during the upload operation.
Example
The following example illustrates a scenario where the user clicks Submit and is informed about the files selected for
upload:
<html> <head> <script language="javascript"> var formatNumber = function(num){ if(num < 1024) return num + " bytes"; if(num < (1024 *
<cfcomponent> <cfscript> empQuery = new query(name="emps", datasource="cfdocexamples"); remote any function
getEmployees(page,pageSize,gridsortcolumn="EMP_ID",gridsortdirection="ASC",empName) { var orderBy = "EMP_ID"; var mysql = "SELECT
Emp_ID, FirstName, LastName, EMail, Department, Email FROM Employees"; if(isdefined("arguments.empName") and
trim(arguments.empName) neq ""){ mysql = mysql & " WHERE " & "firstname = '#arguments.empName#'"; } if(arguments.gridsortcolumn eq ""){
mysql = mysql & " ORDER BY " & orderBy; } mysql = mysql & " " & gridsortdirection; return
QueryConvertForGrid(empQuery.execute(sql=mysql).getResult(), page, pageSize); } remote void function
editEmployees(gridaction,gridrow,gridchanged) { switch(gridaction) { case "I": { var eFName = gridrow["FIRSTNAME"]; var eLNAme =
gridrow["LASTNAME"]; var eDept = gridrow["DEPARTMENT"]; var eEmail = gridrow["EMAIL"]; var insertSql = "insert into
Employees(FirstName,LastName,Department,Email) values (" & "'" & eFName & "', '" & eLName & "', '" & eDept & "', '" & eEmail & "')";
empQuery.execute(sql=insertSql); break; } case "U": { var empId = gridrow["EMP_ID"]; var changedCol = structkeylist(gridchanged); var
updateSql = "UPDATE Employees SET " & changedCol & "='" & gridchanged[changedCol] & "' WHERE emp_id=" & empId;
empQuery.execute(sql=updateSql); break; } case "D": { deleteEmployees(gridrow); } } } remote void function deleteEmployees(empdata) { var i
= 1; var emp = {}; if(isArray(empdata) and not ArrayIsEmpty(empdata)){ for(emp in empdata){ if(isStruct(emp) and
structkeyexists(emp,"emp_id")){ empid = emp["emp_id"]; writelog("deleting " & empid); //var deleteSql = "delete from Employees where
emp_id=" & empid; //empQuery.execute(sql=deleteSql); } } } } </cfscript> </cfcomponent>
In this example, setting multirowselect=true enables performing of batch operations on grid data, such as deleting
multiple records.In the deleteemployees functions, two lines have been commented out to prevent accidental deletion
of data (since it is a batch operation). To see deletion, uncomment the code.The form has a deleteAllSelectedRows
button that illustrates how records can be deleted externally. That is, without using the delete button built in to the grid.
The same approach can be used to perform other batch operations such as moving multiple files to another folder or
batch updates.
Note: Set the httpMethod to POST on the Proxy object carefully to avoid "request URI too large" errors as shown in the deleteAllSelectedRows
method in Employee.cfm.
ColdFusion.Map.show
Description
Shows the map if it is hidden.
Last updated 2/17/2016
Function syntax
ColdFusion.Map.show(Id)
Parameters
• Id: Name of the map.
Example
<script> function showMap(mapId) { ColdFusion.Map.show(mapId); } function hideMap(mapId) { ColdFusion.Map.hide(mapId); } </script> <a
href="##" id="a1" onclick="return showMap('mainMap')">Show Map</a> | <a href="##" id="a1" onclick="return hideMap('mainMap')">Hide
Map</a> <cfmap zoomlevel = "12" name = "mainMap" showcentermarker= "true" centeraddress = "The Key Learning centre, Oxford, UK"
title="Venue Address" hideborder=false collapsible=true initShow=false/>
ColdFusion.Map.hide
Description
If displayed, hides the map.
Function syntax
ColdFusion.Map.hide(Id)
Parameters
91
• Id: Name of the map.
Example
See example in ColdFusion.Map.show
ColdFusion.Map.refresh
Description
Reloads the map.
Function syntax
ColdFusion.Map.refresh (Id)
Parameters
• Id: Name of the map.
Usa ge
If the map is embedded within spry collapsible panels or divs that are hidden on display, that is the map container is
displayed while the actual map is hidden, use this function to force the map to display.
Gets the top toolbar that can be used to add a control, for example icon or button.
Function syntax
ColdFusion.getTopToolbar(Id)
Parameters
• Id: Name of the grid.
Example
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.getBottomToolbar
Description
Gets bottom toolbar that can be used to add a control, for example icon or button.
Function syntax
ColdFusion.Grid.getBottomToolbar(Id)
Parameters
92
• Id: Name of the grid.
Example
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.showTopToolbar
Description
Displays the top toolbar that can be used to add a control, for example icon or button.
Function syntax
ColdFusion.Grid.showTopToolbar(Id)
Parameters
• Id: Name of the grid.
Example
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.hideTopToolbar
Description
Hides the top toolbar that can be used to add a control, for example icon or button.
Function syntax
ColdFusion.Grid.hideTopToolbar(Id)
Parameters
• Id: Name of the grid.
Example
Last updated 2/17/2016
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.showBottomToolbar
Description
Shows bottom toolbar that can be used to add a control, for example icon or button.
Function syntax
ColdFusion.Grid.showBottomToolbar(Id)
Parameters
• Id: Name of the grid.
Example
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.hideBottomToolbar
Description
Hides the bottom toolbar that can be used to add a control, for example icon or button.
Function syntax
93
ColdFusion.Grid.hideBottomToolbar(Id)
Parameters
• Id: Name of the grid.
Example
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.refreshTopToolbar
Description
Refreshes the top toolbar that can be used to add a control, for example icon or button. This function internally calls
the JavaScript function
Function syntax
ColdFusion.Grid.refreshTopToolbar(Id)
Parameters
ColdFusion.Grid.showTopToolbar .
• Id: Name of the grid.
Example
See example in ColdFusion.Grid.refreshBottomToolbar .
ColdFusion.Grid.refreshBottomToolbar
Description
Refreshes the bottom toolbar that can be used to add a control, for example icon or button. This function internally
calls the JavaScript function
Function syntax
ColdFusion.Grid.refresheBottomToolbar(Id)
ColdFusion.Grid.showBottomToolbar .
Last updated 2/17/2016
Parameters
• Id: Name of the grid control.
Example
grid.cfc
<cfcomponent> <cfscript> remote any function getEmployees(page,pageSize,gridsortcolumn="EMP_ID",gridsortdirection="ASC"){ var
startRow = (page-1)*pageSize; var endRow = page*pageSize; if(!isdefined("arguments.gridsortcolumn") or
isdefined("arguments.gridsortcolumn") and trim(arguments.gridsortcolumn) eq "") gridsortcolumn = "EMP_ID";
if(!isdefined("arguments.gridsortdirection") or isdefined("arguments.gridsortdirection") and arguments.gridsortdirection eq "")
gridsortdirection = "ASC"; var mysql = "SELECT Emp_ID, FirstName, EMail, Department FROM Employees";
if(isdefined("arguments.gridsortcolumn") and arguments.gridsortcolumn neq "") mysql = mysql & " ORDER BY " & gridsortcolumn;
if(isdefined("arguments.gridsortdirection") and arguments.gridsortdirection neq "") mysql = mysql & " " & gridsortdirection ; rs1 = new
query(name="team", datasource="cfdocexamples", sql=mysql).execute(); return QueryConvertForGrid(rs1.getResult(), page, pageSize); }
remote any function editEmployees(gridaction,gridrow,gridchanged){ writelog("edit employee info"); } </cfscript> </cfcomponent>
grid.cfm
<script> var refreshToolbar = function(id,type){ type == "top" ? ColdFusion.Grid.refreshTopToolbar(id) :
ColdFusion.Grid.refreshBottomToolbar(id); } var hideToolbar = function(id,type){ type == "top" ? ColdFusion.Grid.hideTopToolbar(id) :
ColdFusion.Grid.hideBottomToolbar(id); } var showToolbar = function(id,type){ (type == "top") ? ColdFusion.Grid.showTopToolbar(id) :
ColdFusion.Grid.showBottomToolbar(id); } var handleToolbar = function(id,type){ if(type == "top"){ tbar = ColdFusion.Grid.getTopToolbar(id);
tbar.addButton({ text: "Add User Account", tooltip: "Add a user account", handler: addUserAccount }); } else{ bbar =
ColdFusion.Grid.getBottomToolbar(id); bbar.add(new Ext.Toolbar.Separator()); bbar.addButton({ text: "Delete User Account", tooltip: "Delete a
user account", handler: deleteUserAccount }); } } var GetUserInfo = function(){ alert("Retrieving user account"); } var addUserAccount =
function(){ alert("Adding new user account") } var deleteUserAccount = function(){ alert("Deleting user account") } </script> <cfform> <br>
<cfinput type="button" onClick="showToolbar('empGrid','top')" name="btn1" value="Show Top Toolbar"> <cfinput type="button"
onClick="handleToolbar('empGrid','top')" name="btn2" value="Add button to Top Toolbar"> <cfinput type="button"
onClick="refreshToolbar('empGrid','top')" name="btn3" value="Refresh Top Toolbar"> <cfinput type="button"
onClick="hideToolbar('empGrid','top')" name="btn4" value="Hide Top Toolbar"> <br><br> <cfgrid format="html" name="empGrid"
width="800" pagesize=5 sort=true title="Employee database" collapsible="true" insert="yes" delete="yes"
bind="cfc:grid.getEmployees({cfgridpage},{cfgridpagesize},{cfgridsortcolumn},{cfgridsortdirection})"
onChange="cfc:grid.editEmployees({cfgridaction},{cfgridrow},{cfgridchanged})" selectMode="edit" > <cfgridcolumn name="Emp_ID"
display=false header="ID" /> <cfgridcolumn name="FirstName" display=true header="First Name"/> <cfgridcolumn name="Email"
display=true header="Email"/> <cfgridcolumn name="Department" display=true header="Department" /> </cfgrid> <br><br> <cfinput
type="button" onClick="hideToolbar('empGrid','bottom')" name="btn5" value="Hide Bottom Toolbar"> <cfinput type="button"
onClick="showToolbar('empGrid','bottom')" name="btn6" value="Show Bottom Toolbar"> <cfinput type="button"
onClick="handleToolbar('empGrid','bottom')" name="btn7" value="Add button to Bottom Toolbar"> <cfinput type="button"
onClick="refreshToolbar('empGrid','bottom')" name="btn8" value="Refresh Bottom Toolbar"> </cfform>
94
Last updated 2/17/2016
Chapter 6: Script Functions
Implemented as CFCs
Script Functions Implemented as CFCs
Script functions were added in ColdFusion 9. They are implemented as ColdFusion Components. These
functions extend the usage of the tags cfmail, cfpdf, cfquery, cfhttp, cfstoredproc, and cfftp to CFScript.
Accessing the functions
Function summary
ftp
95
http
mail
pdf
query
storedproc
Script functions implemented as CFCs in ColdFusion 9 Update 1
Last updated 2/17/2016
Accessing the functions
Script functions are available in the following location: cf_root\CustomTags\com\adobe\coldfusion. Ensure that you
do not delete the default custom tag mapping listed in the ColdFusion Administrator (Extensions > Custom Tag Paths
> Custom tag mappings). Script functions work if they are either in the default location or web root. If you have the
functions in any other location, add a /com mapping in the ColdFusion Administrator that points to the new location
(for example C:\com).
Note: Values of the attributes set in a service action, for example, mail.send(body="test mail") are transient in nature. They are not accessible
after the action completes. Accessing the attributes using implicit getters results in erro r whereas any attributes set using either implicit setters
or the init method call are retained and can be accessed using implicit getters.
Function summary
The following table lists the script functions and the equivalent ColdFusion tag.
FunctionEquivalent ColdFusion Tag
ftpcfftp
96
httpcfhttp
mailcfmail
pdfcfpdf
querycfquery
storedproccfstoredproc
ftp
Description
Used to implement File Transfer Protocol (FTP) operations using CFScript.
Syntax
ModeSyntax
Creating the servicenew ftp() or createObject("component","ftp")
Initializing the attributesAny one of the following:
ArgumentsAll arguments supported by the cfhttp tag.
Last updated 2/17/2016
• getAttributes
DescriptionGets attributes that were set for the http function.
ReturnsReturns a struct with all or some of the service tag attribute values.
SyntaxhttpService.get_Attributes_(attribute_list)
101
ArgumentsA comma-separated list of attributes. If no list is specified, all
defined attributes are returned.
• clearAttributes
DescriptionRemoves all attributes added for the http function.
ReturnsNothing
SyntaxhttpService.clearAttributes(attribute_list)
ArgumentsA comma-separated list of attributes.
• clearParams
DescriptionRemoves cfhttpparam tags that were added using the addParam
ReturnsNothing
SyntaxhttpService.clearParams()
ArgumentsNone
method.
• clear
DescriptionRemoves all attributes and cfhttpparam tags that were added
ReturnsNothing
SyntaxhttpService.clear()
ArgumentsNone
using the addParam method.
Usa ge
This function corresponds to the cfhttp tag. For usage details, see the Usage section for cfhttp in the CFML Reference.
Example
Last updated 2/17/2016
<!--- Get Video ---> <!--- <cfset videoName = "<video path>\hello.wmv"> <cfset videoFileName = "hello.wmv"> ---> <!--- Set User Account Data
---> <!--- <cfset clientKey = "enter client key from google"/> <cfset devKey = "ebtdev key from google>"/> ---> <cfscript> /* youtube uplaod
url */ youTubeUploadURL = "http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"; /* video to upload */ videoName =
ExpandPath('./hello.wmv'); videoFileName = "hello.wmv"; /* set user account data */ clientKey = "enter client key from google"; devKey =
"ewnter dev key from google"; /* create new http service */ httpService = new http(); /* set attributes using implicit setters */
httpService.setMethod("post"); httpService.setCharset("utf-8"); httpService.setUrl("https://www.google.com/accounts/ClientLogin"); /* add
httpparams using addParam() */ httpService.addParam(type="formfield",name="accountType",value="HOSTED_OR_ GOOGLE");
httpService.addParam(type="formfield",name="Email",value="enter gmail id");
httpService.addParam(type="formfield",name="Passwd",value="enter password");
httpService.addParam(type="formfield",name="service",value="youtube");
httpService.addParam(type="formfield",name="source",value="youtubecode"); /* make the http call to the URL using send() */ result =
httpService.send().getPrefix(); /* process the filecontent returned */ content = listtoarray(result.filecontent,chr(10)); for(i=1;i lte
arraylen(content);i++) { item = content[i]; authdata[listFirst(item, "=")] = listRest(i tem, "="); } </cfscript> <!--- Create ATOM XML and save to a file
to be sent with video ---> <cfsavecontent variable="meta"> <cfoutput> <entry xmlns="http://www.w3.org/2005/Atom"
xmlns:media="http://search.yahoo.com/mrss/" xmlns:yt="http://gdata.youtube.com/schemas/2007"> <media:group> <media:title
type="plain">WithOutQuotes</media:title> <media:description type="plain">Test Description</media:description> <media:category
scheme="http://gdata.youtube.com/schemas/2007/categories.cat">People </media:category>
<media:keywords>yourvideo</media:keywords> </media:group> </entry> </cfoutput> </cfsavecontent> <cfscript> tmpfile =
expandPath("./meta.xml"); FileWrite(tmpfile,trim(meta)); /* use the httpService created above */
httpService.setUrl("http://uploads.gdata.youtube.com/feeds/api/users/default/ uploads"); httpService.setTimeOut(450);
httpService.setMultipartType("related"); /* clear params first */ httpService.clearParams(); /* add httpparams using addParam() */
httpService.addParam(type="header",name="Authorization", value="GoogleLogin auth=#authdata.auth#");
httpService.addParam(type="header",name="X-GData-Client", value="#variables.clientkey#");
httpService.addParam(type="header",name="X-GData-Key", value="key=#variables.devkey#");
httpService.addParam(type="header",name="Slug",value="#videoFileName#");
httpService.addParam(type="file",name="API_XML_Request",file="#tmpfile#", mimetype= "application/atom+xml");
httpService.addParam(type="file",name="file",file="#videoName#",mimetype ="video/*"); /* make the http call to the URL using send() */ result
= httpService.send().getPrefix(); if(result.statuscode contains "201") { WriteOutput("Your video has been successfully uploaded to YouTube"); }
else { WriteOutput("There was a problem uploading the video. Status code returned was " & result.statuscode); } </cfscript>
102
mail
Description
Used to sends an e-mail message, that optionally contains query output, using an SMTP server.
Syntax
ModeSyntax
Creating the servicenew mail() or createObject("component", "mail")
Initializing the attributesAny one of the following: