MACROMEDIA COLFUSION MX 7-CFML Reference

Other manuals for COLFUSION MX 7-CFML: Quick Reference

Summary of COLFUSION MX 7-CFML

  • Page 1

    Coldfusion ® mx 7 cfml reference.

  • Page 2

    Trademarks 1 step robopdf, activeedit, activetest, authorware, blue sky software, blue sky, breeze, breezo, captivate, central, coldfusion, contribute, database explorer, director, dreamweaver, fireworks, flash, flashcast, flashhelp, flash lite, flashpaper, flex, flex builder, fontographer, freehand...

  • Page 3: Contents

    3 contents introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5 chapter 1: reserved words and variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 4

    4 contents chapter 5: application.Cfc reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945 application variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 945 method summary . . . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 5: Introduction

    5 introduction cfml reference is your primary coldfusion markup language (cfml) reference. Use this manual to learn about cfml tags and functions, coldfusion expressions, and using javascript objects for wddx in macromedia coldfusion mx 7. It also provides detailed references for java and c++ cfx in...

  • Page 6

    6 introduction: viewing online documentation all coldfusion mx documentation is available online in html and adobe acrobat portable document format (pdf) files. Go to the documentation home page for coldfusion mx on the macromedia website: www.Macromedia.Com ..

  • Page 7: Chapter 1

    7 chapter 1 reserved words and variables this chapter provides information on macromedia coldfusion reserved words, and lists scope variables. Contents reserved words . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 scope-spe...

  • Page 8

    8 chapter 1: reserved words and variables reserved words in forms you must also not create form field names ending in any of the following, except to specify a form field validation rule using a hidden form field name. • _integer • _float • _range • _date • _time • _eurodate reserved words in querie...

  • Page 9

    Scope-specific built-in variables 9 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 ...

  • Page 10

    10 chapter 1: reserved words and variables 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 on page 270 , and chapter 15, “using persistent data and lock...

  • Page 11

    Coldfusion tag-specific variables 11 the predefined application and session variables are as follows: application.Applicationname session.Cfid session.Cftoken session.Urltoken custom tag variables a coldfusion custom tag returns the following variables: thistag.Executionmode thistag.Hasendtag thista...

  • Page 12

    12 chapter 1: reserved words and variables cffile cfftp cfhttp cfindex cfldap cfpop cfquery cfregistry cfsearch cfstoredproc coldfusion query variables a coldfusion tag that returns a query object supports the following variables, where queryname is the value of the name attribute: queryname.Current...

  • Page 13

    Coldfusion tag-specific variables 13 cfcatch.Line cfcatch.Knownline cfdirectory variables the cfdirectory tag, with action=list , returns a query object as follows, where queryname is the name attribute value: queryname.Name queryname.Size queryname.Type queryname.Datelastmodified queryname.Attribut...

  • Page 14

    14 chapter 1: reserved words and variables cffile action=upload variables file variables are read-only. Use the cffile prefix to reference file variables; for example, cffile.Clientdirectory . The file prefix is deprecated in favor of the cffile prefix. Cffile.Attemptedserverfile cffile.Clientdirect...

  • Page 15

    Coldfusion tag-specific variables 15 queryname.Lastmodified[row] queryname.Attributes queryname.Isdirectory queryname.Mode cfhttp variables a cfhttp get operation can return text and binary files. Files are downloaded and the contents stored in a variable or file, depending on the mime type, as foll...

  • Page 16

    16 chapter 1: reserved words and variables the cfstoredproc tag returns the following variables: cfstoredproc.Executiontime cfstoredproc.Statuscode cfregistry variables the cfregistry tag returns a query record set that you can reference after executing the getall action, as follows, where queryname...

  • Page 17

    Cgi environment variables 17 server cgi.Gateway_interface cgi.Server_name cgi.Server_port cgi.Server_protocol cgi.Server_software client cgi.Cert_issuer cgi.Cert_subject cgi.Client_cert_encoded cgi.Http_accept cgi.Http_if_modified_since cgi.Http_user_agent the cert_issuer , cert_subject , client_cer...

  • Page 18

    18 chapter 1: reserved words and variables cgi server variables the following table describes common cgi environment variables that the server creates (some of these are not available with some servers): cgi server variable description server_software name and version of the information server softw...

  • Page 19

    Cgi environment variables 19 cgi client variables the following table describes common cgi environment variables the browser creates and passes in the request header: cgi client certificate variables coldfusion makes available the following client certificate data. These variables are available when...

  • Page 20

    20 chapter 1: reserved words and variables.

  • Page 21: Chapter 2

    21 chapter 2 coldfusion tags coldfusion markup language (cfml) includes a set of tags that you use in macromedia coldfusion mx 7 pages to interact with data sources, manipulate data, and display output. Cfml tag syntax is similar to html element syntax. This chapter contains categorized and alphabet...

  • Page 22

    22 chapter 2: coldfusion tags cfcalendar forms tags provides a calendar from which to select a date cfcase flow-control tags used with the cfswitch and cfdefaultcase tags cfcatch exception handling tags , flow-control tags catches exceptions in coldfusion pages cfchart data output tags generates and...

  • Page 23

    Tag summary 23 cfflush data output tags , page processing tags flushes currently available data to client cfform forms tags builds input form; performs client-side input validation cfformgroup forms tags groups form control into a containing object cfformitem forms tags adds text and dividing rules ...

  • Page 24

    24 chapter 2: coldfusion tags cflock application framework tags ensures data integrity and synchronizes execution of cfml code cflog data output tags , other tags writes a message to a log file cflogin security tags defines a container for user login and authentication code cfloginuser security tags...

  • Page 25

    Tag summary 25 cfregistry other tags , variable manipulation tags reads, writes, and deletes keys and values in a windows system registry cfreport exception handling tags embeds a coldfusion report builder or crystal reports report cfreportparam exception handling tags passes an input parameter to a...

  • Page 26

    26 chapter 2: coldfusion tags tags by function the following tables list tags by their function or purpose. Application framework tags . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26 database manipulation tags . . . . . . . . . . . . . . . . ....

  • Page 27

    Tags by function 27 database manipulation tags data output tags debugging tags exception handling tags extensibility tags file management tags cfinsert cfprocresult cfstoredproc cfobjectcache cfquery cftransaction cfprocparam cfqueryparam cfupdate cfchart cfdocumentitem cfoutput cfchartdata cfdocume...

  • Page 28

    28 chapter 2: coldfusion tags flow-control tags forms tags internet protocol tags page processing tags security tags variable manipulation tags cfabort cfexecute cfrethrow cfbreak cfexit cfswitch cfcase cfif cfthrow cfdefaultcase cfinclude cftry cfelse cflocation cfelseif cfloop cfapplet cfgrid cfse...

  • Page 29

    Tag changes since coldfusion 5 29 other tags tag changes since coldfusion 5 the following tables list tags, attributes, and values that have changed since coldfusion 5.0 and indicate the specific release in which the change was made. New tags, attributes, and values . . . . . . . . . . . . . . . . ....

  • Page 30

    30 chapter 2: coldfusion tags cfcomponent style , namespace , serviceportname , porttypename , wsdlfile , and bindingname attributes coldfusion mx 7 extended functionality for the hint and displayname attributes when publishing document-literal style web services all coldfusion mx cfcontent variable...

  • Page 31

    Tag changes since coldfusion 5 31 cfhttp result attribute coldfusion mx 7 head , put , delete , options , and trace values of method attribute coldfusion mx 6.1 multipart , getasbinary , proxyuser , proxypassword attributes charset , firstrowasheaders attributes coldfusion mx cfhttpparam header and ...

  • Page 32

    32 chapter 2: coldfusion tags cfinvoke serviceport attribute for web services coldfusion mx 7 all coldfusion mx cfinvokeargument omit attribute coldfusion mx 7 all coldfusion mx cfldap returnasbinary attribute coldfusion mx 7 cflogin all coldfusion mx cfloginuser all coldfusion mx cflogout all coldf...

  • Page 33

    Tag changes since coldfusion 5 33 cfsearch category , categorytree , status , suggestions , contextpassages , contextbytes , contexthighlightbegin , contexthighlightend , previouscriteria attributes coldfusion mx 7 natural , internet , and internet_basic values of type attribute cfselect selected at...

  • Page 34

    34 chapter 2: coldfusion tags deprecated tags, attributes, and values the following tags, attributes, and attribute values are deprecated. Do not use them in coldfusion applications. They might not work, and might cause an error, in releases later than coldfusion mx. Tag attribute or value deprecate...

  • Page 35

    Tag changes since coldfusion 5 35 obsolete tags, attributes, and values the following tags, attributes, and attribute values are obsolete. Do not use them in coldfusion applications. They do not work, and might cause an error, in releases later than coldfusion 5. Cfservlet all coldfusion mx cfservle...

  • Page 36: Chapter 2

    36 chapter 2: coldfusion tags cfabort description stops the processing of a coldfusion page at the tag location. Coldfusion returns everything that was processed before the tag. The tag is often used with conditional logic to stop processing a page when a condition occurs. Category flow-control tags...

  • Page 37

    Cfabort 37 the value of myvariable after incrementing through the loop #counter# times is: #myvariable# and cferror the value of myvariable after incrementing through the loop#counter# times is: #myvariable#.

  • Page 38

    38 chapter 2: coldfusion tags cfapplet description this tag references a registered custom java applet. To register a java applet, in the coldfusion administrator, click extensions > java applets. Using this tag within a cfform tag is optional. If you use it within cfform , and the method attribute ...

  • Page 39

    Cfapplet 39 usage you can specify the applet method attribute only in the administrator, java applets view. For other attributes, you can accept the default values in the administrator view, or specify values in this tag and override the defaults. If java applet components are stored in a jar file, ...

  • Page 40

    40 chapter 2: coldfusion tags cfapplication description defines the scope of a coldfusion application; enables and disables storage of client variables; specifies the client variable storage mechanism; enables session variables; and sets application variable timeouts. Category application framework ...

  • Page 41

    Cfapplication 41 attributes attribute req/opt default description name see description name of application. Up to 64 characters. For application and session variables: required. For client variables: optional loginstorage optional cookie • cookie: store login information in the cookie scope. • sessi...

  • Page 42

    42 chapter 2: coldfusion tags usage this tag is typically used in the application.Cfm file, to set defaults for a coldfusion application. Note: you can also set the application defaults in the application.Cfc file. For more information, see “application variables” on page 945 . This tag enables appl...

  • Page 43

    Cfapplication 43 the coldfusion mx cross-site scripting protection operation is done when coldfusion mx processes the application settings at the beginning of a request. Thus, it can process the url, and cookie, cgi, and form variables in a user’s request. By default, it replaces occurrences of the ...

  • Page 44

    44 chapter 2: coldfusion tags.

  • Page 45

    Cfargument 45 cfargument description creates a parameter definition within a component definition. Defines a function argument. Used within a cffunction tag. Category extensibility tags syntax name="string" type="data type" required="yes" or "no" default="default value" displayname="descriptive name...

  • Page 46

    46 chapter 2: coldfusion tags usage this tag must be in a cffunction tag, before any other tags in the cffunction tag body. Arguments that are passed when a method is invoked can be accessed from the method body in the following ways: • with shorthand syntax: #myargument# (this example accesses the ...

  • Page 47

    Cfassociate 47 cfassociate description allows subtag data to be saved with a base tag. Applies only to custom tags. Category application framework tags syntax basetag = "base_tag_name" datacollection = "collection_name"> see also cfapplication , cferror , cflock , cfmodule ; “high-level data exchang...

  • Page 48

    48 chapter 2: coldfusion tags cfauthenticate description this tag is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications” in coldfusion mx developer’s guide. History coldfusion mx: this tag is obsolete. It does not work in coldfusion ...

  • Page 49

    Cfbreak 49 cfbreak description used within a cfloop or cfswitch tag. Breaks out of a loop or switch block. Category flow-control tags syntax see also cfabort , cfexecute , cfif , cflocation , cfloop , cfswitch , cfthrow , cftry ; “cfloop and cfbreak” in chapter 2, “elements of cfml,” in coldfusion m...

  • Page 50

    50 chapter 2: coldfusion tags searching....

  • Page 51

    Cfcache 51 cfcache description stores a copy of a page on the server and/or client computer, to improve page rendering performance. To do this, the tag creates temporary files that contain the static html returned from a coldfusion page. Use this tag if it is not necessary to get dynamic content eac...

  • Page 52

    52 chapter 2: coldfusion tags attributes usage use this tag in pages whose content is not updated frequently. Taking this action can greatly improve the performance of your application. The output of a cached page is stored in a file on the client browser and/or the coldfusion server. Instead of reg...

  • Page 53

    Cfcache 53 you can specify client-side caching or a combination of client-side and server-side caching (the default), using the action attribute. The advantage of client-side caching is that it requires no coldfusion resources; the browser stores pages in its own cache, improving performance. The ad...

  • Page 54

    54 chapter 2: coldfusion tags cfcalendar description puts an interactive macromedia flash format calendar in an html or flash form. Not supported in xml format forms. The calendar lets a user select a date for submission as a form variable. Category forms tags syntax name = "name of calendar" height...

  • Page 55

    Cfcalendar 55 startrange optional the start of a range of dates that are disabled. Users cannot select dates from this date through the date specified by the endrange attribute. Endrange optional the end of a range of dates that are disabled. Users cannot select dates from the date specified by the ...

  • Page 56

    56 chapter 2: coldfusion tags usage the cfcalendar tag displays a calendar month, showing the month, the year, a grid of the days of the month, and headings for the days of the week. The calendar contains forward and back arrow buttons to let you change the month and year that are displayed. If you ...

  • Page 57

    Cfcalendar 57 you selected #form.Selecteddate# please select a date on the calendar and click save. Selecteddate="#form.Selectdate#" startrange="#form.Startdate#" endrange="#form.Enddate#" mask="mmm dd, yyyy" daynames="su,mo,tu,we,th,fr,sa" monthnames="jan, feb, mar, apr, may, jun, jul, aug, sep, oc...

  • Page 58

    58 chapter 2: coldfusion tags cfcase description used only inside the cfswitch tag body. Contains code to execute when the expression specified in the cfswitch tag has one or more specific values. Category flow-control tags syntax value = "value or delimited set of values" delimiters = "delimiter ch...

  • Page 59

    Cfcase 59 your grade is #grade#.

  • Page 60

    60 chapter 2: coldfusion tags cfcatch description used inside a cftry tag. Together, they catch and process exceptions in coldfusion pages. Exceptions are events that disrupt the normal flow of instructions in a coldfusion page, such as failed database operations, missing include files, and develope...

  • Page 61

    Cfcatch 61 attributes usage you must code at least one cfcatch tag within a cftry block. Put cfcatch tags at the end of a cftry block. Coldfusion mx tests cfcatch tags in the order in which they appear. This tag requires an end tag. If type="any" , coldfusion mx catches exceptions from any cfml tag,...

  • Page 62

    62 chapter 2: coldfusion tags you can code cfcatch tags in any order to catch a custom exception type. If you specify type = "application" , the cfcatch tag catches only custom exceptions that have the application type in the cfthrow tag that defines them. The cfinclude , cfmodule , and cferror tags...

  • Page 63

    Cfcatch 63 advanced exception types you can specify the following advanced exception types in the type attribute: coldfusion advanced exception type com.Allaire.Coldfusion.Cfexecute.Outputerror com.Allaire.Coldfusion.Cfexecute.Timeout com.Allaire.Coldfusion.Fileexception com.Allaire.Coldfusion.Httpa...

  • Page 64

    64 chapter 2: coldfusion tags example select * from employeeas #cfcatch.Message# com.Allaire.Coldfusion.Httpnotmodified com.Allaire.Coldfusion.Httppartialcontent com.Allaire.Coldfusion.Httppaymentrequired com.Allaire.Coldfusion.Httppreconditionfailed com.Allaire.Coldfusion.Httpproxyauthenticationreq...

  • Page 65

    Cfcatch 65 caught an exception, type = #cfcatch.Type# the contents of the tag stack are:.

  • Page 66

    66 chapter 2: coldfusion tags cfchart description generates and displays a chart. Category data output tags , extensibility tags ; “controlling chart appearance” in chapter 31, “creating charts and graphs,” in coldfusion mx developer’s guide syntax syntax 1 style = "xml string or filename"> style = ...

  • Page 67

    Cfchart 67 see also cfchartdata , cfchartseries history coldfusion mx 7: • added style and title attributes. • added support for eight-digit hexadecimal values to specify rgb color and transparency. • removed the rotated attribute. • renamed the column chart type to be horizontalbar chart type. Cold...

  • Page 68

    68 chapter 2: coldfusion tags fontbold optional no whether to make the text bold: • yes • no fontitalic optional no whether to make the text italicized: • yes • no fontsize optional 11 font size; integer. Foregroundcolor optional black color of text, grid lines, and labels. Hexadecimal value or supp...

  • Page 69

    Cfchart 69 seriesplacement optional default relative positions of series in charts that have more than one data series. • default: coldfusion determines relative positions, based on graph types • cluster • stacked • percent show3d optional yes whether to display the chart with three- dimensional app...

  • Page 70

    70 chapter 2: coldfusion tags tipstyle optional mouseover determines the action that opens a pop-up window to display information about the current chart element. • mousedown: display if the user positions the cursor at the element and clicks the mouse. Applies only to flash format graph files. (for...

  • Page 71

    Cfchart 71 usage the cfchart tag defines a container in which a graph displays: its height, width, background color, labels, and so on. The cfchartseries tag defines the chart style in which data displays: bar, line, pie, and so on. The cfchartdata tag defines a data point. Data is passed to the cfc...

  • Page 72

    72 chapter 2: coldfusion tags for all other color values, you must enter the hexadecimal value. You can enter a six-digit value, which specifies the rgb value, or an eight-digit value, which specifies the rgb value and the transparency. The first two digits of an eight-digit hexadecimal value specif...

  • Page 73

    Cfchart 73 cfchart format="flash" xaxistitle="department" yaxistitle="salary average"> query="datatable" itemcolumn="dept_name" valuecolumn="avgsal"> query="datatable" itemcolumn="dept_name" valuecolumn="avgsal">.

  • Page 74

    74 chapter 2: coldfusion tags cfchartdata description used with the cfchart and cfchartseries tags. This tag defines chart data points. Its data is submitted to the cfchartseries tag. Category data output tags , extensibility tags syntax item = "text" value = "number"> see also cfchart , cfchartseri...

  • Page 75

    Cfchartdata 75 xaxistitle="department" yaxistitle="salary average"> itemcolumn="dept_name" valuecolumn="avgsal"> cfchartdata item="#datatable.Dept_name#" value="#datatable.Avgsal#"> xaxistitle="department" yaxistitle="salary average"> itemcolumn="dept_name" valuecolumn="avgsal"> cfchartdata item="#d...

  • Page 76

    76 chapter 2: coldfusion tags cfchartseries description used with the cfchart tag. This tag defines the chart style in which the data displays: bar, line, pie, and so on. Category data output tags , extensibility tags syntax colorlist = "list"> itemcolumn="querycolumn" markerstyle="style" paintstyle...

  • Page 77

    Cfchartseries 77 attributes attribute req/opt default description colorlist optional sets colors for each data point. Applies if the cfchartseries type attribute is pie , pyramid , area , horizontalbar , cone , cylinder , or step . Comma-delimited list of hexadecimal values or supported, named web c...

  • Page 78

    78 chapter 2: coldfusion tags usage for a pie chart, coldfusion sets pie slice colors as follows: • if the seriescolor attribute is omitted, coldfusion automatically determines the colors of the slices. • if the seriescolor attribute is specified, coldfusion automatically determines the colors of th...

  • Page 79

    Cfchartseries 79 select dept_name, avg(salary) as avgsal, sum(salary) as sumsal from getsalaries group by dept_name xaxistitle="department" yaxistitle="salary average"> query="datatable" itemcolumn="dept_name" valuecolumn="avgsal" /> xaxistitle="department" yaxistitle="salary average"> query="datata...

  • Page 80

    80 chapter 2: coldfusion tags cfcol description defines table column header, width, alignment, and text. Used within a cftable tag. Category data output tags syntax header = "column_header_text" width = "number_indicating_width_of_column" align = "left" or "right" or "center" text = "column_text"> s...

  • Page 81

    Cfcol 81 example select emp_id, firstname, lastname, email, phone, department from employees query = "getemployees" startrow = "1" colspacing = "3" htmltable colheaders> align = "left" width = 2 text = "#emp_id#"> align = "left" width = 15 text = "#firstname# #lastname#"> align = "center" width = 15...

  • Page 82

    82 chapter 2: coldfusion tags cfcollection description creates and administers verity search engine collections. Category extensibility tags syntax action = "action" collection = "collection_name" path = "path_to_verity_collection" language = "language" name = "queryname" categories = "yes" or "no">...

  • Page 83

    Cfcollection 83 attributes usage with this tag you can create, register, and administer a verity collection that was created by coldfusion or by a verity application. Attribute req/opt default description action required; see usage list • categorylist: retrieves categories from the collection and in...

  • Page 84

    84 chapter 2: coldfusion tags the following table shows the dependence relationships among this tag’s attribute values: the following examples illustrate the structures returned by the categorylist action: the list action returns the following information in a result set that contains one row per co...

  • Page 85

    Cfcollection 85 the coldfusion mx administrator verity > collections page displays the information that is returned when you use the list attribute. If the verity server is not running when the list action is executed, the tag throws an error. To determine whether a collection exists, use code, such...

  • Page 86

    86 chapter 2: coldfusion tags the default location of verity collections is as follows: • server configuration: ■ windows: c:\cfusionmx7\verity\collections ■ unix system: /opt/coldfusionmx7/verity/collections • j2ee configuration: webapp_root/web-inf/cfusion/verity/collections example path="#collpat...

  • Page 87

    Cfcollection 87 create this collection optimize this collection repair this collection delete this collection collection on which to act use the default value or enter your own collection name.

  • Page 88

    88 chapter 2: coldfusion tags cfcomponent description creates and defines a component object; encloses functionality that you build in cfml and enclose within cffunction tags. This tag contains one or more cffunction tags that define methods. Code within the body of this tag, other than cffunction t...

  • Page 89

    Cfcomponent 89 history coldfusion mx 7: • added support for publishing document-literal style web services. • added the style , namespace , serviceportname , porttypename , wsdlfile , and bindingname attributes. • extended functionality for the hint and displayname attributes when publishing documen...

  • Page 90

    90 chapter 2: coldfusion tags usage if you specify the extends attribute, the data and methods of the parent component are available to cfc methods as if they were parts of the current component. If the managercfc component extends the employeecfc component, and the employeecfc component has a getem...

  • Page 91

    Cfcomponent 91 example select firstname, lastname, email from tblemployees select * from tbldepartments.

  • Page 92

    92 chapter 2: coldfusion tags cfcontent description does either or both of the following: • sets the mime content encoding header for the current page; if the encoding information includes a character encoding, sets the character encoding of generated output. • sends the contents of a file, or of a ...

  • Page 93

    Cfcontent 93 attributes attribute req/opt default description type optional the mime content type of the page, optionally followed by a semicolon and the character encoding. By default, coldfusion sends pages as text/html content type in the utf-8 character encoding. The content type determines how ...

  • Page 94

    94 chapter 2: coldfusion tags usage to set the character encoding (character set) of generated output, including the page html, use code such as the following: when coldfusion processes an http request, it determines the character encoding to use for the data it returns in the http response. By defa...

  • Page 95

    Cfcontent 95 for file types that might contain executable code, such as microsoft excel documents, most browsers always ask before opening the document. For these file types, the inline content disposition specification requests the browser to display the file directly if the user selects to open th...

  • Page 96

    96 chapter 2: coldfusion tags deletefile="yes"> monthquantity$ sales january80$245 february100$699 march230$2036 total=sum(b2..B4)=sum(c2..C4) deletefile="yes">.

  • Page 97

    Cfcookie 97 cfcookie description defines web browser cookie variables, including expiration and security options. Category forms tags , variable manipulation tags syntax name = "cookie_name" value = "text" expires = "period" secure = "yes" or "no" path = "url" domain = ".Domain"> see also cfdump , c...

  • Page 98

    98 chapter 2: coldfusion tags usage if this tag specifies that a cookie is to be saved beyond the current browser session, the client browser writes or updates the cookie in its local cookies file. Until the browser is closed, the cookie resides in browser memory. If the expires attribute is not spe...

  • Page 99

    Cfcookie 99 example select email, fromuser, subject, posted from comments value = "#now()#" expires = "now"> value = "#email#" expires = "now" > value = "#now()#" expires = "10"> the last aol visitor to view this site was #cookie.Lastaolvisitor#, on #dateformat(cookie.Timevisited)# hide my tracks no...

  • Page 100

    100 chapter 2: coldfusion tags cfdefaultcase description used only inside the cfswitch tag body. Contains code to execute when the expression specified in the cfswitch tag does not match a of the value specified by a cfcase tag. Category flow-control tags syntax see also cfcase , cfswitch ; “cfswitc...

  • Page 101

    Cfdefaultcase 101 your grade is #grade#.

  • Page 102

    102 chapter 2: coldfusion tags cfdirectory description manages interactions with directories. Category file management tags syntax action = "directory action" directory = "directory name" name = "query name" filter = "list filter" mode = "permission" sort = "sort specification" newdirectory = "new d...

  • Page 103

    Cfdirectory 103 attributes attribute req/opt default description action optional list • list: returns a query record set of the files in the specified directory. The directory entries "." (dot) and ".." (dot dot), which represent the current directory and the parent directory, are not returned. • cr...

  • Page 104

    104 chapter 2: coldfusion tags usage if you put coldfusion applications on a server that is used by multiple customers, you must consider the security of files and directories that could be uploaded or otherwise manipulated with this tag by unauthorized users. For more information about securing col...

  • Page 105

    Cfdirectory 105 the following table shows examples of patterns and file names that they match: example = "#newdirectory#" > the directory existed and the name has been changed to: #newdirectory# p> your directory has been created. "othernewdir"> name="mydirectory"> files exist in this directory. Eit...

  • Page 106

    106 chapter 2: coldfusion tags the directory did not exist. The directory did not exist. Select * from dirquery where type='dir'.

  • Page 107

    Cfdocument 107 cfdocument description creates pdf or flashpaper output from a text block containing cfml and html. Category data output tags syntax format = "pdf" or "flashpaper" filename = "filename" overwrite = "yes" or "no" name = "output variable name" pagetype = "page type" pageheight = "page h...

  • Page 108

    108 chapter 2: coldfusion tags overwrite optional no specifies whether coldfusion mx overwrites an existing file. Used in conjunction with the filename attribute name optional specifies the name of an existing variable into which the tag stores the pdf or flashpaper output. Pagetype optional a4 spec...

  • Page 109

    Cfdocument 109 usage use the cfdocument tag to render html and cfml output into pdf or flashpaper format. Coldfusion mx does not return html and cfml outside of the pair. The cfdocument tag can render html that supports the following standards: • html 4.01 • xml 1.0 • dom level 1 and 2 • css1 and cs...

  • Page 110

    110 chapter 2: coldfusion tags the cfdocument tag does not support the internet explorer-specific html generated by microsoft word. The pdf or flashpaper document returned by the cfdocument tag overwrites any previous html in the input stream and ignores any html after the tag. You cannot embed a cf...

  • Page 111

    Cfdocumentitem 111 cfdocumentitem description specifies action items for a pdf or flashpaper document created by the cfdocument tag. Actions include the following: • page break • header • footer category data output tags syntax syntax 1 syntax 2 type = "header" or "footer"> header/footer text type =...

  • Page 112

    112 chapter 2: coldfusion tags you can use the cfdocument scope variable, cfdocument.Currentpagenumber, to display the current page number in a header or footer. You can also use cfdocument.Totalpagecount to display the total number of pages. For example: ... #cfdocument.Currentpagenumber# of #cfdoc...

  • Page 113

    Cfdocumentsection 113 cfdocumentsection description divides a pdf or flashpaper document into sections. By using this tag in conjunction with a cfdocumentitem tag, each section can have unique headers, footers, and page numbers. Category data output tags syntax margintop = "number" marginbottom = "n...

  • Page 114

    114 chapter 2: coldfusion tags usage use the cfdocumentsection tag to divide a report into sections. Within each cfdocumentsection tag, you can use one or more cfdocumentitem tags to specify unique headers and footers for each section. When using cfdocumentsection , coldfusion mx ignores html and cf...

  • Page 115

    Cfdocumentsection 115.

  • Page 116

    116 chapter 2: coldfusion tags cfdump description use the cfdump tag to get the elements, variables, and values of most kinds of coldfusion objects. Useful for debugging. You can display the contents of simple and complex variables, objects, components, user-defined functions, and other elements. Ca...

  • Page 117

    Cfdump 117 usage the expand/contract display capability is useful when working with large structures, such as xml document objects, structures, and arrays. To display a construct, use code such as the following, in which mydoc is a variable of type xmldocument: the tag output is color-coded accordin...

  • Page 118

    118 chapter 2: coldfusion tags cfelse description used as the last control block in a cfif tag block to handle any case not identified by the cfif tag or a cfelseif tag. Category flow-control tags syntax html and cfml tags html and cfml tags html and cfml tags see also cfif , cfelseif , cfabort , cf...

  • Page 119

    Cfelseif 119 cfelseif description used as a control block in a cfif tag block to handle any case not identified by the cfif tag or a cfelseif tag. Category flow-control tags syntax expression> html and cfml tags expression> html and cfml tags html and cfml tags expression> html and cfml tags express...

  • Page 120

    120 chapter 2: coldfusion tags cferror description displays a custom html page when an error occurs. This lets you maintain a consistent look and feel among an application’s functional and error pages. Category exception handling tags , extensibility tags , application framework tags syntax type = "...

  • Page 121

    Cferror 121 usage use this tag to provide custom error messages for pages in an application. This lets you maintain a consistent look and feel within the application, even when errors occur. You generally embed this tag in your application cfc or application.Cfm file to specify error- handling respo...

  • Page 122

    122 chapter 2: coldfusion tags error variables the exception-handling page specified in the cferror tag template attribute contains one or more error variables. Coldfusion substitutes the value of the error variable when an error displays. The following table lists error variables: request includes ...

  • Page 123

    Cferror 123 note: if type = "exception" , you can substitute the prefix cferror for error ; for example, cferror.Diagnostics, cferror.Mailto , or cferror.Datetime . Example template = "request_err.Cfm" mailto = "admin@mywebsite.Com"> select * from nothing template = "request_err.Cfm" mailto = "admin...

  • Page 124

    124 chapter 2: coldfusion tags cfexecute description executes a coldfusion developer-specified process on a server computer. Category extensibility tags , flow-control tags syntax name = "application name" arguments = "command line arguments" outputfile = "output filename" variable = "variable name"...

  • Page 125

    Cfexecute 125 usage do not put other coldfusion tags or functions between the start and end tags of cfexecute . You cannot nest cfexecute tags. Exceptions throws the following exceptions: • if the application name is not found: java.Io.Ioexception • if the effective user of the coldfusion executing ...

  • Page 126

    126 chapter 2: coldfusion tags cfexit description this tag aborts processing of the currently executing cfml custom tag, exits the page within the currently executing cfml custom tag, or re-executes a section of code within the currently executing cfml custom tag. Category debugging tags , flow-cont...

  • Page 127

    Cfexit 127 example cfexit can be used to abort the processing of the currently executing cfml custom tag. Execution resumes following the invocation of the custom tag in the page that called the tag. Cfexit is used primarily to perform a conditional stop of processing inside a custom tag. Cfexit ret...

  • Page 128

    128 chapter 2: coldfusion tags cffile description manages interactions with server files. The following sections describe the actions of the cffile tag: • cffile action = "append" on page 131 • cffile action = "copy" on page 133 • cffile action = "delete" on page 135 • cffile action = "move" on page...

  • Page 129

    Cffile 129 coldfusion mx: • changed use of slashes in paths: you can use forward (/) or backward (\) slashes in paths on both unix and windows systems. • changed file hierarchy requirements: coldfusion does not require that you put files and directories that you manipulate with this tag below the ro...

  • Page 130

    130 chapter 2: coldfusion tags a file exists (foobar.Txt, in #gettempdirectory()#). You may add to it, read from it, or delete it. #readtext# make new file add to existing file delete file read existing file.

  • Page 131

    Cffile 131 cffile action = "append" description appends text to a text file on the server. Syntax action = "append" file = "full_path_name" output = "string" addnewline = "yes" or "no" attributes = "file_attributes_list" mode = "mode" charset = "charset_option" > see also cfdirectory history see the...

  • Page 132

    132 chapter 2: coldfusion tags example text"> this a test?"> attributes optional applies to windows. A comma-delimited list of attributes to set on the file. If omitted, the file’s attributes are maintained. Each value must be specified explicitly. For example, if you specify attributes = "readonly"...

  • Page 133

    Cffile 133 cffile action = "copy" description copies a file from one directory to another on the server. Syntax action = "copy" source = "full_path_name" destination = "full_path_name" mode = "mode" attributes = "file_attributes_list"> see also cfdirectory history see the history section of the main...

  • Page 134

    134 chapter 2: coldfusion tags example this example copies the keymemo.Doc file to the c:\files\backup\ directory: source = "c:\files\upload\keymemo.Doc" destination = "c:\files\backup\"> source = "c:\files\upload\keymemo.Doc" destination = "c:\files\backup\">.

  • Page 135

    Cffile 135 cffile action = "delete" description deletes a file on the server. Syntax action = "delete" file = "full_path_name"> see also cfdirectory attributes example the following example deletes the specified file: file = "c:\files\upload\#variables.Deletefilename#"> attribute req/opt default des...

  • Page 136

    136 chapter 2: coldfusion tags cffile action = "move" description moves a file from one location to another on the server. Syntax action = "move" source = "full_path_name" destination = "full_path_name" mode = "mode" attributes = "file_attributes_list" charset = "charset_option"> see also cfdirector...

  • Page 137

    Cffile 137 example the following example moves the keymemo.Doc file from the c:\files\upload\ directory to the c:\files\memo\ directory in windows: action = "move" source = "c:\files\upload\keymemo.Doc" destination = "c:\files\memo\"> in this example, the destination directory is “memo.” attributes ...

  • Page 138

    138 chapter 2: coldfusion tags cffile action = "read" description reads a text file on the server. The file is read into a dynamic, local variable that you can use in the page. For example: • read a text file; insert the file’s contents into a database • read a text file; use the find and replace fu...

  • Page 139

    Cffile 139 usage the following example creates a variable named message for the contents of the file message.Txt: file = "c:\web\message.Txt" variable = "message"> the variable message can be used in the page. For example, you could display the contents of the message.Txt file in the final web page ...

  • Page 140

    140 chapter 2: coldfusion tags cffile action = "readbinary" description reads a binary file (such as an executable or image file) on the server, into a binary object parameter that you can use in the page. To send it through a web protocol (such as http or smtp) or store it in a database, first conv...

  • Page 141

    Cffile 141 cffile action = "rename" description renames or moves a file on the server. Syntax action = "rename" source = "full_path_name" destination = "path_name" mode = "mode" attributes = "file_attributes_list"> see also cfdirectory history see the history section of the main cffile tag page. Att...

  • Page 142

    142 chapter 2: coldfusion tags example windows example: destination = "c:\files\memoormalmemo.Doc" attributes="normal"> unix example: "#mywr#/memo/other_sample.Txt" mode="666"> destination = "c:\files\memoormalmemo.Doc" attributes="normal"> unix example: "#mywr#/memo/other_sample.Txt" mode="666"...

  • Page 143

    Cffile 143 cffile action = "upload" description copies a file to a directory on the server. Syntax action = "upload" filefield = "formfield" destination = "full_path_name" nameconflict = "behavior" accept = "mime_type/file_type" mode = "permission" attributes = "file_attribute_or_list"> result = "re...

  • Page 144

    144 chapter 2: coldfusion tags usage after a file upload is completed, you can get status information using file upload parameters. To refer to parameters, use either the cffile prefix or, if you specified an alternate name in the result attribute, the name you specified there . For example, if you ...

  • Page 145

    Cffile 145 note: file status parameters are read-only. They are set to the results of the most recent cffile operation. If two cffile tags execute, the results of the second overwrite the first, unless you have specified a different result variable in the result attribute. Example the following exam...

  • Page 146

    146 chapter 2: coldfusion tags cffile action = "write" description writes a text file on the server, based on dynamic content. You can create static html files from the content, or log actions in a text file. Syntax action = "write" file = "full_path_name" output = "content" mode = "permission" addn...

  • Page 147

    Cffile 147 example this example creates a file with information a user entered in an html insert form: file = "c:\files\updates\#form.Updatetitle#.Txt" output = "created by: #form.Fullname# date: #form.Date# #form.Content#"> if the user submitted a form with the following: updatetitle = "fieldwork" ...

  • Page 148

    148 chapter 2: coldfusion tags this example shows the use of the mode attribute for unix. It creates the file /tmp/foo with permissions rw-r--r-- (owner = read/write, group = read, other = read): file = "/tmp/foo" mode = 644> this example appends to the file and sets permissions to read/write (rw) f...

  • Page 149

    Cfflush 149 cfflush description flushes currently available data to the client. Category data output tags , page processing tags syntax interval = "integer number of bytes"> see also cfcache , cfheader , cfinclude , cfsetting , cfsilent attributes usage the first occurrence of this tag on a page sen...

  • Page 150

    150 chapter 2: coldfusion tags example the following example uses cfloop tags and the rand random number generating function to delay data display. It simulates a page that is slow to generate data. It will take us a little while to calculate your ten magic numbers. It takes a lot of work to find nu...

  • Page 151

    Cfform 151 cfform description builds a form with cfml custom control tags; these provide more functionality than standard html form input elements. You can include the resulting form on the client page as html or flash content, and generate the form using xml and xslt. Category forms tags syntax nam...

  • Page 152

    152 chapter 2: coldfusion tags • deprecated the passthrough attribute. The tag now supports all html form tag attributes directly. • added the method attribute and support for the get method. • added support for flash and xml output, including the format , height , width , preloader , timeout , wmod...

  • Page 153

    Cfform 153 format html, flash, xml opt html • html: generates an html form and send it to the client. Cfgrid and cftree child controls can be in flash or applet format. • flash: generates a flash form and send it to the client. All controls are in flash format. • xml: generates xforms-compliant xml ...

  • Page 154

    154 chapter 2: coldfusion tags style html, flash, xml opt styles to apply to the form. In html or xml format, coldfusion passes the style attribute to the browser or xml. In flash format, must be a style specification in css format. For detailed information on specifying flash styles, see chapter 29...

  • Page 155

    Cfform 155 scriptsrc html, flash xml opt see description specifies the url, relative to the web root, of the directory that contains the cfform.Js file with the client-side javascript used by this tag and its child tags. For xml format forms, this directory is also the default directory for xslt ski...

  • Page 156

    156 chapter 2: coldfusion tags note: attributes that are not marked as supported in xml are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml as html namespace attributes to the form tag. Usage this tag requires an end tag. You can use the followi...

  • Page 157

    Cfform 157 in html format, all tags, and in flash format the cftree and cfgrid tags, require javascript support on the browser. The cfapplet tag and applet format cfgrid , cfslider , and cftree tags require the client to download a java applet. If you specify flash format in the cfform tag, coldfusi...

  • Page 158

    158 chapter 2: coldfusion tags in html format, the cfform tag lets you incorporate the following standard html elements. They are not available in flash format: • standard html form tag attributes and values. The attributes and values are included in the form tag that cfform outputs in the page. For...

  • Page 159

    Cfform 159 please enter a credit card number: message = "please enter a credit card number" validate = "creditcard" required = "no"> this example shows the use of the cfslider tag. Message = "please enter a credit card number" validate = "creditcard" required = "no"> rate your approval of this examp...

  • Page 160

    160 chapter 2: coldfusion tags cfformgroup description creates a container control for multiple form controls. Used in the cfform tag body of macromedia flash and xml forms. Ignored in html forms. Category forms tags syntax type = "group type" label = "label" style = "style specification" selectedin...

  • Page 161

    Cfformgroup 161 note: attributes that are not marked as supported in xml are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml attribute req/opt; formats default description type required; flash and xml xml: can be any xforms group type defined in...

  • Page 162

    162 chapter 2: coldfusion tags type (continued) • hdividedbox: aligns children horizontally. Each child is in a box with a border, and there are dividers between the boxes that users can move to change the relative sizes of the children. Use a tag with this attribute to arrange groups of form contro...

  • Page 163

    Cfformgroup 163 usage this tag requires an end tag. This tag is ignored if the cfform type is html; any tag body’s contents are interpreted as if the surrounding cfformgroup does not exist. Label optional; flash and xml label to apply to the form group. In flash, does the following: • for a page or ...

  • Page 164

    164 chapter 2: coldfusion tags in flash format forms, this tag organizes the contents of the form. It groups and arranges child tags. The body of this tag can contain the following tags; all other tags and text are ignored: • cfformgroup • cfformitem • cfcalendar • cfgrid • cfinput • cfselect • cfte...

  • Page 165

    Cfformgroup 165 the following more complex example shows more fully how you can use cfformgroup tags to arrange controls in a flash form. It also shows many of the text formatting features that you can use in a text cfformgroup body. When you submit the form, the page dumps the contents of the forms...

  • Page 166

    166 chapter 2: coldfusion tags tell us your preferences pets: checked> fruits: value="apples"> value="bananas"> value="pears"> value="oranges"> value="grapes"> value="cumquats"> checked> fruits: value="apples"> value="bananas"> value="pears"> value="oranges"> value="grapes"> value="cumquats"> value=...

  • Page 167

    Cfformitem 167 cfformitem description inserts a horizontal line, a vertical line, a spacer, or text in a flash form. Used in the cfform or cfformgroup tag body for flash and xml forms. Ignored in html forms. Category forms tags syntax type = "hrule, vrule, or spacer" style = "style specification" wi...

  • Page 168

    168 chapter 2: coldfusion tags note: attributes that are marked as flash only are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml in all controls except text and html types. Attribute req/opt; formats default description type required; flash and...

  • Page 169

    Cfformitem 169 note: attributes that are marked as flash only are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml in all controls except text and html types. Usage this tag requires an end tag or a slash before the closing end character of the o...

  • Page 170

    170 chapter 2: coldfusion tags cfftp description lets users implement file transfer protocol (ftp) operations. Category file management tags , internet protocol tags syntax the tag syntax depends on the action attribute value. See the following sections: • “cfftp: opening and closing ftp server conn...

  • Page 171

    Cfftp: opening and closing ftp server connections 171 cfftp: opening and closing ftp server connections description to establish a connection with an ftp server, you use the open action with a connection attribute. Syntax action = "action" username = "name" password = "password" server = "server" ti...

  • Page 172

    172 chapter 2: coldfusion tags usage when you establish a connection with cfftp action="open" and specify a name in the connection attribute, coldfusion caches the connection so that you can reuse it to perform additional ftp operations. When you use a cached connection for subsequent ftp operations...

  • Page 173

    Cfftp: opening and closing ftp server connections 173 username = "anonymous" connection = "my_query" password = "youremail@email.Com" server = "ftp.Tucows.Com" stoponerror = "yes"> did it succeed? #cfftp.Succeeded# list the files in a directory: stoponerror = "yes" name = "listfiles" directory = "/"...

  • Page 174

    174 chapter 2: coldfusion tags cfftp: connection: file and directory operations description use this form of the cfftp tag to perform file and directory operations with cfftp . Syntax action = "action" username = "name" password = "password" name = "query_name" server = "server" asciiextensionlist =...

  • Page 175

    Cfftp: connection: file and directory operations 175 name required if action = "listdir" query name of directory listing. Server required if ftp connection is not cached ftp server to which to connect; for example, ftp.Myserver.Com . Asciiextension list optional txt;htm;html; cfm;cfml; shtm;shtml; c...

  • Page 176

    176 chapter 2: coldfusion tags usage if you use connection caching to an active ftp connection, you do not have to respecify the username , password , or server connection attributes. Changing a cached connection, such as changing retrycount or timeout values, might require reestablishing the connec...

  • Page 177

    Cfftp: connection: file and directory operations 177 example the following example opens a connection and gets a file listing showing file or directory name, path, url, length, and modification date: open a connection username = "myusername" password = "myusername@allaire.Com" server = "ftp.Allaire....

  • Page 178

    178 chapter 2: coldfusion tags cfftp action = "listdir" description to access the columns in a query object, use this tag with action = "listdir" . Usage when you use this action, you must specify a value for the name attribute. This value holds the results of the listdir action in a query object. T...

  • Page 179

    Cffunction 179 cffunction description defines a function that you can call in cfml. Required to define coldfusion component methods. History coldfusion mx 7: added the xml value to the returntype attribute. Coldfusion mx: added this tag. Category extensibility tags syntax name = "methodname" returnt...

  • Page 180

    180 chapter 2: coldfusion tags attributes attribute req/opt default description name required a string; a component method that is used within the cfcomponent tag. Returntype required for a web service; optional, otherwise. Any string; a type name; data type of the function return value: • any • arr...

  • Page 181

    Cffunction 181 usage the cffunction tag can define a function that you call in the same manner as a coldfusion built-in function. To define a coldfusion component (cfc) method, you must use a cffunction tag. The following example shows cffunction tag attributes for a simple cfc method that returns a...

  • Page 182

    182 chapter 2: coldfusion tags for information on using the cffunction tag for coldfusion components, see chapter 10, “building and using coldfusion components” in coldfusion mx developer’s guide. If you specify a roles attribute, the function executes only if a user is logged in and belongs to one ...

  • Page 183

    Cfgraph 183 cfgraph description this tag is deprecated. Use the cfchart , cfchartdata , and cfchartseries tags instead. Displays data graphically. History coldfusion mx: deprecated this tag. It works differently than it did in coldfusion 5, and it might not work in later releases. The incompatibilit...

  • Page 184

    184 chapter 2: coldfusion tags depth • 0: displays graph with two-dimensional appearance. • any other value: displays graph with threedimensional appearance. Linewidth ignored. Showvaluelabel • yes: displays values on mouse-click. • no: suppresses value displays. • rollover: displays values on mouse...

  • Page 185

    Cfgraphdata 185 cfgraphdata description this tag is deprecated. Use the cfchart , cfchartdata , and cfchartseries tags instead. Displays a data point in a graph. Used within the cfgraph tag. History coldfusion mx: deprecated this tag. It works differently than in coldfusion 5 and might not work in l...

  • Page 186

    186 chapter 2: coldfusion tags cfgrid description used within the cfform tag. Puts a grid control (a table of data) in a coldfusion form. To specify grid columns and row data, use the cfgridcolumn and cfgridrow tags, or use the query attribute, with or without cfgridcolumn tags. Category forms tags ...

  • Page 187

    Cfgrid 187 onvalidate = "javascript_function" onerror = "text" griddataalign = "position" rowheaders = "yes" or "no" rowheaderalign = "position" rowheaderfont = "font_name" rowheaderfontsize = "size" rowheaderitalic = "yes" or "no" rowheaderbold = "yes" or "no" rowheadertextcolor = "web color" colhe...

  • Page 188

    188 chapter 2: coldfusion tags attributes note: in xml format, coldfusion mx passes all attributes to the xml. The supplied xslt skins do not handle or display xml format grids, but do display applet and flash format grids. Attribute req/opt; formats default description name required; all name of th...

  • Page 189

    Cfgrid 189 textcolor optional; all black color of text. Can be a hexadecimal value or a named color. For a hexadecimal value, use the form " ##xxxxxx " , where x = 0-9 or a-f; use two number signs or none. For a list of the supported named colors, see cfchart . Selectcolor optional; all background c...

  • Page 190

    190 chapter 2: coldfusion tags visible optional; flash yes flash format only: boolean value specifying whether to show the control. Space that would be occupied by an invisible control is blank. Tooltip optional; flash flash format only: text to display when the mouse pointer hovers over the control...

  • Page 191

    Cfgrid 191 href optional; applet url or name of a query column that contains urls to hyperlink each grid cell with. Target optional; applet the target frame or window in which to display the href url; for example, "_blank". Appendkey optional; applet yes • yes: when used with href , appends "cfgridk...

  • Page 192

    192 chapter 2: coldfusion tags usage this tag must be in a cfform tag block. An applet format grid requires the client to download a java applet. Also, if the client does not have an up-to-date java plugin installed, the system might also have to download an updated java plugin to display the an app...

  • Page 193

    Cfgrid 193 note: clicking the submit button while editing a grid cell occasionally causes the cell changes to be lost. To ensure that changes are submitted properly, macromedia recommends that after user updates data in a cell, they click another cell before submitting the form. How data is returned...

  • Page 194

    194 chapter 2: coldfusion tags each table row that contains an update, insert, or deletion has a parallel entry in each of these arrays. To view all the information for all the changes, you can traverse the arrays, as in this example. To make it work with a cfgrid on a submitted cfform , set the gri...

  • Page 195

    Cfgrid 195 using the href attribute when specifying a url with grid items using the href attribute, the selectmode attribute value determines whether the appended key value is limited to one grid item or extends to a grid column or row. When a user clicks a linked grid item, a cfgridkey variable is ...

  • Page 196

    196 chapter 2: coldfusion tags cfgridcolumn description used with the cfgrid tag in a cfform . Formats a columns and optionally populates the column from a query. The font and alignment attributes used in cfgridcolumn override global font or alignment settings defined in cfgrid . Category forms tags...

  • Page 197

    Cfgridcolumn 197 coldfusion mx: changed behavior if select="no" : a user cannot select and edit the cell data, regardless of the cfgrid selectmode attribute value. When clicked, the cell border (and, depending on the selectcolor value, the cell background) changes color, but the cell data cannot be ...

  • Page 198

    198 chapter 2: coldfusion tags type optional; all you can specify the following values in all formats: • image: grid displays the image specified by the url in the column. If you use a relative url, the image must be in the cfide\classes directory or a subdirectory. If image is larger than column ce...

  • Page 199

    Cfgridcolumn 199 fontsize optional; all as specified by cfgrid size of text in column. Italic optional; all as specified by cfgrid • yes: displays grid control text in italics. • no bold optional; all as specified by cfgrid • yes: displays grid control text in bold. • no textcolor optional; all colo...

  • Page 200

    200 chapter 2: coldfusion tags mask optional; flash a mask pattern that controls the character pattern that the form displays or allows users to input and sends to coldfusion. For columns with the currency type attribute, the mask specifies the currency symbol. Coldfusion mx automatically inserts th...

  • Page 201

    Cfgridcolumn 201 numberformat mask characters in applet format only, you can use the following numberformat attribute mask characters to format output in u.S. Numeric and currency styles. For more information on using these mask characters, see numberformat on page 783 . (the cfgridcolumn tag does n...

  • Page 202

    202 chapter 2: coldfusion tags date/time formats in mask attribute by default, flash displays date/time values in grid columns using a format that shows values such as oct 29 2004 11:03:21. Use the mask attribute to display the date or time in a different format, as described in the following table:...

  • Page 203

    Cfgridcolumn 203 example the following example lets you update certain fields of the courselist table in the cfdocexamples database. It uses cfgridcolumn tags to structure the table. Tablename = "courselist" keyonly = "yes"> select course_id, dept_id, cornumber, corname, corlevel, cordesc from cours...

  • Page 204

    204 chapter 2: coldfusion tags width="65"> width="65">.

  • Page 205

    Cfgridrow 205 cfgridrow description lets you define a cfgrid control that does not use a query as source for row data. If a query attribute is specified in the cfgrid tag, the cfgridrow tags are ignored. Category forms tags syntax data = "col1, col2, ..."> see also cfgrid , cfgridcolumn , cfgridupda...

  • Page 206

    206 chapter 2: coldfusion tags cfgridupdate description used within a cfgrid tag. Updates data sources directly from edited grid data. This tag provides a direct interface with your data source. This tag applies delete row actions first, then insert row actions, then update row actions. If it encoun...

  • Page 207

    Cfgridupdate 207 example the following example lets you update a database by using a cfgrid tag to add and delete entire records or to update the data in individual cells. The cfgridupdate tag processes the data from the submitted form and updates the database. Tablename = "courselist"> select cours...

  • Page 208

    208 chapter 2: coldfusion tags cfheader description generates custom http response headers to return to the client. Category data output tags , page processing tags syntax name = "header_name" value = "header_value" charset="charset"> or statuscode = "status_code" statustext = "status_text"> see als...

  • Page 209

    Cfheader 209 usage if you use this tag after the cfflush tag on a page, an error is thrown. Example cfheader generates custom http response headers to return to the client. This example forces browser client to purge its cache of requested file. Statuscode required if name not specified number. Http...

  • Page 210

    210 chapter 2: coldfusion tags cfhtmlhead description writes text to the head section of a generated html page. Category page processing tags syntax text = "text"> see also cfcache , cfflush , cfheader , cfheader , cfinclude , cfsetting , cfsilent attributes usage use this tag for embedding javascri...

  • Page 211

    Cfhtmlhead 211 description #item.Description.Xmltext# applies to these products #item.Subject[i].Xmltext#.

  • Page 212

    212 chapter 2: coldfusion tags cfhttp description generates an http request and handles the response from the server. Category internet protocol tags syntax url = "server_url" port = "port_number" method = "method_name" proxyserver = "hostname" proxyport = "port_number" proxyuser = "username" proxyp...

  • Page 213

    Cfhttp 213 • modified response body content types considered to be text. • changed behavior for multiple headers: multiple headers of the same type are returned in an array. • added support for https proxy tunneling. • fixed bugs in code and documentation. Coldfusion mx: • added the charset and firs...

  • Page 214

    214 chapter 2: coldfusion tags method opt get • get: requests information from the server. Any data that the server requires to identify the requested information must be in the url or in cfhttp type="url" tags. • post: sends information to the server for processing. Requires one or more cfhttpparam...

  • Page 215

    Cfhttp 215 charset opt for request: utf-8 for response: charset specified by response content- type header, or utf-8 if response does not specify charset. The character encoding of the request, including the url query string and form or file data, and the response. The following list includes common...

  • Page 216

    216 chapter 2: coldfusion tags redirect opt yes if the response header includes a location field and coldfusion receives a 300-series (redirection) status code, specifies whether to redirect execution to the url specified in the field: • yes: redirects execution to the specified page. • no: stops ex...

  • Page 217

    Cfhttp 217 the following attribute is used with the put method to determine how to send data specified with httpparam type="formfield" : the following attribute allows you to specify the name of the variable in which you would like the results of the operation returned. The name you specify replaces...

  • Page 218

    218 chapter 2: coldfusion tags the following attributes tell coldfusion to convert the http response body into a coldfusion query object. They can be used with the get and post methods only. Usage the cfhttp tag is a general-purpose tool for creating http requests and handling the returned results. ...

  • Page 219

    Cfhttp 219 when coldfusion receives a response to a cfhttp request, it can put the response body (if any) in a file or the cfhttp.Filecontent string variable. If the body text is structured as a result set, coldfusion can put the body text in query object. You can also access the values of all retur...

  • Page 220

    220 chapter 2: coldfusion tags variables returned by a cfhttp get operation the cfhttp tag returns the following variables. If you set the result attribute, the name you assign replaces cfhttp as the prefix. For additional information, see the result attribute. Building a query from a delimited text...

  • Page 221

    Cfhttp 221 run the following code to show how coldfusion treats this data: url="127.0.0.1:8500/tests/escapetest.Txt" name="onerow"> column names can be specified in three ways: • by default, coldfusion uses the first row of the response as the column names. • if you specify a comma-delimited columns...

  • Page 222

    222 chapter 2: coldfusion tags #item.Title.Xmltext# a> author #item.Author.Xmltext# applies to these products #item.Xmlchildren[i].Xmlattributes.Name#.

  • Page 223

    Cfhttpparam 223 cfhttpparam description allowed inside cfhttp tag bodies only. Required for cfhttp post operations. Optional for all others. Specifies parameters to build an http request. Category internet protocol tags syntax type = "transaction type" name = "data name" value = "data value" file = ...

  • Page 224

    224 chapter 2: coldfusion tags attributes attribute req/opt default description type required information type: • header: specifies an http header. Coldfusion does not url encode the header. • cgi: specifies an http header. Coldfusion url encodes the header by default. • body: specifies the body of ...

  • Page 225

    Cfhttpparam 225 usage specifies header or body data to send in the http request. The type attribute identifies the information that the parameter specifies. A cfhttp tag can have multiple cfhttpparam tags, subject to the following limitations: • an xml type attribute cannot be used with additional x...

  • Page 226

    226 chapter 2: coldfusion tags #cfhttp.Filecontent# form variable: #form.Form_test# url variable: #url.Url_test# cookie variable: #cookie.Cookie_test# cgi variable: #cgi.Cgi_test# note that the cgi variable is url encoded..

  • Page 227

    Cfif 227 cfif description creates simple and compound conditional statements in cfml. Tests an expression, variable, function return value, or string. Used, optionally, with the cfelse and cfelseif tags. Category flow-control tags syntax html and cfml tags html and cfml tags html and cfml tags see a...

  • Page 228

    228 chapter 2: coldfusion tags the following centers are in san diego: name/address:#name#, #address1#, #city#, #state# contact: #contact# if we would like more than one condition to be the case, we can ask for a list of the centers in san diego or santa ana. If the center does not follow this condi...

  • Page 229

    Cfimpersonate 229 cfimpersonate description this tag is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications” in coldfusion mx developer’s guide. History coldfusion mx: this tag is obsolete. It does not work in coldfusion mx and later ...

  • Page 230

    230 chapter 2: coldfusion tags cfimport description you can use the cfimport tag to import either of the following: • all coldfusion pages in a directory, as a tag custom tag library. • a java server page (jsp) tag library. A jsp tag library is a packaged set of tag handlers that conform to the jsp ...

  • Page 231

    Cfimport 231 usage the following example imports the tags from the directory mycustomtags: prefix="mytags" taglib="mycustomtags"> you can import multiple tag libraries using one prefix. If there are duplicate tags in a library, the first one takes precedence. Jsp tags have fixed attributes; however,...

  • Page 232

    232 chapter 2: coldfusion tags cfinclude description embeds references to coldfusion pages in cfml. You can embed cfinclude tags recursively. For another way to encapsulate cfml, see cfmodule on page 305 . (a coldfusion page was formerly sometimes called a coldfusion template or a template.) categor...

  • Page 233

    Cfinclude 233 you can specify a variable for the template attribute, as the following example shows: example the images do not display, because they are located in a separate directory. However, the page appears fully rendered within the contents of this page..

  • Page 234

    234 chapter 2: coldfusion tags cfindex description populates a verity collection with metadata and creates indexes for searching it. Verity is a search engine that you can integrate in a coldfusion application to search physical files of various types or a database query. Indexing database columns t...

  • Page 235

    Cfindex 235 coldfusion mx: • the action attribute value optimize is obsolete. It does not work, and might cause an error, in coldfusion mx. • changed the external attribute behavior: it is not necessary to specify the external attribute. (coldfusion automatically detects whether a collection is inte...

  • Page 236

    236 chapter 2: coldfusion tags body required if type = custom • ascii text to index. • query column names, if name is specified in query. You can specify columns in a delimited list; for example: "emp_name, dept_name, location" . This attribute is ignored if type is file or path , and is invalid if ...

  • Page 237

    Cfindex 237 usage the attributes settings that the cfindex tag requires depend on whether you set the query attribute. If you set the query attribute to a valid query name, it specifies that cfindex is to index the data in the query rather than indexing documents on a disk. If you do not set the que...

  • Page 238

    238 chapter 2: coldfusion tags status attribute the status attribute provides the following information and diagnostics about the result of a cfindex operation: example action="refresh" type="file" key="c:\blackstone\wwwroot\vw_files\cfindex.Htm" urlpath="http://localhost:8500/vw_files/" language="e...

  • Page 239

    Cfindex 239 language="english" categorytree="vw_files/newspaper/sports" category="giants"> name = "mysearch" collection = "codecoll" categorytree="vw_files/newspaper/sports" category="giants" criteria = "williams" contextpassages = "1" maxrows = "100"> key=#mysearch.Key# title=#mysearch.Title# conte...

  • Page 240

    240 chapter 2: coldfusion tags title=#mysearch.Title# context=#mysearch.Context# url=#mysearch.Url# select * from employee where emp_id = 1 query="getemps" collection="codecoll" action="update" type="file" key="contract_file" title="contract_file" body="emp_id,firstname,lastname,contract_file"> inde...

  • Page 241

    Cfindex 241 name = "getemps" collection = "codecoll" criteria = "cfsetting" contextpassages = "1" maxrows = "100"> key=#getemps.Key# title=#getemps.Title# context=#getemps.Context# url=#getemps.Url# action="delete" type="path" key="c:\cfusionmx7\wwwroot\vw_filesewspaper" urlpath="http://localhost:...

  • Page 242

    242 chapter 2: coldfusion tags cfinput description used within the cfform tag, to place input controls that support input validation on a form. Category forms tags syntax name = "name" type = "input type" label = "text" style = "style specification" required = "yes" or "no" mask = "masking pattern" ...

  • Page 243

    Cfinput 243 history coldfusion mx 7: • added support for button, file, hidden, image, reset, and submit controls. • added support for generating flash and xml controls (specified in the cfform tag). • added datefield type (flash forms only) and the supporting daynames and monthnames attributes. • ad...

  • Page 244

    244 chapter 2: coldfusion tags label optional; flash and xml label to put next to the control on a flash form. Not used for button, hidden, image, reset, or submit types. Style optional; all in html or xml format, coldfusion passes the style attribute to the browser or xml. In flash format, must be ...

  • Page 245

    Cfinput 245 range optional; all minimum and maximum allowed numeric values. Coldfusion uses this attribute only if you specify range in the validate attribute. If you specify a single number or a single number followed by a comma, it is treated as a minimum, with no maximum. If you specify a comma f...

  • Page 246

    246 chapter 2: coldfusion tags disabled optional; all not disabled disables user input, making the control read-only. To disable input, specify disabled without an attribute or disabled="yes" (or any coldfusion positive boolean value, such as true). To enable input, omit the attribute or specify dis...

  • Page 247

    Cfinput 247 note: attributes that are marked as not supported in xml are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml. Usage for this tag to work properly. The browser must be javascript-enabled. If the cfform preservedata attribute is true a...

  • Page 248

    248 chapter 2: coldfusion tags • onblur in html format the form page on the browser includes javascript functions that perform validation when the field loses the focus. In flash format, the attribute is equivalent to onsubmit. Onblur validation uses the same algorithms as onsubmit validation. Onblu...

  • Page 249

    Cfinput 249 validation differences the preceding table describes the general validation behavior. The underlying validation code must differ depending on the validation method and the form type. As a result, the algorithms used vary in some instances, including the following: • the validation algori...

  • Page 250

    250 chapter 2: coldfusion tags the following pattern enforces entry of a part number of the format eb-1234-c1-098765, where the user starts the entry by typing the first numeric character, such as 3. Coldfusion fills in the preceding ea prefix and all - characters. The user must enters four numbers,...

  • Page 251

    Cfinput 251 phone number validation (enter a properly formatted phone number): type = "text" name = "myphone" message = "enter telephone number, formatted xxx-xxx-xxxx (e.G. 617-761- 2000)" validate = "telephone" required = "yes"> required zip code validation (enter a properly formatted zip code): t...

  • Page 252

    252 chapter 2: coldfusion tags cfinsert description inserts records in data sources from data in a coldfusion form or form scope. Category database manipulation tags syntax datasource = "ds_name" tablename = "tbl_name" tableowner = "owner" tablequalifier = "tbl_qualifier" username = "username" passw...

  • Page 253

    Cfinsert 253 example tablename = "comments" formfields = "email,fromuser,subject,messtext,posted"> your record was added to the database. Tablename = "comments" formfields = "email,fromuser,subject,messtext,posted"> formfields="email,fromuser,subject,messtext,posted"> formfields="commentid,email,fro...

  • Page 254

    254 chapter 2: coldfusion tags next, we’ll offer the opportunity to enter a comment: email: from: subject: message: date posted: #dateformat(now())# name = "posted" value = "#now()#"> name = "" value = "insert my comment">.

  • Page 255

    Cfinvoke 255 cfinvoke description does either of the following: • invokes a component method from within a coldfusion page or component. • invokes a web service. This tag works as follows: • transiently instantiates a component or web service and invokes a method on it. • invokes a method on an inst...

  • Page 256

    256 chapter 2: coldfusion tags proxyserver = "wsdl proxy server url proxyport = "port on proxy server" proxyuser = "user id for proxy server" proxypassword = "password for proxy server" serviceport = "wsdl port name" inputparam1 = "value1" inputparam2 = "value2" ... Returnvariable = "var_name" ...> ...

  • Page 257

    Cfinvoke 257 history coldfusion mx 7: added the serviceport attribute. Coldfusion mx 6.1: added the following attributes: timeout , proxyserver , proxyport , proxyuser , and proxypassword . Coldfusion mx: added this tag. Attributes attribute req/opt default description component see usage. String or...

  • Page 258

    258 chapter 2: coldfusion tags note: if you do not specify any the proxy attributes, and a corresponding system property is set (typically in the jvm startup arguments) coldfusion uses the system property value. Usage the following table shows when you can use each attribute: if the component attrib...

  • Page 259

    Cfinvoke 259 method arguments can be passed in any of the following ways. If an argument is passed in more than one way with the same name, this order of precedence applies: 1. Using the cfinvokeargument tag 2. Passing directly as attributes of the cfinvoke tag (they cannot have the same name as a r...

  • Page 260

    260 chapter 2: coldfusion tags example4 this example uses syntax 3. Webservice="http://www.Xmethods.Net/sd/2001/temperatureservice.Wsdl" method="gettemp" returnvariable="atemp"> webservice="http://www.Xmethods.Net/sd/2001/temperatureservice.Wsdl" method="gettemp" returnvariable="atemp"> the temperat...

  • Page 261

    Cfinvokeargument 261 cfinvokeargument description passes the name and value of a parameter to a component method or a web service. This tag is used within the cfinvoke tag. Category extensibility tags syntax name="argument name" value="argument value" omit = "yes" or "no"> see also cfargument , cfco...

  • Page 262

    262 chapter 2: coldfusion tags example1 component="nasdaq.Quote" method="getlasttradeprice" returnvariable="res"> name="symbol" value="mot"> name="symbol" value="macr"> component="nasdaq.Quote" method="getlasttradeprice" returnvariable="res"> name="symbol" value="mot"> name="symbol" value="macr"> #r...

  • Page 263

    Cfldap 263 cfldap description provides an interface to a lightweight directory access protocol (ldap) directory server, such as the netscape directory server. Category internet protocol tags syntax server = "server_name" port = "port_number" username = "name" password = "password" action = "action" ...

  • Page 264

    264 chapter 2: coldfusion tags • deprecated the filterfile attribute. It might not work, and might cause an error, in later releases. Attributes attribute req/opt default description server required host name or ip address of ldap server. Port optional 389 port. Username required if secure = "cfssl_...

  • Page 265

    Cfldap 265 attributes required if action = "query" , "add" , "modifydn" , or "modify" for queries: comma-delimited list of attributes to return. For queries, to get all attributes, specify "*" . If action = "add" or "modify" , you can specify a list of update columns. Separate attributes with a semi...

  • Page 266

    266 chapter 2: coldfusion tags usage if you use the query action, cfldap creates a query object, allowing access to information in the query variables, as follows: if you use the security="cfssl_basic" option, coldfusion determines whether to trust the server by comparing the server’s certificate wi...

  • Page 267

    Cfldap 267 then restart coldfusion mx. The keytool utility initial keypass password is "change it". For more information on using the keytool utility, see the sun jdk documentation. Characters that are illegal in coldfusion can be used in ldap attribute names. As a result, the cfldap tag could creat...

  • Page 268

    268 chapter 2: coldfusion tags enter a name to search in the database..

  • Page 269

    Cflocation 269 cflocation description stops execution of the current page and opens a coldfusion page or html file. Category flow-control tags , page processing tags syntax url = "url" addtoken = "yes" or "no"> see also cfabort , cfbreak , cfexecute , cfexit , cfif , cfloop , cfswitch , cfthrow , cf...

  • Page 270

    270 chapter 2: coldfusion tags cflock description ensures the integrity of shared data. Instantiates the following kinds of locks: exclusive allows single-thread access to the cfml constructs in its body. The tag body can be executed by one request at a time. No other requests can start executing co...

  • Page 271

    Cflock 271 attributes note: limit the scope of code that updates shared data structures, files, and cfxs. Exclusive locks are required to ensure the integrity of updates, but read-only locks are faster. In a performance- sensitive application, substitute read-only locks for exclusive locks where pos...

  • Page 272

    272 chapter 2: coldfusion tags to work safely with coldfusion, a c++ cfx that maintains and manipulates shared (global) data structures must be made thread-safe; however, this requires advanced knowledge. You can use a cfml custom tag wrapper around a cfx to make its invocation thread-safe. When you...

  • Page 273

    Cflock 273 to avoid a deadlock, everyone who nests locks must do so in a well-specified order and name the locks consistently. If you must lock access to the server, application, and session scopes, you must do so in this order: 1. Lock the session scope. In the cflock tag, specify scope = " session...

  • Page 274

    274 chapter 2: coldfusion tags thanks for shopping e-turtleneck. You chose size #form.Size#, color #form.Color#. E-turtleneck has now sold #application.Number# turtlenecks! E-turtleneck has sold #application.Number# turtlenecks to date. Congratulations! You selected the most comfortable turtleneck i...

  • Page 275

    Cflock 275 turquoise black forest green xxsmall xsmall small medium large xlarge.

  • Page 276

    276 chapter 2: coldfusion tags cflog description writes a message to a log file. Category data output tags syntax text = "text" log = "log type" file = "filename" type = "message type" application = "yes" or "no"> see also cfcol , cfcontent , cfoutput , cftable history coldfusion mx: deprecated the ...

  • Page 277

    Cflog 277 usage this tag logs custom messages to standard or custom log files. You can specify a file for the log message or send messages to the default application or scheduler log. The log message can include coldfusion expressions. Log files must have the suffix .Log and must be located in the c...

  • Page 278

    278 chapter 2: coldfusion tags cflogin description a container for user login and authentication code. Coldfusion runs the code in this tag if a user is not already logged in. You put code in the tag that authenticates the user and identifies the user with a set of roles. Used with cfloginuser tag. ...

  • Page 279

    Cflogin 279 usage the body of this tag executes only if there is no logged-in user. When using application-based security, you put code in the body of the cflogin tag to check the user-provided id and password against a data source, ldap directory, or other repository of login identification. The bo...

  • Page 280

    280 chapter 2: coldfusion tags password = "#cflogin.Password#" roles = "#trim(qsecurity.Roles)#" > password = "#cflogin.Password#" roles = "#trim(qsecurity.Roles)#" >.

  • Page 281

    Cfloginuser 281 cfloginuser description identifies an authenticated user to coldfusion. Specifies the user id and roles. Used within a cflogin tag. Category security tags syntax name = "name" password = "password-string" roles = "roles"> see also cflogin , cflogout , getauthuser , isuserinrole , cfa...

  • Page 282

    282 chapter 2: coldfusion tags cflogout description logs the current user out. Removes knowledge of the user id, password, and roles from the server. If you do not use this tag, the user is automatically logged out when the session ends. Category security tags syntax see also cflogin , cfloginuser ,...

  • Page 283

    Cfloop 283 cfloop description looping is a programming technique that repeats a set of instructions or displays output repeatedly until one or more conditions are met. This tag supports the following types of loops: • “cfloop: index loop” on page 284 • “cfloop: conditional loop” on page 286 • “cfloo...

  • Page 284

    284 chapter 2: coldfusion tags cfloop: index loop description an index loop repeats for a number of times that is determined by a numeric value. An index loop is also known as a for loop. Syntax index = "parameter_name" from = "beginning_value" to = "ending_value" step = "increment"> ... Html or cfm...

  • Page 285

    Cfloop: index loop 285 the loop index is 3. The loop index is 4. The loop index is 5. In this example, the code loops four times, displaying the index value each time. The value of j is decreased by one for each iteration. This does not affect the value of to , because it is a copy of j that is made...

  • Page 286

    286 chapter 2: coldfusion tags cfloop: conditional loop description a conditional loop iterates over a set of instructions as long as a condition is true. To use this type of loop correctly, the instructions must change the condition every time the loop iterates, until the condition is false. Condit...

  • Page 287

    Cfloop: looping over a date or time range 287 cfloop: looping over a date or time range description loops over the date or time range specified by the from and to attributes. By default, the step is 1 day, but you can change the step by creating a timespan. The cfloop tag loops over tags that cannot...

  • Page 288

    288 chapter 2: coldfusion tags cfloop: looping over a query description a loop over a query executes for each record in a query record set. The results are similar to those of the cfoutput tag. During each iteration, the columns of the current row are available for output. The cfloop tag loops over ...

  • Page 289

    Cfloop: looping over a query 289 the following example combines the pages that are returned by a query of a list of page names into one document, using the cfinclude tag: datasource = "library" maxrows = "5"> select templatename from templates datasource = "library" maxrows = "5"> select templatenam...

  • Page 290

    290 chapter 2: coldfusion tags cfloop: looping over a list or file description looping over a list steps through elements contained in any of these entities: • a variable • a value that is returned from an expression • a file syntax index = "index_name" list = "list_items" delimiters = "item_delimit...

  • Page 291

    Cfloop: looping over a list or file 291 to loop over each line of a file, use the tag this way: index="curline" delimiters="#chr(10)##chr(13)#"> ... Index="curline" delimiters="#chr(10)##chr(13)#"> ....

  • Page 292

    292 chapter 2: coldfusion tags cfloop: looping over a com collection or structure description the cfloop collection attribute loops over every object within a com/dcom collection object, or every element in a structure: • a com/dcom collection object is a set of similar items referenced as a group. ...

  • Page 293

    Cfloop: looping over a com collection or structure 293.

  • Page 294: Chapter 2

    294 chapter 2: coldfusion tags cfmail description sends an e-mail message that optionally contains query output, using an smtp server. Category internet protocol tags syntax to = "recipient" from = "sender" cc = "copy_to" bcc = "blind_copy_to" subject = "msg_subject" replyto = "reply_to_addr" failto...

  • Page 295

    Cfmail 295 attributes attribute req/opt default description to required message recipient e-mail addresses: • static address; for example, " support@macromedia.Com ". • variable that contains an address; for example, "#form.Email#" . • name of a query column that contains an address; for example, " ...

  • Page 296

    296 chapter 2: coldfusion tags charset optional character encoding selected in coldfusion mx administrator mail page; default is utf-8 character encoding of the mail message, including the headers. The following list includes commonly used values: • utf-8 • iso-8859-1 • windows-1252 • us-ascii • shi...

  • Page 297

    Cfmail 297 usage sends a mail message to the specified address. Mail messages can include attachments. The tag body can include cfml code to generate mail output. The cfmailparam and cfmailpart tags can only be used in the cfmail tag body. Mail messages can be single or multipart. If you send a mult...

  • Page 298

    298 chapter 2: coldfusion tags note: the cfmail tag does not make copies of attachments when spooling mail to disk. If you use the cfmail tag to send a message with an attachment with spooling enabled and you use the cffile tag to delete the attachment file, coldfusion might not send the mail becaus...

  • Page 299

    Cfmail 299 this message was sent by an automatic mailer built with cfmail: = = = = = = = = = = = = = = = = = = = = = = = = = = = #form.Body# thank you, #mailfrom#: your message, #subject#, has been sent to #mailto#. To: from: subject: message body: a recipient"> enter a sender"> a subject"> some tex...

  • Page 300

    300 chapter 2: coldfusion tags cfmailparam description attaches a file or adds a header to an e-mail message. Category internet protocol tags syntax to = "recipient" subject = "msg_subject" from = "sender" ...More attributes... > file = "file-name" type ="media type" contentid = "content id" disposi...

  • Page 301

    Cfmailparam 301 usage this tag attaches a file or adds a header to an e-mail message. It can only be used in the cfmail tag. You can use multiple cfmailparam tags within a cfmail tag. You can use this tag to include a file, such as an image, in an html mail message. The file can be displayed inline ...

  • Page 302

    302 chapter 2: coldfusion tags this view-only example displays an image in the body of an html message. To = "#form.Mailto#" from = "#form.Mailfrom#" subject = "sample inline image"> disposition="inline" contentid="image1"> there should be an image here after the picture to = "#form.Mailto#" from = ...

  • Page 303

    Cfmailpart 303 cfmailpart description specifies one part of a multipart e-mail message. Can only be used in the cfmail tag. You can use more than one cfmailpart tag within a cfmail tag. Category internet protocol tags syntax ... > (optional cfmailparam entries) type="mime type" charset="character en...

  • Page 304

    304 chapter 2: coldfusion tags usage use this tag to create mail messages with alternative versions of the message that duplicate the content in multiple formats. The most common use is to send a plain text version of the message that can be read by all mail readers followed by a version formatted i...

  • Page 305

    Cfmodule 305 cfmodule description invokes a custom tag for use in coldfusion application pages. This tag processes custom tag name conflicts. Category application framework tags syntax template = "path" name = "tag_name" attributecollection = "collection_structure" attribute_name1 = "valuea" attribu...

  • Page 306

    306 chapter 2: coldfusion tags usage to name a coldfusion page that contains the custom tag definition, including its path, use the template attribute. To refer to the custom tag in the coldfusion installation directory, using dot notation to indicate its location, use the name attribute. On unix sy...

  • Page 307

    Cfmodule 307 using the template attribute. #htmlcodeformat(" template=""mytag.Cfm"" x=3 attributecollection=##attrcollection1## y=4>")# template=""mytag.Cfm"" x=3 attributecollection=##attrcollection1## y=4>")# the result: #result# here is another way to invoke the custom tag, using the name attribu...

  • Page 308

    308 chapter 2: coldfusion tags cfntauthenticate description authenticates a user name and password against the windows nt domain on which the coldfusion server is running, and optionally retrieves the user’s groups. Category security tags syntax username="username" password="password" domain="nt_dom...

  • Page 309

    Cfntauthenticate 309 note: coldfusion must run as a user that has the privilege to authenticate other users in the specified domain. The structure specified in the result attribute contains the following information: this tag provides two models for handling authentication: status checking and excep...

  • Page 310

    310 chapter 2: coldfusion tags save the following page as loginform.Cfm: user name: required="yes"> password: required="yes"> domain: save the following page as application.Cfm: domain="#thedomain#" result="authresult" listgroups="yes"> roles="authresult.Groups"> the password for #theusername# is no...

  • Page 311

    Cfntauthenticate 311 please try again.

  • Page 312

    312 chapter 2: coldfusion tags cfobject description creates a coldfusion object, of a specified type. Note: you can enable and disable this tag in the coldfusion administrator page, under coldfusion security, sandbox security. Category extensibility tags syntax the tag syntax depends on the object t...

  • Page 313

    Cfobject: com object 313 cfobject: com object description creates and manipulates a component object model (com) object. Invokes a registered automation server object type. For information on oleview, and about com and dcom, see the microsoft ole development website: www.Microsoft.Com . To use this ...

  • Page 314

    314 chapter 2: coldfusion tags example type = "com" class = allaire.Docex1.1 name = "obj"> this object has #obj.Count# items. Type = "com" class = allaire.Docex1.1 name = "obj"> this object has #obj.Count# items. The last name in the third item is #emp.Lastname#. Looping through all items in the col...

  • Page 315

    Cfobject: component object 315 cfobject: component object description creates an instance of a coldfusion component (cfc) object. Syntax name = "variable name" component = "component name"> see also cfcollection , cfcomponent , cfexecute , cfindex , cfreport , cfsearch , cfwddx ; “using coldfusion c...

  • Page 316

    316 chapter 2: coldfusion tags cfobject: corba object description calls methods on a registered corba object. Syntax type = "corba" context = "context" class = "file or naming service" name = "text" locale = "type-value arguments"> see also cfcollection , cfexecute , cfindex , cfreport , cfsearch , ...

  • Page 317

    Cfobject: corba object 317 usage coldfusion enterprise version 4.0 and later supports corba through the dynamic invocation interface (dii). To use cfobject with corba objects, you must provide the name of the file that contains a string-formatted version of the ior, or the object’s naming context in...

  • Page 318

    318 chapter 2: coldfusion tags cfobject: java or ejb object description creates and manipulates a java and enterprise java bean (ejb) object. Syntax type = "java" action = "create" class = "java class" name = "object name"> see also cfcollection , cfexecute , cfindex , cfreport , cfsearch , cfwddx ;...

  • Page 319

    Cfobject: java or ejb object 319 calling ejbs to create and call ejb objects, use the cfobject tag. In the second example below, the weblogic jndi is used to register and find ejbhome instances. Example action = "create" type = "java" class = "myclass" name = "myobj"> action = "create" type = "java"...

  • Page 320

    320 chapter 2: coldfusion tags cfobject: web service object description creates a web service proxy object. Syntax webservice= "http://....?Wsdl" or "name set in administrator" name = "myobjectname"> see also cfcollection , cfexecute , cfindex , cfreport , cfsearch , cfwddx ; “consuming web services...

  • Page 321

    Cfobjectcache 321 cfobjectcache description flushes the query cache. Category database manipulation tags syntax action = "clear"> see also cfobject history coldfusion 5: added this tag. Attributes attribute req/opt default description action required clear: clears queries from the cache in the appli...

  • Page 322

    322 chapter 2: coldfusion tags cfoutput description displays output that can contain the results of processing coldfusion variables and functions. Can loop over the results of a database query. Category data output tags syntax query = "query_name" group = "query_column" groupcasesensitive = "yes" or...

  • Page 323

    Cfoutput 323 when you specify a query attribute, this tag loops over the query rows and produces output for each row within the range specified by the startrow and maxrows values, and groups or eliminates duplicate entries as specified by the grouping attribute values, if any. It also sets the query...

  • Page 324

    324 chapter 2: coldfusion tags today is #dayofweekasstring(dayofweek(now()))# example: this last example shows nested cfoutput tags: select emp_id, firstname, lastname, e.Dept_id, salary, d.Dept_name from employee e, departmt d where e.Dept_id = d.Dept_id order by d.Dept_name.

  • Page 325

    Cfparam 325 cfparam description tests for the existence of a parameter (that is, a variable), validates its data, and, if a default value is not assigned, optionally provides one. Category variable manipulation tags syntax name = "param_name" type = "data_type" default = "value" max = "value" min = ...

  • Page 326

    326 chapter 2: coldfusion tags attributes attribute req/opt default description name required name of the parameter (variable) to test (such as "client.Email " or "cookie.Backgroundcolor "). If omitted, and if the parameter does not exist, an error is thrown. Type optional any the valid format for t...

  • Page 327

    Cfparam 327 usage you can use this tag to make the following tests: • to test whether a required variable exists, use this tag with only the name attribute. If it does not exist, coldfusion mx stops processing the page and returns an error. • to test whether a required variable exists, and that it i...

  • Page 328

    328 chapter 2: coldfusion tags and tempvar is not ""> the value of tempvar has changed: the new value is and tempvar is not ""> #tempvar# type in a new value for tempvar, and hit submit:.

  • Page 329

    Cfpop 329 cfpop description retrieves or deletes e-mail messages from a pop mail server. Category internet protocol tags syntax server = "servername" port = "port_number" username = "username" password = "password" action = "action" name = "queryname" messagenumber = "number" uid = "number" attachme...

  • Page 330

    330 chapter 2: coldfusion tags password optional password that corresponds to username . Action optional getheaderonly • getheaderonly: returns message header information only • getall: returns message header information, message text, and attachments if attachmentpath is specified • delete: deletes...

  • Page 331

    Cfpop 331 usage the cfpop tag retrieves one or more mail messages from a pop server and populates a coldfusion query object with the resulting messages, one message per row. Alternatively, it deletes one or more messages from the pop server. Note: when the cfpop tag encounters malformed mail message...

  • Page 332

    332 chapter 2: coldfusion tags query message header and body columns the following table lists the message header and body columns that are returned if action = " getheaderonly" or " getall" : if the mail message includes a part with a content-type of text/plain, the queryname.Textbody column contai...

  • Page 333

    Cfpop 333 for more information on cfpop , see chapter 39, “sending and receiving e-mail” in coldfusion mx developer’s guide. Example cfpop lets you retrieve and manipulate mail in a pop3 mailbox. This view-only example shows how to create one feature of a mail client, to display the mail headers in ...

  • Page 334

    334 chapter 2: coldfusion tags cfprocessingdirective description provides the following information to coldfusion about how to process the current page: • specifies whether to remove excess whitespace character from coldfusion generated content in the tag body. • identifies the character encoding (c...

  • Page 335

    Cfprocessingdirective 335 attributes usage the cfprocssingdirective tag has limitations that depend on the attribute you use. For this reason, macromedia recommends that you include either the pageencoding or suppresswhitespace attribute in a cfprocessingdirective tag, not both. To specify both valu...

  • Page 336

    336 chapter 2: coldfusion tags • you cannot embed the tag within conditional logic, because the pageencoding attribute is evaluated when coldfusion compiles a page (not when it executes the page). For example, the following code has no effect at execution time, because the cfprocessingdirective tag ...

  • Page 337

    Cfprocparam 337 cfprocparam description defines stored procedure parameters. This tag is nested within a cfstoredproc tag. Category database manipulation tags syntax type = "in" or "out" or "inout" variable = "variable name" value = "parameter value" cfsqltype = "parameter datatype" maxlength = "len...

  • Page 338

    338 chapter 2: coldfusion tags usage use this tag to identify stored procedure parameters and their data types. Code one cfprocparam tag for each parameter. The parameters that you code vary based on parameter type and dbms. Coldfusion mx supports positional parameters only and you must code cfprocp...

  • Page 339

    Cfprocparam 339 output variables are stored in the coldfusion variable specified by the variable attribute. You cannot use the cfprocparam tag for oracle 8 and 9 reference cursors. Instead, use the cfprocresult tag. Example the following example shows how to invoke an oracle 8 pl/sql stored procedur...

  • Page 340

    340 chapter 2: coldfusion tags variable = "param2"> variable = "foo"> the first result set: variable = "foo"> the first result set: the second result set: the output parameter is:'#foo#'.

  • Page 341

    Cfprocresult 341 cfprocresult description associates a query object with a result set returned by a stored procedure. Other coldfusion tags, such as cfoutput and cftable , use this query object to access the result set. This tag is nested within a cfstoredproc tag. Category database manipulation tag...

  • Page 342

    342 chapter 2: coldfusion tags datasource = "my_sybase_test" username = "sa" password = "" dbserver = "scup" dbname = "pubs2" returncode = "yes" debug = "yes"> cfsqltype = cf_sql_integer value = "1" dbvarname = @param1> variable = foo dbvarname = @param2> the output param value: ’#foo#’ the results ...

  • Page 343

    Cfproperty 343 cfproperty description defines properties of a coldfusion component (cfc). Used to create complex data types for web services. The attributes of this tag are exposed as component metadata and are subject to inheritance rules. Category extensibility tags syntax name="name" type="type" ...

  • Page 344

    344 chapter 2: coldfusion tags attributes usage you must position cfproperty tags at the beginning of a component, above executable code and function definitions. If a component is not used as a web service, the cfproperty only provides metadata information when the component is viewed using introsp...

  • Page 345

    Cfproperty 345 for web services that you create in coldfusion, the cfproperty tag defines complex variables used by the web service. Example the following code defines a component in the file address.Cfc that contains properties that represent a street address: this component represents a complex da...

  • Page 346

    346 chapter 2: coldfusion tags cfquery description passes queries or sql statements to a data source. Macromedia recommends that you use the cfqueryparam tag within every cfquery tag, to help secure your databases from unauthorized users. For more information, see security bulletin asb99-04, "multip...

  • Page 347

    Cfquery 347 coldfusion mx: • changed query of queries behavior: it now supports a larger subset of standard sql. • changed dot notation support: coldfusion now supports dot notation within a record set name. Coldfusion interprets such a name as a structure. • deprecated the connectstring , dbname , ...

  • Page 348

    348 chapter 2: coldfusion tags usage use this tag to execute a sql statement against a coldfusion data source. Although you can use the cfquery tag to execute any sql data definition language (ddl) or data manipulation language (dml) statement, you typically use it to execute a sql select statement....

  • Page 349

    Cfquery 349 you can cache query results and execute stored procedures. For information about this and about displaying cfquery output, see coldfusion mx developer’s guide. Because the timeout attribute only affects the maximum time for each suboperation of a query, the cumulative time may exceed its...

  • Page 350

    350 chapter 2: coldfusion tags region state #getparks.Currentrow# #parkname# #region# #state# maxrows)#"> see next #maxrows# rows.

  • Page 351

    Cfqueryparam 351 cfqueryparam description verifies the data type of a query parameter and, for dbmss that support bind variables, enables coldfusion to use bind variables in the sql statement. Bind variable usage enhances performance when executing a cfquery statement multiple times. This tag is nes...

  • Page 352

    352 chapter 2: coldfusion tags attributes attribute req/opt default description value required value that coldfusion passes to the right of the comparison operator in a where clause. If cfsqltype is a date or time option, ensure that the date value uses your dbms-specific date format. Use the create...

  • Page 353

    Cfqueryparam 353 usage use the cfqueryparam tag in any sql statement (for example, select, insert, update, and delete) that uses coldfusion variables. You cannot use the cfquery cachedafter or cachedwithin attributes with cfqueryparam. For maximum validation of string data, specify the maxlength att...

  • Page 354

    354 chapter 2: coldfusion tags cf_sql_char char char char, nchar char, nchar char, nchar, unique identifier cf_sql_clob clob clob clob clob,nclob cf_sql_date date date date, datetime, year to day cf_sql_decimal decimal decimal decimal, money number decimal, money, small money cf_sql_distinct distinc...

  • Page 355

    Cfqueryparam 355 example select * from courses where course_id = cfsqltype = "cf_sql_integer"> course number: #course_id# description: #descript# cfsqltype = "cf_sql_integer"> course number: #course_id# description: #descript# this example throws an error because the value passed in the cfqueryparam...

  • Page 356

    356 chapter 2: coldfusion tags cfregistry description this tag is deprecated for the unix platform. Reads, writes, and deletes keys and values in the system registry. Provides persistent storage of client variables. Note: for this tag to execute, it must be enabled in the coldfusion mx administrator...

  • Page 357

    Cfregistry 357 cfregistry action = "getall" description returns all registry keys and values defined in a branch. You can access the values as you would any record set. Syntax action = "getall" branch = "branch" type = "data type" name = "query name" sort = "criteria"> see also chapter 15, “using pe...

  • Page 358

    358 chapter 2: coldfusion tags.

  • Page 359

    Cfregistry 359 cfregistry action = "get" description accesses a registry value and stores it in a coldfusion variable. Syntax action = "get" branch = "branch" entry = "key or value" variable = "variable" type = "data type"> see also chapter 15, “using persistent data and locking,” in coldfusion mx d...

  • Page 360

    360 chapter 2: coldfusion tags cfregistry action = "set" description adds a registry key, adds a value, or updates a value. Syntax action = "set" branch = "branch" entry = "key or value" type = "value type" value = "data"> see also chapter 15, “using persistent data and locking,” in coldfusion mx de...

  • Page 361

    Cfregistry 361 cfregistry action = "delete" description deletes a registry key or value. Syntax action = "delete" branch = "branch" entry = "keyorvalue"> see also chapter 15, “using persistent data and locking,” in coldfusion mx developer’s guide attributes usage if you delete a key, the cfregistry ...

  • Page 362

    362 chapter 2: coldfusion tags cfreport description used to do either of the following: • execute a report definition created with the coldfusion report builder, displaying it in pdf, flashpaper, or excel format. You can optionally save this report to a file. • run a predefined crystal reports repor...

  • Page 363

    Cfreport 363 history coldfusion mx 7: added support for the coldfusion report builder. Coldfusion mx: changed data source connection behavior: crystal reports now establishes an independent connection to the data source. The connection is not subject to any coldfusion data source-specific restrictio...

  • Page 364

    364 chapter 2: coldfusion tags usage use this tag to generate a report using a report definition created in either coldfusion report builder or in crystal reports. (for more information on using the coldfusion report builder, display the online help by opening the report builder and pressing f1.) pe...

  • Page 365

    Cfreport 365 note: the excel report output format type provides limited support for the formatting options available in coldfusion mx 7 reporting. Images and charts are not supported and numeric data containing formatting (commas, percents, currency, and so on) appear as plain text in excel. The exc...

  • Page 366

    366 chapter 2: coldfusion tags cfreportparam description passes input parameters to a coldfusion report builder report definition. Allowed inside cfreport tag bodies only. Category data output tags syntax name = "data name" value = "data value"> see also cfreport ; chapter 32, “creating reports for ...

  • Page 367

    Cfreportparam 367 overwrite="yes"> #timeformat(now())#"> overwrite="yes"> #timeformat(now())#">.

  • Page 368

    368 chapter 2: coldfusion tags cfrethrow description rethrows the currently active exception. Preserves the exception’s cfcatch . Type and cfcatch.Tagcontext variable values. Category exception handling tags , extensibility tags syntax see also cferror , cfthrow , cftry ; “handling runtime exception...

  • Page 369

    Cfreturn 369 cfreturn description returns result values from a component method. Contains an expression returned as result of the function. Return value an expression; the result of the function from which this tag is called. Category extensibility tags syntax expr> see also cfargument , cfcomponent...

  • Page 370

    370 chapter 2: coldfusion tags select * from tbldepartments.

  • Page 371

    Cfsavecontent 371 cfsavecontent description saves the generated content of the cfsavecontent tag, including the results of evaluating expressions and executing custom tags, in the specified variable. Category variable manipulation tags syntax variable = "variable name"> the content variable = "varia...

  • Page 372

    372 chapter 2: coldfusion tags cfschedule description provides a programmatic interface to the coldfusion scheduling engine. Can run a cfml page at scheduled intervals, with the option to write the page output to a static html page. This feature enables you to schedule pages that publish data, such ...

  • Page 373

    Cfschedule 373 history coldfusion mx 6.1: changed the way intervals are calculated. The day length now reflects changes between standard and daylight saving times. The month length is now the calendar month length, not four weeks. The scheduler handles leap years correctly. Attributes attribute req/...

  • Page 374

    374 chapter 2: coldfusion tags usage this tag and the coldfusion mx administrator scheduled task page schedule coldfusion tasks. Tasks that you add or change using this tag are visible in the administrator. You can disable this tag in the administrator sandbox/resource security page. This tag’s succ...

  • Page 375

    Cfschedule 375 operation = "httprequest" url = "http://127.0.0.1/playpen/history.Cfm" startdate = "8/7/03" starttime = "12:25 pm" interval = "3600" resolveurl = "yes" publish = "yes" file = "sample.Html" path = "c:\inetpub\wwwroot\playpen" requesttimeout = "600"> --->.

  • Page 376

    376 chapter 2: coldfusion tags cfscript description encloses a code block that contains cfscript statements. Category application framework tags , other tags syntax cfscript code here see also cfinvoke , cfmodule , createobject ; chapter 6, “extending coldfusion pages with cfml scripting” in coldfus...

  • Page 377

    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....

  • Page 378

    378 chapter 2: coldfusion tags consuming web services with the cfscript tag the following example shows how to consume a web service with the cfscript tag. You use the createobject function to connect to the web service. Ws = createobject("webservice", "http://www.Xmethods.Net/sd/2001/babelfishservi...

  • Page 379: Chapter 2

    Cfsearch 379 cfsearch description searches one or more verity collections. A collection must be created and indexed before this tag can return search results. A collection can be created in these ways: • with the cfcollection tag • in the coldfusion mx administrator • using a native verity indexing ...

  • Page 380

    380 chapter 2: coldfusion tags see also cfcollection , cfexecute , cfindex , cfobject , cfreport , cfwddx history coldfusion mx 7: • added category , categorytree , status , suggestions , contextpassages , contextbytes , contexthighlightbegin , contexthighlightend , and previouscriteria attributes. ...

  • Page 381

    Cfsearch 381 category optional a list of categories, separated by commas, to which the search is limited. If specified, and the collection does not have categories enabled, coldfusion throws an exception. Categorytree optional the location in a hierarchical category tree at which to start the search...

  • Page 382

    382 chapter 2: coldfusion tags usage the cfsearch tag returns a query object whose columns you can reference in a cfoutput tag. For example, the following code specifies a search for the exact terms "filming" or "filmed": name = "mysearch" collection = "mycollection" criteria = '`film{ing,ed}`' type...

  • Page 383

    Cfsearch 383 in this example, the single-quotation mark ( ' ) and backtick ( ` ) characters are used as delimiters; for more information, see chapter 25, “using verity search expressions” in coldfusion mx developer’s guide. To optimize search performance, always specify the maxrows attribute, settin...

  • Page 384

    384 chapter 2: coldfusion tags status structure keys to permit application users to search verity collections for nonstandard strings, words, or characters (for example, "ab23.45.67" or "--->") that would otherwise cause an error, you can create a text file that lists these elements and defines thei...

  • Page 385

    Cfsearch 385 title=#name.Title# score=#name.Score# custom1=#name.Custom1# custom2=#name.Custom2# summary=#name.Summary# recordcount=#name.Recordcount# currentrow=#name.Currentrow# columnlist=#name.Columnlist# recordssearched=#name.Recordssearched# name = "snippets" collection = "snippets" criteria =...

  • Page 386

    386 chapter 2: coldfusion tags currentrow=#book.Currentrow# columnlist=#book.Columnlist# recordssearched=#book.Recordssearched#.

  • Page 387

    Cfselect 387 cfselect description constructs a drop-down list box form control. Used within a cfform tag. You can populate the list from a query, or by using the html option tag. Category forms tags syntax name = "name" label = "label" style = "style specification" size = "integer" required = "yes" ...

  • Page 388

    388 chapter 2: coldfusion tags • added on -prefixed attributes. • added enabled , group , height , label , queryposition , tooltip , visible , and width attributes. Attributes the following table lists attributes that coldfusion uses directly. The tag also supports all html select tag attributes tha...

  • Page 389

    Cfselect 389 display optional; all value of value attribute query column to use for the display label of each list element. Used with the query attribute. Group optional; html and xml query column to use to group the items in the drop-down list into a two-level hierarchical list. Queryposition optio...

  • Page 390

    390 chapter 2: coldfusion tags note: attributes that are marked as flash only are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml. Usage this tag requires an end tag and can include html option and optgroup child tags. To ensure that a selected ...

  • Page 391

    Cfselect 391 show the selected names. ---> #name# email: #email# select emp_id, email, phone, department, firstname, lastname, firstname +' ' +lastname as name from getallemployees where emp_id in (#form.Employeeid#) #firstname# #lastname# email: #email# name = "employeeid" size = "15" multiple="yes...

  • Page 392

    392 chapter 2: coldfusion tags cfservlet description this tag is deprecated. Executes a java servlet on a jrun engine. To access servlets that run on the same server as coldfusion, use code such as the following, in which path specifies a servlet, jsp, or anything else: getpagecontext().Include(path...

  • Page 393

    Cfservletparam 393 cfservletparam description this tag is deprecated. A child tag of the cfservlet tag. Passes data to a servlet. Each cfservletparam tag within the cfservlet block passes a separate item of data to the servlet. To access servlets that run on the same server as coldfusion, use code s...

  • Page 394

    394 chapter 2: coldfusion tags cfset description sets a value in coldfusion. Used to create a variable, if it does not exist, and assign it a value. Also used to call functions. Category variable manipulation tags syntax var variable_name = expression > see also cfcookie , cfparam , cfregistry , cfs...

  • Page 395

    Cfset 395 dynamic variable names in this example, the variable name is itself a variable: function local variables the var keyword specifies that the variable being defined is only available inside the body of a function that you define using the cffunction tag. The variable value that is set in one...

  • Page 396

    396 chapter 2: coldfusion tags example select * from messages cfset sets and reassigns values to local or global variables within a page. For example, the variable numrecords has been declared on this page to hold the number of records returned from query (#numrecords#). In addition, cfset can be us...

  • Page 397

    Cfsetting 397 cfsetting description controls aspects of page processing, such as the output of html code in pages. Category page processing tags , variable manipulation tags syntax enablecfoutputonly = "yes" or "no" showdebugoutput = "yes" or "no" requesttimeout = "value in seconds" > see also cfcac...

  • Page 398

    398 chapter 2: coldfusion tags usage the cfsetting requesttimeout attribute replaces the use of requesttimeout within a url. To enforce a page timeout, detect the url variable and use code such as the following to change the page timeout: you can use this tag to manage whitespace in coldfusion outpu...

  • Page 399

    Cfsilent 399 cfsilent description suppresses output produced by cfml within a tag’s scope. Category data output tags , page processing tags syntax ... See also cfcache , cfflush , cfheader , cfhtmlhead , cfinclude , cfsetting ; chapter 9, “writing and calling user-defined functions,” in coldfusion m...

  • Page 400

    400 chapter 2: coldfusion tags cfslider description puts a slider control, for selecting a numeric value from a range, in a coldfusion form. The slider moves over the slider groove. As the user moves the slider, the current value displays. Used within a cfform tag. Not supported with flash forms. Ca...

  • Page 401

    Cfslider 401 attributes attribute req/opt default description name required name of cfslider control. Label optional label to display with control; for example, "volume" this displays: "volume %value%" to reference the value, use "%value%" . If %% is omitted, slider value displays directly after lab...

  • Page 402

    402 chapter 2: coldfusion tags usage this tag requires the client to download a java applet. Using this tag may be slightly slower than using an html form element to display the same information. Also, if the client does not have an up-to-date java plugin installed, the system might also have to dow...

  • Page 403

    Cfslider 403 if the following conditions are true, a user’s selection from query data that populates this tag’s options continues to display after the user submits the form: • the cfform preservedata attribute is set to " yes ". • the cfform action attribute posts to the same page as the form itself...

  • Page 404

    404 chapter 2: coldfusion tags cfstoredproc description executes a stored procedure in a server database. It specifies database connection information and identifies the stored procedure. Category database manipulation tags syntax procedure = "procedure name" datasource = "ds_name" username = "usern...

  • Page 405

    Cfstoredproc 405 usage use this tag to call a database stored procedure. Within this tag, you code cfprocresult and cfprocparam tags as follows: • cfprocresult if the stored procedure returns one or more result sets, code one cfprocresult tag per result set. • cfprocparam if the stored procedure use...

  • Page 406

    406 chapter 2: coldfusion tags value = "1" dbvarname = @param1> variable = foo dbvarname = @param2> ---> value = "1" dbvarname = @param1> variable = foo dbvarname = @param2> ---> variable = foo dbvarname = @param2> --->.

  • Page 407

    Cfswitch 407 cfswitch description evaluates a passed expression and passes control to the cfcase tag that matches the expression result. You can, optionally, code a cfdefaultcase tag, which receives control if there is no matching cfcase tag value. Category flow-control tags syntax expression = "exp...

  • Page 408

    408 chapter 2: coldfusion tags example select emp_id, firstname, lastname, email, phone, department from employees each time the case is fulfilled, the specific information is printed; if the case is not fulfilled, the default case is output #firstname# #lastname# is in sales #firstname# #lastname# ...

  • Page 409

    Cftable 409 cftable description builds a table in a coldfusion page. This tag renders data as preformatted text, or, with the htmltable attribute, in an html table. If you don't want to write html table tag code, or if your data can be presented as preformatted text, use this tag. Preformatted text ...

  • Page 410

    410 chapter 2: coldfusion tags usage this tag aligns table data, sets column widths, and defines column heads. At least one cfcol tag is required within this tag. You must put cfcol and cftable tags adjacent in a page. The only tag that you can nest within this tag is the cfcol tag. You cannot nest ...

  • Page 411

    Cftable 411.

  • Page 412

    412 chapter 2: coldfusion tags cftextarea description puts a multiline text entry box in a cfform tag and controls its display characteristics. Category forms tags syntax name = "name" label = "text" required = "yes" or "no" style = "style specification" validate = "data type" validateat= one or mor...

  • Page 413

    Cftextarea 413 note: attributes that are marked as flash only are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml. Attribute req/opt; format default description name required; all name of the cftextinput control. Label optional; flash and xml la...

  • Page 414

    414 chapter 2: coldfusion tags pattern required if validate = "regular_ expression" html and xml. Javascript regular expression pattern to validate input. Omit leading and trailing slashes. Coldfusion uses this attribute only if you specify regex in the validate attribute. For examples and syntax, s...

  • Page 415

    Cftextarea 415 note: attributes that are marked as flash only are not handled by the skins provided with coldfusion mx. They are, however, included in the generated xml. Usage for this tag to work properly in html format. The browser must be javascript-enabled. If you put text in the tag body, the c...

  • Page 416

    416 chapter 2: coldfusion tags bind="hello {username.Text}! Enter your comments here." /> example this example has two cftextarea controls. When you submit the form, coldfusion copies the text from the first control into the second. The onblur maxlength validation prevents you from entering more tha...

  • Page 417

    Cftextinput 417 cftextinput description puts a single-line text entry box in a cfform tag and controls its display characteristics. This tag is deprecated, and is not supported in xml format forms. In its place, you should use a cfinput or cftextarea tag and use a cascading style sheet (css) to spec...

  • Page 418

    418 chapter 2: coldfusion tags cfthrow description throws a developer-specified exception, which can be caught with a cfcatch tag that has any of the following type attribute options: • type = "custom_type" • type = "application" • type = "any" category exception handling tags , flow-control tags sy...

  • Page 419

    Cfthrow 419 usage use this tag within a cftry block, to throw an error. The cfcatch block can access accompanying information, as follows: • message, with cfcatch.Message • detail, with cfcatch.Detail • error code, with cfcatch.Errorcode to get more information, use cfcatch.Tagcontext . This array s...

  • Page 420

    420 chapter 2: coldfusion tags #cfcatch.Message# the contents of the tag stack are: index = i from = 1 to = #arraylen(cfcatch.Tagcontext)#> #i# #scurrent["id"]# (#scurrent["line"]#,#scurrent["column"]#) #scurrent["template"]# index = i from = 1 to = #arraylen(cfcatch.Tagcontext)#> #i# #scurrent["id"...

  • Page 421

    Cftimer 421 cftimer description displays execution time for a specified section of cfml code. Coldfusion mx displays the timing information along with any output produced by the timed code. Note: to permit this tag to execute, you must enable the timer information option under debugging settings in ...

  • Page 422

    422 chapter 2: coldfusion tags example1 ... Select * from employees #lastname#, #firstname# select * from courselist select * from parks select view > source to see timing information select *.

  • Page 423

    Cftimer 423 from departments scroll down to cftimer times heading to see timing information ....

  • Page 424

    424 chapter 2: coldfusion tags cftrace description displays and logs debugging data about the state of an application at the time the cftrace tag executes. Tracks runtime logic flow, variable values, and execution time. Displays output at the end of the request or in the debugging section at the end...

  • Page 425

    Cftrace 425 usage you cannot put application code within this tag. (this avoids problems that can occur if you disable debugging.) this tag is useful for debugging cfml code during application development. You can display cftrace tag output in the following ways: • as a section in the debugging outp...

  • Page 426

    426 chapter 2: coldfusion tags cftransaction description for enterprise database management systems that support transaction processing, instructs the database management system to treat multiple database operations as a single transaction. Provides database commit and rollback processing. See the d...

  • Page 427

    Cftransaction 427 usage if you do not specify a value for the action attribute, automatic transaction processing proceeds as follows: • if the cfquery operations within the transaction block complete without an error, the transaction is committed. • if a cfquery tag generates an error within a cftra...

  • Page 428

    428 chapter 2: coldfusion tags cftree description inserts a tree control in a form. Validates user selections. Used within a cfform tag block. You can use a coldfusion query to supply data to the tree. Category forms tags syntax format="applet", "flash", xml, or "object" required = "yes" or "no" del...

  • Page 429

    Cftree 429 history coldfusion mx 7: • added the format attribute and support for generating flash and xml and object output. • added enabled , onchange , style , tooltip , and visible attributes (flash format only). Coldfusion mx: changed behavior: coldfusion renders a tree control regardless of whe...

  • Page 430

    430 chapter 2: coldfusion tags appendkey optional; all yes • yes: if you use cftreeitem href attributes, coldfusion appends a cftreeitemkey query string variable with the value of the selected tree item to the cfform action url. • no: does not append the tree item value to the url. Highlighthref opt...

  • Page 431

    Cftree 431 align optional; applet, object • top • left • bottom • baseline • texttop • absbottom • middle • absmiddle • right border optional; applet, object yes • yes: displays a border around the tree control. • no hscroll optional; applet, object yes • yes: permits horizontal scrolling. • no vscr...

  • Page 432

    432 chapter 2: coldfusion tags note: all attributes are passed to the xml generated in xml format, but no coldfusion mx skin interprets cftree xml. Usage this tag must be in a cfform tag block. The applet format tree requires the client to download a java applet. Also, if the client does not have an...

  • Page 433

    Cftree 433 the structure variable name is specified by the cftree name attribute. The top level of the structure has two types of entries: • attribute settings • a children array attribute settings the structure has top-level entries with the values of the following cftree attributes: children array...

  • Page 434

    434 chapter 2: coldfusion tags from courselist c, departments d where d.Dept_id = c.Dept_id order by d.Dept_name, c.Corname, c.Corlevel query="getcourses" value="dept_name,course_id" display="dept_name,corlabel" queryasroot="no" expand="yes,no"> the following example creates a tree that shows the ba...

  • Page 435

    Cftree 435 parent = "#department#" expand="false" img="cd" href="#cgi.Script_name#?User_id=#emp_id#"> parent = "#lastname#, #firstname#" img="remote"> display = "contact information" parent = "#lastname#, #firstname#" expand = "false"> parent = "#department#" expand="false" img="cd" href="#cgi.Scrip...

  • Page 436

    436 chapter 2: coldfusion tags cftreeitem description populates a form tree control, created with the cftree tag, with one or more elements. Category forms tags syntax value = "text" display = "text" parent = "parent_name" img = "filename" imgopen = "filename" href = "url" target = "url_target" quer...

  • Page 437

    Cftreeitem 437 img optional; applet, object folder image name, filename, or file url for tree item icon. The following values are provided: • cd • computer • document • element • folder • floppy • fixed • remote you can also specify a custom image. To do so, include path and file extension; for exam...

  • Page 438

    438 chapter 2: coldfusion tags usage this tag requires the client to download a java applet. Downloading an applet takes time; therefore, using this tag might be slightly slower than using an html form element or the cfinput tag to get the same information. For this tag to work properly. The browser...

  • Page 439

    Cftreeitem 439 you requested information on #url.Cftreeitemkey#; user id #url.User_id# font = "arial narrow" highlighthref="no" hscroll="no"> display = "#lastname#, #firstname#" parent = "#department#" expand="no" href="#cgi.Script_name#?User_id=#emp_id#"> parent = "#lastname#, #firstname#"> display...

  • Page 440

    440 chapter 2: coldfusion tags cftry description used with one or more cfcatch tags. Together, they catch and process exceptions in coldfusion pages. Exceptions are events that disrupt the normal flow of instructions in a coldfusion page, such as failed database operations, missing include files, an...

  • Page 441

    Cftry 441 #i# #scurrent["id"]# (#scurrent["line"]#,#scurrent["column"]#) #scurrent["template"]#.

  • Page 442

    442 chapter 2: coldfusion tags cfupdate description updates records in a data source from data in a coldfusion form or form scope. Category database manipulation tags syntax datasource = "ds_name" tablename = "table_name" tableowner = "name" tablequalifier = "qualifier" username = "username" passwor...

  • Page 443

    Cfupdate 443 example select * from employees select * from employees where emp_id=#url.Id# #phonequery.Firstname# #phonequery.Lastname# password optional overrides the password value specified in odbc setup. Formfields optional (all on form, except keys) comma-delimited list of form fields to update...

  • Page 444

    444 chapter 2: coldfusion tags cfwddx description serializes and deserializes cfml data structures to the xml-based wddx format. The wddx is an xml vocabulary for describing complex data structures in a standard, generic way. Implementing it lets you use the http protocol to such information among a...

  • Page 445

    Cfwddx 445 usage coldfusion preserves the case of column names cases in javascript. The wddx2js and cfml2js actions create a wddxrecordset javascript object when they encounter a recordset java object. The serialized javascript code requires a wddx.Js file. This tag performs the following conversion...

  • Page 446

    446 chapter 2: coldfusion tags #message_id# #thread_id# #username# serializing cfml data... Resulting wddx packet is: deserializing wddx packet... The recordset data is:... #message_id# #thread_id# #username#.

  • Page 447

    Cfxml 447 cfxml description creates a coldfusion xml document object that contains the markup in the tag body. This tag can include xml and cfml tags. Coldfusion processes the cfml code in the tag body, and then assigns the resulting text to an xml document object variable, which is always stored in...

  • Page 448

    448 chapter 2: coldfusion tags to change the declaration to specify another encoding, use the replace function. To specify the encoding of the text that is returned to a browser or other application, use the cfcontent tag. The following example illustrates this process: belgian waffles our famous be...

  • Page 449: Chapter 3

    449 chapter 3 coldfusion functions this chapter lists and categorizes coldfusion markup language (cfml) functions. Contents function list. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 functions by category . . . . . . ....

  • Page 450

    450 chapter 3: coldfusion functions arrayprepend getsoapresponseheader queryaddrow arrayresize gettempdirectory querynew arrayset gettempfile querysetcell arraysort gettickcount quotedvaluelist arraysum gettimezoneinfo rand arrayswap gettoken randomize arraytolist hash randrange asc hour refind asin...

  • Page 451

    Function list 451 createtimespan isxmlelem structcopy createuuid isxmlnode structcount dateadd isxmlroot structdelete datecompare javacast structfind dateconvert jsstringformat structfindkey datediff lcase structfindvalue dateformat left structget datepart len structinsert day listappend structisemp...

  • Page 452

    452 chapter 3: coldfusion functions functions by category the following tables list functions by their category or purpose. Array functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 conversion functions . . . . . . . . ....

  • Page 453

    Functions by category 453 conversion functions date and time functions decision functions arraydeleteat arraymin arraysort listtoarray arrayinsertat arraynew arraysum arraytolist hash toscript xmlformat binarydecode lcase tostring xmlparse binaryencode listtoarray urldecode xmltransform charsetdecod...

  • Page 454

    454 chapter 3: coldfusion functions display and formatting functions dynamic evaluation functions extensibility functions full-text search functions history coldfusion mx 6.1: these functions are deprecated. They might not work, and might cause errors, in a future release. International functions li...

  • Page 455

    Functions by category 455 mathematical functions other functions query functions security functions string functions history coldfusion mx: coldfusion now supports the java ucs-2 representation of unicode character values 0–65535. (earlier releases supported ascii values.) compare left listgetat lis...

  • Page 456

    456 chapter 3: coldfusion functions string-processing functions process any of these characters (including ascii 0 (nul) characters), and continue counting subsequent characters of the string, if any. (in earlier releases, some string-processing functions processed the ascii 0 (nul) character, but d...

  • Page 457

    Function changes since coldfusion 5 457 xml functions function changes since coldfusion 5 the following tables list functions, parameters and values that have changed since coldfusion 5.0 and indicate the specific release in which the change was made. New functions, parameters, and values. . . . . ....

  • Page 458

    458 chapter 3: coldfusion functions getauthuser all coldfusion mx getcontextroot all coldfusion mx 7 getencoding all coldfusion mx getlocaledisplayname coldfusion mx 7 getmetadata all coldfusion mx getpagecontext all coldfusion mx getprofilesections all coldfusion mx getsoaprequest all coldfusion mx...

  • Page 459

    Function changes since coldfusion 5 459 deprecated functions, parameters, and values the following functions, parameters, and values are deprecated. Do not use them in coldfusion applications. They might not work, and might cause an error, in releases later than coldfusion mx. Toscript all coldfusio...

  • Page 460

    460 chapter 3: coldfusion functions obsolete functions, parameters, and values the following functions, parameters, and values are obsolete. Do not use them in coldfusion applications. They do not work in releases later than coldfusion 5. Function parameter or value obsolete as of this coldfusion re...

  • Page 461: Chapter 3

    Abs 461 abs description absolute-value function. The absolute value of a number is the number without its sign. Returns the absolute value of a number. Category mathematical functions function syntax abs(number ) see also sgn parameters example the absolute value of the following numbers: 1,3,-4,-3....

  • Page 462

    462 chapter 3: coldfusion functions acos description arccosine function. The arccosine is the angle whose cosine is number. Returns the arccosine, in radians, of a number. Category mathematical functions function syntax acos(number) see also cos , sin , asin , tan , atn , pi parameters usage the ran...

  • Page 463

    Addsoaprequestheader 463 addsoaprequestheader description adds a soap header to a web service request before making the request. Returns nothing. Category xml functions history coldfusion mx 7: added this function. Function syntax addsoaprequestheader(webservice, namespace, name, value [, mustunders...

  • Page 464

    464 chapter 3: coldfusion functions // create the web service object. Ws = createobject("webservice", "http://localhost/soapheaders/ headerservice.Cfc?Wsdl"); // set the username header as a string. Addsoaprequestheader(ws, "http://mynamespace/", "username", "tom", false); // set the password header...

  • Page 465

    Addsoapresponseheader 465 addsoapresponseheader description adds a soap response header to a web service response. Call only from within a cfc web service function that is processing a request as a soap web service. Returns nothing category xml functions history coldfusion mx 7: added this function....

  • Page 466

    466 chapter 3: coldfusion functions save the following code as headerservice.Cfc in a folder called soapheaders under your web root. Test its operation, and specifically the operation of the addsoapresponseheader function, by executing the examples that invoke this web service. For example, see the ...

  • Page 467

    Arrayappend 467 arrayappend description appends an array element to an array. Returns true, on successful completion. Category array functions function syntax arrayappend(array, value) see also arrayprepend ; “adding elements to an array” in chapter 5, “using arrays and structures,” in coldfusion mx...

  • Page 468

    468 chapter 3: coldfusion functions arrayavg description calculates the average of the values in an array. Returns number. If the array parameter value is an empty array, returns zero. Category array functions , mathematical functions function syntax arrayavg(array) see also arraysum ; “basic array ...

  • Page 469

    Arrayavg 469 the average of the numbers that you entered is #arrayavg(mynumberarray)#. Try again. You must enter at least two numeric values..

  • Page 470

    470 chapter 3: coldfusion functions arrayclear description deletes the data in an array. Returns true, on successful completion. Category array functions function syntax arrayclear(array) see also arraydeleteat ; “functions for xml object management” in chapter 35, “using xml and wddx,” in coldfusio...

  • Page 471

    Arraydeleteat 471 arraydeleteat description deletes an element from an array. When an element is deleted, coldfusion recalculates index positions. For example, in an array that contains the months of the year, deleting the element at position 5 removes the entry for may. After this, to delete the en...

  • Page 472

    472 chapter 3: coldfusion functions #daysarray[1][1]# #daysarray[1][2]# #daysarray[2][1]# #daysarray[2][2]# #daysarray[3][1]# #daysarray[3][2]# we delete this element of the array: #arraydeleteat(daysarray,2)# this is what the array looks like after delete: #daysarray[1][1]# #daysarray[1][2]# #daysa...

  • Page 473

    Arrayinsertat 473 arrayinsertat description inserts a value into an array. Array elements whose indexes are equal to or greater than the new position are incremented by one. The array length increases by one. Returns true, on successful completion. Category array functions function syntax arrayinser...

  • Page 474

    474 chapter 3: coldfusion functions add an element before position 3: #arrayinsertat(daysarray,3,"wednesday")# now output the array as a list: #arraytolist(daysarray)#.

  • Page 475

    Arrayisempty 475 arrayisempty description determines whether an array is empty of data elements. Returns true, if the array is empty; false, otherwise. Category array functions function syntax arrayisempty(array) see also arraylen , “functions for xml object management” in chapter 35, “using xml and...

  • Page 476

    476 chapter 3: coldfusion functions arraylen description determines the number of elements in an array. Returns the number of elements in an array. Category array functions function syntax arraylen(array) see also arrayisempty ; “functions for xml object management” in chapter 35, “using xml and wdd...

  • Page 477

    Arraymax 477 arraymax description array maximum function. Returns the largest numeric value in an array. If the array parameter value is an empty array, returns zero. Category array functions function syntax arraymax(array) parameters example this example uses arraymax to find the largest number in ...

  • Page 478

    478 chapter 3: coldfusion functions arraymin description array minimum function. Returns the smallest numeric value in an array. If the array parameter value is an empty array, returns zero. Category array functions function syntax arraymin(array) parameters example this example uses arraymin to fin...

  • Page 479

    Arraynew 479 arraynew description creates an array of 1–3 dimensions. Index array elements with square brackets: [ ]. Coldfusion arrays expand dynamically as data is added. Returns an array category array functions function syntax arraynew(dimension) parameters example is this an array? #isarray(myn...

  • Page 480

    480 chapter 3: coldfusion functions arrayprepend description inserts an array element at the beginning of an array. Returns true, on successful completion. Category array functions function syntax arrayprepend(array, value) see also arrayappend ; “adding elements to an array” in chapter 5, “using ar...

  • Page 481

    Arrayresize 481 arrayresize description resets an array to a specified minimum number of elements. This can improve performance, if used to size an array to its expected maximum. For more than 500 elements, use arrayresize immediately after using the arraynew tag. Coldfusion arrays expand dynamicall...

  • Page 482

    482 chapter 3: coldfusion functions arrayset description in a one-dimensional array, sets the elements in a specified index range to a value. Useful for initializing an array after a call to arraynew . Returns true, on successful completion. Category array functions function syntax arrayset(array, s...

  • Page 483

    Arraysort 483 arraysort description sorts array elements numerically or alphanumerically. Returns true, if sort is successful; false, otherwise. Category array functions , list functions function syntax arraysort(array, sort_type [, sort_order ]) history coldfusion mx: • changed thrown exceptions: t...

  • Page 484

    484 chapter 3: coldfusion functions throws if an array element is other than a simple element, this function throws an arraysortsimplevalueexception error. If sort_type is numeric and an array element is not numeric, this function throws a valuenotnumeric error. Example select firstname, lastname fr...

  • Page 485

    Arraysum 485 arraysum description array sum function. Returns the sum of values in an array. If the array parameter value is an empty array, returns zero. Category array functions , mathematical functions function syntax arraysum(array) parameters example this example uses arraysum to add two number...

  • Page 486

    486 chapter 3: coldfusion functions arrayswap description swaps array values of an array at specified positions. This function is more efficient than multiple cfset tags. Returns true, on successful completion. Category array functions function syntax arrayswap(array, position1, position2) see also ...

  • Page 487

    Arraytolist 487 arraytolist description converts a one-dimensional array to a list. Returns delimited list, as a string. Category array functions , conversion functions , list functions function syntax arraytolist(array [, delimiter ]) parameters example select firstname, lastname from employees the...

  • Page 488

    488 chapter 3: coldfusion functions asc description determines the value of a character. Returns the value of the first character of a string; if string is empty, returns zero. Category string functions function syntax asc(string) see also chr history coldfusion mx: changed unicode support: coldfusi...

  • Page 489

    Asin 489 asin description determines the arcsine of a number. The arcsine is the angle whose sine is number. Returns the arcsine, in radians, of a number. Category mathematical functions function syntax asin(number) see also sin , cos , acos , tan , atn , pi parameters usage the range of the result ...

  • Page 490

    490 chapter 3: coldfusion functions value must be between 1 and -1,inclusive. Enter a number to get its arcsine in radians and degrees..

  • Page 491

    Atn 491 atn description arctangent function. The arctangent is the angle whose tangent is number. Returns the arctangent, in radians, of a number. Category mathematical functions function syntax atn(number) see also atn , sin , asin , cos , acos , pi parameters usage the range of the result is - π /...

  • Page 492

    492 chapter 3: coldfusion functions authenticatedcontext description this function is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications” in coldfusion mx developer’s guide. History coldfusion mx: this function is obsolete. It does n...

  • Page 493

    Authenticateduser 493 authenticateduser description this function is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications” in coldfusion mx developer’s guide. History coldfusion mx: this function is obsolete. It does not work in coldfu...

  • Page 494

    494 chapter 3: coldfusion functions binarydecode description converts a string to a binary object. Used to convert binary data that has been encoded into string format back into binary data. Returns a binary object. Category conversion functions , string functions function syntax binarydecode(string...

  • Page 495

    Binarydecode 495 example the following example reads a gif file as binary data, converts it to a binary-encoded string, converts the binary-encoded data back to binary data and writes the result to a file. It displays the encoded string and the image in the output file. File="c:\cfusionmx7\wwwroot\c...

  • Page 496

    496 chapter 3: coldfusion functions binaryencode description converts binary data to a string. Returns an encoded string representing the binary data. Category conversion functions , string functions function syntax binaryencode(binarydata, encoding) see also binarydecode , charsetencode , charsetde...

  • Page 497

    Binaryencode 497 • isbinary for checking variables for binary format • len for determining the length of a binary object example the following example reads a gif file as binary data, converts it to a binary-encoded string, converts the binary-encoded data back to binary data, and writes the result ...

  • Page 498

    498 chapter 3: coldfusion functions bitand description performs a bitwise logical and operation. Returns the bitwise and of two long integers. Category mathematical functions function syntax bitand(number1, number2) see also bitnot , bitor , bitxor parameters usage bit functions operate on 32-bit si...

  • Page 499

    Bitmaskclear 499 bitmaskclear description performs a bitwise mask clear operation. Returns a number, bitwise cleared, with length bits beginning at start. Category mathematical functions function syntax bitmaskclear(number, start, length) see also bitmaskread , bitmaskset parameters usage bit functi...

  • Page 500

    500 chapter 3: coldfusion functions bitmaskread description performs a bitwise mask read operation. Returns an integer, created from length bits of number, beginning at start. Category mathematical functions function syntax bitmaskread(number, start, length) see also bitmaskclear , bitmaskset parame...

  • Page 501

    Bitmaskset 501 bitmaskset description performs a bitwise mask set operation. Returns a number, bitwise masked with length bits of mask beginning at start. Category mathematical functions function syntax bitmaskset(number, mask, start, length) see also bitmaskclear , bitmaskread parameters usage bit ...

  • Page 502

    502 chapter 3: coldfusion functions bitnot description performs a bitwise logical not operation. Returns a number; the bitwise not of a long integer. Category mathematical functions function syntax bitnot(number) see also bitand , bitor , bitxor parameters usage bit functions operate on 32-bit signe...

  • Page 503

    Bitor 503 bitor description performs a bitwise logical or operation. Returns a number; the bitwise or of two long integers. Category mathematical functions function syntax bitor(number1, number2) see also bitand , bitnot , bitxor parameters usage bit functions operate on 32-bit signed integers, in t...

  • Page 504

    504 chapter 3: coldfusion functions bitshln description performs a bitwise shift-left, no-rotation operation. Returns a number, bitwise shifted without rotation to the left by count bits. Category mathematical functions function syntax bitshln(number, count) see also bitshrn parameters usage bit fun...

  • Page 505

    Bitshrn 505 bitshrn description performs a bitwise shift-right, no-rotation operation. Returns a number, bitwise shifted, without rotation, to the right by count bits. Category mathematical functions function syntax bitshrn(number, count) see also bitshln parameters usage bit functions operate on 32...

  • Page 506

    506 chapter 3: coldfusion functions bitxor description performs a bitwise logical xor operation. Returns bitwise xor of two long integers. Category mathematical functions function syntax bitxor(number1, number2) see also bitand , bitnot , bitor parameters usage bit functions operate on 32-bit signed...

  • Page 507

    Ceiling 507 ceiling description determines the closest integer that is greater than a specified number. Returns the closest integer that is greater than a given number. Category mathematical functions function syntax ceiling(number) see also int , fix , round parameters example the ceiling of 3.4 is...

  • Page 508

    508 chapter 3: coldfusion functions charsetdecode description converts a string to a binary representation. Returns a binary object that represents the string. Category conversion functions , string functions function syntax charsetdecode(string, encoding) see also binarydecode , binaryencode , char...

  • Page 509

    Charsetdecode 509 example the following example uses the charsetdecode function to convert a string from a form to a binary object, and uses the charsetencode function to convert it back to the original value. You can change the character encoding that coldfusion uses for the conversion. Notice that...

  • Page 510

    510 chapter 3: coldfusion functions the following four characters are not in all character encodings: ½àç÷.

  • Page 511

    Charsetencode 511 charsetencode description uses the specified encoding to convert binary data to a string. Returns a string representation of the binary object. Category conversion functions , string functions function syntax charsetencode(binaryobject, encoding) see also binarydecode , binaryencod...

  • Page 512

    512 chapter 3: coldfusion functions example the following example uses the charsetdecode function to convert a string from a form to a binary object, and uses the charsetencode function to convert it back to the original value. You can change the character encoding that coldfusion uses for the conve...

  • Page 513

    Charsetencode 513 the following four characters are not in all character encodings: ½àç÷.

  • Page 514

    514 chapter 3: coldfusion functions chr converts a numeric value to a ucs-2 character. Returns a character with the specified ucs-2 character code. Category string functions function syntax chr(number) see also asc history coldfusion mx: changed unicode support: coldfusion supports the java ucs-2 re...

  • Page 515

    Chr 515 maxlength="5" >.

  • Page 516

    516 chapter 3: coldfusion functions cjustify description centers a string in a field length. Returns string, center-justified by adding spaces before or after the input parameter. If length is less than the length of the input parameter string, the string is returned unchanged. Category display and ...

  • Page 517

    Compare 517 compare description performs a case-sensitive comparison of two strings. Returns • -1, if string1 is less than string2 • 0, if string1 is equal to string2 • 1, if string1 is greater than string2 category string functions function syntax compare(string1, string2) see also comparenocase , ...

  • Page 518

    518 chapter 3: coldfusion functions string 1 string 2.

  • Page 519

    Comparenocase 519 comparenocase description performs a case-insensitive comparison of two strings. Returns an indicator of the difference: • a negative number, if string1 is less than string2 • 0, if string1 is equal to string2 • a positive number, if string1 is greater than string2 category string ...

  • Page 520

    520 chapter 3: coldfusion functions string 1 string 2.

  • Page 521

    Cos 521 cos description calculates the cosine of an angle that is entered in radians. Returns a number; the cosine of the angle. Category mathematical functions function syntax cos(number) see also acos , sin , asin , tan , atn , pi parameters usage the range of the result is -1 to 1. To convert deg...

  • Page 522

    522 chapter 3: coldfusion functions enter an angle in degrees to get its cosine:.

  • Page 523

    Createdate 523 createdate description creates a date/time object. Returns a date/time value. Category date and time functions function syntax createdate(year, month, day) see also createdatetime , createodbcdate ; “date-time functions and queries when odbc is not supported” in chapter 3, “using cold...

  • Page 524

    524 chapter 3: coldfusion functions #dateformat(createdate(form.Year, form.Month, form.Day), "mmm-dd- yyyy")# #dateformat(createdatetime(form.Year, form.Month, form.Day, 12,13,0))# #dateformat(createodbcdate(yourdate), "mmmm d, yyyy")# #dateformat(createodbcdatetime(yourdate), "d/m/yy")# enter the y...

  • Page 525

    Createdatetime 525 createdatetime description creates a date-time object. Returns a date/time value. Category date and time functions function syntax createdatetime(year, month, day, hour, minute, second) see also createdate , createtime , createodbcdatetime , now ; “date-time functions and queries ...

  • Page 526

    526 chapter 3: coldfusion functions the same value can be formatted with dateformat: #dateformat(createdate(form.Year, form.Month, form.Day), "mmm-dd-yyyy")# #dateformat(createdatetime(form.Year, form.Month, form.Day, form.Hour, form.Minute, form.Second))# #dateformat(createodbcdate(yourdate), "mmmm...

  • Page 527

    Createobject 527 createobject description creates a coldfusion object, of a specified type. Returns an object, of the specified type. Note: you can enable and disable this function in the coldfusion administrator, coldfusion basic security, tag restrictions page. Category extensibility functions his...

  • Page 528

    528 chapter 3: coldfusion functions createobject: com object description the createobject function can create a component object model (com) object. To create a com object, you must provide this information: • the object’s program id or filename • the methods and properties available to the object t...

  • Page 529

    Createobject 529 usage the following example creates the windows collaborative data objects (cdo) for nts newmail object to send mail. You would use this code within a cfscript tag. Mailer = createobject("com", "cdonts.Newmail");.

  • Page 530

    530 chapter 3: coldfusion functions createobject: component object description the createobject function can create an instance of a coldfusion component (cfc) object. Returns a component object. Function syntax createobject (type, component-name) see also chapter 10, “building and using coldfusion ...

  • Page 531

    Createobject 531 createobject: corba object description the createobject function can call a method on a corba object. The object must be defined and registered for use. Returns a handle to a corba interface. Function syntax createobject (type, context, class, locale) see also chapter 38, “integrati...

  • Page 532

    532 chapter 3: coldfusion functions coldfusion enterprise supports corba through the dynamic invocation interface (dii). To use this function with corba objects, you must provide the name of the file that contains a string version of the ior, or the object’s naming context in the naming service. You...

  • Page 533

    Createobject 533 createobject: java or ejb object description the createobject function can create a java object, and, by extension, an ejb object. Returns a java object. Function syntax createobject (type, class) parameters usage any java class available in the class path that is specified in the c...

  • Page 534

    534 chapter 3: coldfusion functions createobject: web service object description this function can create a web service object. Returns a web service object. Function syntax createobject (type, urltowsdl [, portname ]) parameters usage you can use the createobject function to create a web service. E...

  • Page 535

    Createodbcdate 535 createodbcdate description creates an odbc date object. Returns a date object, in normalized odbc date format. Category date and time functions function syntax createodbcdate(date) see also createdate , createodbcdatetime parameters usage this function does not parse or validate v...

  • Page 536

    536 chapter 3: coldfusion functions #dateformat(createdatetime(form.Year, form.Month, form.Day, form.Hour, form.Minute, form.Second))# #dateformat(createodbcdate(yourdate), "mmmm d, yyyy")# #dateformat(createodbcdatetime(yourdate), "d/m/yy")# enter the year, month and day, as integers: year required...

  • Page 537

    Createodbcdatetime 537 createodbcdatetime description creates an odbc date-time object. Returns a date-time object, in odbc timestamp format. Category date and time functions function syntax createodbcdatetime(date) see also createdatetime , createodbcdate , createodbctime , now ; “evaluation and ty...

  • Page 538

    538 chapter 3: coldfusion functions #dateformat(createodbcdate(yourdate), "mmmm d, yyyy")# #dateformat(createodbcdatetime(yourdate), "d/m/yy")# enter a year, month and day, as integers: year type="text" name="year" value="1998" validate="integer" required="yes"> month type="text" name="month" value=...

  • Page 539

    Createodbctime 539 createodbctime description creates an odbc time object. Returns a time object, in odbc timestamp format. Category date and time functions function syntax createodbctime(date) see also createodbcdatetime , createtime , “evaluation and type conversion issues” in chapter 3, “using co...

  • Page 540

    540 chapter 3: coldfusion functions createtime description creates a time variable. Returns a time variable. Category date and time functions function syntax createtime(hour, minute, second) see also createodbctime , createdatetime ; “evaluation and type conversion issues” in chapter 3, “using coldf...

  • Page 541

    Createtime 541 message="you must enter a value for seconds (0-59)" validate="integer" required="yes">.

  • Page 542

    542 chapter 3: coldfusion functions createtimespan description creates a date/time object that defines a time period. You can add or subtract it from other date- time objects and use it with the cachedwithin attribute of cfquery . Returns a date-time object. Category date and time functions function...

  • Page 543

    Createtimespan 543 cachedwithin = "#createtimespan(0, 6, 0, 0)#"> select parkname, region, state from parks order by parkname, state park name region state maxrows = "#maxrows#"> #getparks.Currentrow# #parkname# #region# #state# maxrows = "#maxrows#"> #getparks.Currentrow# #parkname# #region# #state...

  • Page 544

    544 chapter 3: coldfusion functions createuuid description creates a universally unique identifier (uuid). A uuid is a 35-character string representation of a unique 128-bit integer. Returns a coldfusion format uuid, in the format xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx , where x is a hexadecimal digit ...

  • Page 545

    Dateadd 545 dateadd description adds units of time to a date. Returns a date/time object. Category date and time functions function syntax dateadd("datepart", number, "date") see also dateconvert , datepart , createtimespan history coldfusion mx 6.1: added the datepart character l or l to represent ...

  • Page 546

    546 chapter 3: coldfusion functions select username, subject, posted from messages this example uses dateadd to determine when a message in the database will expire. Currently, messages older than #value# years quarters months days of year weekdays weeks hours minutes seconds years are expired. Colo...

  • Page 547

    Dateadd 547 years months days weeks hours minutes seconds.

  • Page 548

    548 chapter 3: coldfusion functions datecompare description performs a full date/time comparison of two dates. Returns • -1, if date1 is earlier than date2 • 0, if date1 is equal to date2 • 1, if date1 is later than date2 category date and time functions function syntax datecompare("date1", "date2" ...

  • Page 549

    Datecompare 549 #timeformat(form.Date2)# (date 2) the dates are not equal #timeformat(form.Date1)# to #dateformat(form.Date2)# #timeformat(form.Date2)# (date 2) the dates are equal! #timeformat(form.Date1)# than #dateformat(form.Date2)# #timeformat(form.Date2)# (date 2) the dates are not equal date ...

  • Page 550

    550 chapter 3: coldfusion functions.

  • Page 551

    Dateconvert 551 dateconvert description converts local time to coordinated universal time (utc), or utc to local time. The function uses the daylight savings settings in the executing computer to compute daylight savings time, if required. Returns utc- or local-formatted time object. Category date a...

  • Page 552

    552 chapter 3: coldfusion functions your date and time value, converted to coordinated universal time (utc): #yourutc#. Your utc date and time, converted back to local date and time: #dateconvert("utc2local", yourutc)#. Type the date and time, and press enter to see the conversion. Enter year, month...

  • Page 553

    Datediff 553 datediff description determines the integer number of units by which date1 is less than date2. Returns a number of units, of type datepart. Category date and time functions function syntax datediff("datepart", "date1", "date2") see also dateadd , datepart , createtimespan history coldfu...

  • Page 554

    554 chapter 3: coldfusion functions enclose string constant dates in quotation marks. If the text contains only numbers (such 1932), and is not surrounded by quotation marks, coldfusion interprets it as a date/time object, resulting in an incorrect value. Example this example uses datediff to determ...

  • Page 555

    Datediff 555 please enter two valid date/time values, formatted like this: #dateformat(now())# date 1 #dateformat(now())# cfoutput>"> date 2 #dateformat(now())# cfoutput>"> what kind of unit to show difference? Years quarters months days of year days weekdays weeks hours minutes seconds ..

  • Page 556

    556 chapter 3: coldfusion functions dateformat description formats a date value using u.S. Date formats. For international date support, use lsdateformat . Returns a text string representing the date formatted according to the mask. If no mask is specified, returns the value in dd-mmm-yy format. Cat...

  • Page 557

    Dateformat 557 usage when passing a date/time object as a string, you must enclose it in quotation marks. Otherwise, it is interpreted as a numeric representation of a date/time object. Note: you can pass the createdate function or now function as the date parameter of this function; for example: #d...

  • Page 558

    558 chapter 3: coldfusion functions datepart description extracts a part from a date value. Returns part of a date, as an integer. Category date and time functions function syntax datepart("datepart", "date") see also dateadd , dateconvert history coldfusion mx 6.1: added the datepart character l or...

  • Page 559

    Datepart 559.

  • Page 560

    560 chapter 3: coldfusion functions day description determines the day of the month, in a date. Returns the ordinal for the day of the month, ranging from 1 to 31. Category date and time functions function syntax day("date") see also dayofweek , dayofweekasstring , dayofyear , daysinmonth , daysinye...

  • Page 561

    Dayofweek 561 dayofweek description determines the day of the week, in a date. Returns the ordinal for the day of the week, as an integer in the range 1 (sunday) to 7 (saturday). Category date and time functions function syntax dayofweek("date") see also day , dayofweekasstring , dayofyear , daysinm...

  • Page 562

    562 chapter 3: coldfusion functions dayofweekasstring description determines the day of the week, in a date, as a string function. Returns the day of the week, as a string in the current locale, that corresponds to day_of_week. Category date and time functions , string functions function syntax dayo...

  • Page 563

    Dayofyear 563 dayofyear description determines the day of the year, in a date. Returns the ordinal value of day of the year, as an integer. Category date and time functions function syntax dayofyear("date") see also day , dayofweek , dayofweekasstring , daysinmonth , daysinyear , firstdayofmonth par...

  • Page 564

    564 chapter 3: coldfusion functions daysinmonth description determines the number of days in a month. Returns the number of days in the month in date. Category date and time functions function syntax daysinmonth("date") see also day , dayofweek , dayofweekasstring , dayofyear , daysinyear , firstday...

  • Page 565

    Daysinyear 565 daysinyear description determines the number of days in a year. Returns the number of days in a year. Category date and time functions function syntax daysinyear("date") see also day , dayofweek , dayofweekasstring , dayofyear , daysinmonth , daysinyear , firstdayofmonth , isleapyear ...

  • Page 566

    566 chapter 3: coldfusion functions de description escapes any double-quotation marks in the parameter and wraps the result in double-quotation marks. Returns parameter, surrounded by double-quotation marks, with any inner double-quotation marks escaped. Category dynamic evaluation functions functio...

  • Page 567

    De 567 the following example shows how you can use the de function and number signs together, and shows how the function works with an iif function: the expression is #myresult# coldfusion processes this code as follows: 1. Coldfusion sets the variables var1 and var2 to be the strings blue and green...

  • Page 568

    568 chapter 3: coldfusion functions try a simple expression, such as "2+2". #cfcatch.Message#.

  • Page 569

    Decimalformat 569 decimalformat description converts a number to a decimal-formatted string. Returns a number as a string formatted with two decimal places and a thousands separator. Category display and formatting functions function syntax decimalformat(number) see also dollarformat , numberformat ...

  • Page 570

    570 chapter 3: coldfusion functions decrementvalue description decrements the integer part of a number. Returns integer part of number, decremented by one. Category mathematical functions function syntax decrementvalue(number) see also incrementvalue parameters example returns the integer part of a ...

  • Page 571

    Decrypt 571 decrypt description decrypts a string that is encrypted using a standard encryption technique, including strings encrypted by the encrypt function. Returns an unencrypted string. Category security functions , string functions function syntax decrypt(encrypted_string, key[, algorithm[, en...

  • Page 572

    572 chapter 3: coldfusion functions usage this function uses a symmetric key-based algorithm, in which the same key is used to encrypt and decrypt a string. The parameter values must match the values used to encode string. The security of the encrypted string depends on maintaining the secrecy of th...

  • Page 573

    Decrypt 573 select the algorithm cfmx_compat aes des desede input your key (used for cfmx_compat encryption only) enter string to encrypt this string will be encrypted (you can replace it with more typing)..

  • Page 574

    574 chapter 3: coldfusion functions deleteclientvariable description deletes a client variable. (to test for the existence of a variable, use isdefined .) returns true, if the variable is successfully deleted; false, otherwise. Category other functions function syntax deleteclientvariable("name") se...

  • Page 575

    Directoryexists 575 directoryexists description determines whether a directory exists. Returns yes, if the specified directory exists; no, otherwise. Category system functions function syntax directoryexists(absolute_path) see also fileexists parameters example your directory exists. Directory name:...

  • Page 576

    576 chapter 3: coldfusion functions dollarformat description formats a string in u.S. Format. (for other currencies, use lscurrencyformat or lseurocurrencyformat .) returns a number as a string, formatted with two decimal places, thousands separator, and dollar sign. If number is negative, the retur...

  • Page 577

    Duplicate 577 duplicate description returns a clone, also known as a deep copy, of a variable. There is no reference to the original variable. Returns a clone of a variable. Category structure functions , system functions function syntax duplicate(variable_name) see also structcopy , other structure...

  • Page 578

    578 chapter 3: coldfusion functions encrypt description encrypts a string using a specific algorithm and encoding method. Returns string; can be much longer than the original string. Category security functions , string functions function syntax encrypt(string, key[, algorithm[, encoding]])) see als...

  • Page 579

    Encrypt 579 usage this function uses a symmetric key-based algorithm, in which the same key is used to encrypt and decrypt a string. The security of the encrypted string depends on maintaining the secrecy of the key. For all algorithms except the default algorithm, coldfusion mx 7 uses the java cryp...

  • Page 580

    580 chapter 3: coldfusion functions select the encoding uu base64 hex select the algorithm cfmx_compat aes des desede input your key (used for cfmx_compat encryption only) enter string to encrypt this string will be encrypted (you can replace it with more typing)..

  • Page 581

    Evaluate 581 evaluate description evaluates one or more string expressions, dynamically, from left to right. (the results of an evaluation on the left can have meaning in an expression to the right.) returns the result of evaluating the rightmost expression. Returns an object; the result of the eval...

  • Page 582

    582 chapter 3: coldfusion functions exp description calculates the exponent whose base is e that represents number. The constant e equals 2.71828182845904, the base of the natural logarithm. This function is the inverse of log , the natural logarithm of number. Returns the constant e, raised to the ...

  • Page 583

    Expandpath 583 expandpath description creates an absolute, platform-appropriate path that is equivalent to the value of relative_path , appended to the base path. This function (despite its name) can accept an absolute or relative path in the relative_path parameter the base path is the currently ex...

  • Page 584

    584 chapter 3: coldfusion functions example name="mydirectory" sort="name asc, size desc"> text="#name#"> text="#size#"> please enter a file name enter the name of a file in this directory name="mydirectory" sort="name asc, size desc"> text="#name#"> text="#size#"> please enter a file name text="#na...

  • Page 585

    Fileexists 585 fileexists description determines whether a file exists. Returns yes, if the file specified in the parameter exists; no, otherwise. Category system functions , decision functions function syntax fileexists(absolute_path) see also directoryexists , expandpath , gettemplatepath paramete...

  • Page 586

    586 chapter 3: coldfusion functions find description finds the first occurrence of a substring in a string, from a specified start position. The search is case-sensitive. Returns a number; the position of substring in string; or 0, if substring is not in string. Category string functions function sy...

  • Page 587

    Findnocase 587 findnocase description finds the first occurrence of a substring in a string, from a specified start position. If substring is not in string, returns zero. The search is case-insensitive. Returns the position of substring in string; or 0, if substring is not in string. Category string...

  • Page 588

    588 chapter 3: coldfusion functions findoneof description finds the first occurrence of any one of a set of characters in a string, from a specified start position. The search is case-sensitive. Returns the position of the first member of set found in string; or 0, if no member of set is found in st...

  • Page 589

    Firstdayofmonth 589 firstdayofmonth description determines the ordinal (day number, in the year) of the first day of the month in which a given date falls. Returns a number corresponding to a day-number in a year. Category date and time functions function syntax firstdayofmonth(date) see also day , ...

  • Page 590

    590 chapter 3: coldfusion functions fix description converts a real number to an integer. Returns if number is greater than or equal to 0, the closest integer less than number. If number is less than 0, the closest integer greater than number. Category mathematical functions function syntax fix(numb...

  • Page 591

    Formatbasen 591 formatbasen description converts number to a string, in the base specified by radix. Returns string that represents number, in the base radix. Category display and formatting functions , mathematical functions , string functions function syntax formatbasen(number, radix) see also inp...

  • Page 592

    592 chapter 3: coldfusion functions generatesecretkey description gets a secure key value for use in the encrypt function. Returns a string containing the encryption key. Category security functions , string functions function syntax generatesecretkey(algorithm) see also decrypt , encrypt history co...

  • Page 593

    Generatesecretkey 593 example the following example encrypts and decrypts a text string. It lets you specify the encryption algorithm and encoding technique. It also has a field for a key seed to use with the cfmx_compat algorithm. For all other algorithms, it uses the generatesecretkey function to ...

  • Page 594

    594 chapter 3: coldfusion functions desede input your key (used for cfmx_compat encryption only) enter string to encrypt this string will be encrypted (you can replace it with more typing)..

  • Page 595

    Getauthuser 595 getauthuser description gets the name of an authenticated user. Returns the name of an authenticated user. Category security functions function syntax getauthuser() see also isuserinrole , cflogin , cfloginuser ; chapter 16, “securing applications” in coldfusion mx developer’s guide ...

  • Page 596

    596 chapter 3: coldfusion functions getbasetagdata description used within a custom tag. Finds calling (ancestor) tag by name and accesses its data. Returns an object that contains data (variables, scopes, and so on) from an ancestor tag. If there is no ancestor by the specified name, or if the ance...

  • Page 597

    Getbasetaglist 597 getbasetaglist description gets ancestor tag names, starting with the parent tag. Returns a comma-delimited list of uppercase ancestor tag names, as a string. The first list element is the current tag. If the current tag is nested, the next element is the parent tag. If the functi...

  • Page 598

    598 chapter 3: coldfusion functions getbasetemplatepath description gets the absolute path of an application’s base page. Returns the absolute path of the application base page, as a string. Category other functions , system functions function syntax getbasetemplatepath() see also getcurrenttemplate...

  • Page 599

    Getclientvariableslist 599 getclientvariableslist description finds the client variables to which a page has write access. Returns comma-delimited list of non-read-only client variables, as a string. Category list functions , other functions function syntax getclientvariableslist() see also deletecl...

  • Page 600

    600 chapter 3: coldfusion functions getcontextroot description returns path to the j2ee server context root for the current request. Returns the path from the web root to the context root for the current page. The path starts with a forward slash character (/) but does not end with a forward slash c...

  • Page 601

    Getcurrenttemplatepath 601 getcurrenttemplatepath description gets the path of the page that calls this function. Returns the absolute path of the page that contains the call to this function, as a string. Category system functions function syntax getcurrenttemplatepath() see also getbasetemplatepat...

  • Page 602

    602 chapter 3: coldfusion functions getdirectoryfrompath description extracts a directory from an absolute path. Returns absolute path, without the filename. The last character is a forward or backward slash, depending on the operating system. Category system functions function syntax getdirectoryfr...

  • Page 603

    Getdirectoryfrompath 603 (try expandpath.Cfm).

  • Page 604

    604 chapter 3: coldfusion functions getencoding description returns the encoding (character set) of the form or url scope. Returns string; the character encoding of the specified scope. Category international functions , system functions function syntax getencoding(scope_name) see also setencoding ,...

  • Page 605

    Getencoding 605 writeoutput("the encoding is " & theencoding);.

  • Page 606

    606 chapter 3: coldfusion functions getexception description used with the cftry and cfcatch tags. Retrieves a java exception object from a java object. Returns any java exception object raised by a previous method call on the java object. Category system functions syntax getexception(object) parame...

  • Page 607

    Getfilefrompath 607 getfilefrompath description extracts a filename from an absolute path. Returns filename, as a string. Category system functions function syntax getfilefrompath(path) see also expandpath , getcurrenttemplatepath parameters example the current directory is: #getdirectoryfrompath(th...

  • Page 608

    608 chapter 3: coldfusion functions getfunctionlist description displays a list of the functions that are available in coldfusion. Returns a structure of functions. Category system functions function syntax getfunctionlist() example getfunctionlist()> #structcount(flist)# functions #key#.

  • Page 609

    Getgatewayhelper 609 getgatewayhelper description gets a java gatewayhelper object that provides methods and properties for use with a coldfusion event gateway. Returns a java gatewayhelper object. Category extensibility functions function syntax getgatewayhelper(gatewayid) see also sendgatewaymessa...

  • Page 610

    610 chapter 3: coldfusion functions example if an event gateway’s helper class includes an addbuddy method that takes a single string parameter, you could use the following code to get the gatewayhelper object and add a buddy to the buddies list: myhelper = getgatewayhelper(mygatewayid); status = my...

  • Page 611

    Gethttprequestdata 611 gethttprequestdata description makes http request headers and body available to cfml pages. Useful for capturing soap request data, which can be delivered in an http header. Returns a coldfusion structure. Category system functions function syntax gethttprequestdata() returns ...

  • Page 612

    612 chapter 3: coldfusion functions http_content --- #x.Content#.

  • Page 613

    Gethttptimestring 613 gethttptimestring description gets the current time, in the universal time code (utc). Returns the time, as a string, according to the http standard described in rfc 1123 and its underlying rfc, 822. This format is commonly used in internet protocols, including http. Category d...

  • Page 614

    614 chapter 3: coldfusion functions getk2serverdoccount description this function is deprecated. Returns the number of collection metadata items stored in verity collections. Category full-text search functions , query functions function syntax getk2serverdoccount() see also getk2serverdoccountlimit...

  • Page 615

    Getk2serverdoccountlimit 615 getk2serverdoccountlimit description this function is deprecated. Returns number of collection metadata items that the k2 server permits, as an integer category full-text search functions , query functions function syntax getk2serverdoccountlimit() see also getk2serverdo...

  • Page 616

    616 chapter 3: coldfusion functions getlocale description gets the current coldfusion mx geographic/language locale value. To set the default display format of date, time, number, and currency values in a coldfusion application session, you use the setlocale function. Returns the current locale valu...

  • Page 617

    Getlocale 617 for more information, see “locales” in chapter 17, “developing globalized applications,” in coldfusion mx developer’s guide. Example initial locale's coldfusion name: #getlocale()# changing locale to #form.Mylocale# new locale: #getlocale()# #i#.

  • Page 618

    618 chapter 3: coldfusion functions getlocaledisplayname description gets a locale value and displays the name in a manner that is appropriate to a specific locale. By default, gets the current locale in the current locale’s language. Returns the localized display name of the locale, in the language...

  • Page 619

    Getlocaledisplayname 619 new locale's coldfusion name: #newlocale# new locale's display name in current locale: #getlocaledisplayname()# new locale's display name in old locale: #getlocaledisplayname(newlocale, oldlocale)# new locale's display name in en_us: #getlocaledisplayname(newlocale, "en_us")...

  • Page 620

    620 chapter 3: coldfusion functions getmetadata description gets metadata (such as the methods, properties, and parameters of a component) associated with an object that is deployed on the coldfusion server. Returns structured metadata information: for coldfusion components (cfcs) and user defined f...

  • Page 621

    Getmetadata 621 the following table lists the data returned by the function for supported object types: object field description component a structure containing the following fields: displayname value of the cfcomponent tag displayname attribute, if any. Extends metadata for the component’s ancesto...

  • Page 622

    622 chapter 3: coldfusion functions note: use the this scope to access component metadata inside the cfc. The this scope is available at runtime in the component body and in the cfc methods. It is used to read and write variables that are present during the life of the component. For more informatio...

  • Page 623

    Getmetadata 623 select * from employees #employeemeta[i].Name# #employeemeta[i].Typename# #employeemeta[i].Iscasesensitive#.

  • Page 624

    624 chapter 3: coldfusion functions getmetricdata description gets server performance metrics. Returns coldfusion structure that contains metric data, depending on the mode value. Category system functions function syntax getmetricdata(mode) history coldfusion mx: deprecated the cachepops parameter....

  • Page 625

    Getmetricdata 625 example current perfmonitor data is: instancename:#pmdata.Instancename# pagehits:#pmdata.Pagehits# reqqueued: #pmdata.Reqqueued# dbhits: #pmdata.Dbhits# reqrunning: #pmdata.Reqrunning# reqtimedout: #pmdata.Reqtimedout# bytesin: #pmdata.Bytesin# bytesout: #pmdata.Bytesout# avgqueuet...

  • Page 626

    626 chapter 3: coldfusion functions getpagecontext description gets the current coldfusion mx pagecontext object that provides access to page attributes and configuration, request, and response objects. Returns the current coldfusion mx java pagecontext java object. Category system functions functio...

  • Page 627

    Getprofilesections 627 getprofilesections description gets all the sections of an initialization file. An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An initializati...

  • Page 628

    628 chapter 3: coldfusion functions getprofilestring description gets an initialization file entry. An initialization file assigns values to configuration variables, also known as entries, that are set when the system boots, the operating system comes up, or an application starts. An initialization ...

  • Page 629

    Getprofilestring 629.

  • Page 630

    630 chapter 3: coldfusion functions getsoaprequest description returns an xml object that contains the entire soap request. Usually called from within a web service cfc. Returns an xml object that contains the entire soap request. Category xml functions history coldfusion mx 7: added this function. ...

  • Page 631

    Getsoaprequest 631 different than shown here. Note, too, that getsoaprequest is called from the client here, whereas often it would be called from within the web service cfc. ---> ws = createobject("webservice", "http://localhost/soapheaders/headerservice.Cfc?Wsdl"); ws.Echo_me("hello world"); req =...

  • Page 632

    632 chapter 3: coldfusion functions getsoaprequestheader description obtains a soap request header. Call only from within a cfc web service function that is processing a request as a soap web service. Returns a soap request header. Category xml functions history coldfusion mx 7: added this function....

  • Page 633

    Getsoaprequestheader 633 access="remote" output="false" returntype="string" displayname="echo test" hint="header test"> "true")> as xml: " & xmlusername> "true")> as xml: " & xmlpassword> "authorized value", false)> access="remote" output="false" returntype="string" displayname="echo test" hint="hea...

  • Page 634

    634 chapter 3: coldfusion functions getsoapresponse description returns an xml object that contains the entire soap response after invoking a web service. Returns an xml object that contains the entire soap response. Category xml functions history coldfusion mx 7: added this function. Function synta...

  • Page 635

    Getsoapresponseheader 635 getsoapresponseheader description returns a soap response header. Call this function from within code that is invoking a web service after making a web service request. Returns a soap response header. Category xml functions history coldfusion mx 7: added this function. Func...

  • Page 636

    636 chapter 3: coldfusion functions execute the following example to see how the getsoapresponseheader function operates: // create the web service object ws = createobject("webservice", "http://localhost/soapheaders/ headerservice.Cfc?Wsdl"); // set the username header as a string addsoaprequesthea...

  • Page 637

    Gettempdirectory 637 gettempdirectory description gets the path of the directory that coldfusion uses for temporary files. The directory depends on the account under which coldfusion is running and other factors. Before using this function in an application, test to determine the directory it return...

  • Page 638

    638 chapter 3: coldfusion functions gettempfile description creates a temporary file in a directory whose name starts with (at most) the first three characters of prefix. Returns name of a temporary file, as a string. Category system functions function syntax gettempfile(dir, prefix) see also gettem...

  • Page 639

    Gettemplatepath 639 gettemplatepath description this function is deprecated. Use the getbasetemplatepath function instead. Gets the absolute path of an application’s base page. History coldfusion mx: deprecated this function. It might not work, and it might cause an error, in later releases..

  • Page 640

    640 chapter 3: coldfusion functions gettickcount description returns the current value of an internal millisecond timer. Returns a string representation of the system time, in milliseconds. Category date and time functions , system functions function syntax gettickcount() usage this function is usef...

  • Page 641

    Gettimezoneinfo 641 gettimezoneinfo description gets local time zone information for the computer on which it is called, relative to universal time coordinated (utc). Utc is the mean solar time of the meridian of greenwich, england, used as the basis for calculating standard time throughout the worl...

  • Page 642

    642 chapter 3: coldfusion functions gettoken description determines whether a token of the list in the delimiters parameter is present in a string. Returns the token found at position index of the string, as a string. If index is greater than the number of tokens in the string, returns an empty stri...

  • Page 643

    Gettoken 643 #mystring# the output is as follows: four, ,five, nine,zero:; nine,ten:, eleven:;twelve:;thirteen, ,four the gettoken function recognizes explicit spaces, tabs, or newline characters as the parameter delimiters (to specify a space character, the code is chr(32) ; a tab character, chr(9)...

  • Page 644

    644 chapter 3: coldfusion functions the following is a call against mystring2 : gettoken(mystring2, 2) is : #gettoken(mystring2, 2)# the output is as follows: gettoken(mystring2, 2) is : ,five,nine,zero:; the function finds the second delimiter, and returns the substring just before it that is betwe...

  • Page 645

    Hash 645 hash description converts a variable-length string to a fixed-length string that can act as a “fingerprint” or unique identifier for the original string. It is not possible to convert the hash result back to the source string. Returns a string. Category conversion functions , security funct...

  • Page 646

    646 chapter 3: coldfusion functions usage the result of this function is useful for comparison and validation. For example, you can store the hash of a password in a database without exposing the password. You can check the validity of the password by hashing the entered password and comparing the r...

  • Page 647

    Hash 647 user id: password:.

  • Page 648

    648 chapter 3: coldfusion functions hour description gets the current hour of the day. Returns ordinal value of the hour, in the range 0 - 23. Category date and time functions function syntax hour(date) see also datepart , minute , second parameters usage when passing a date/time value as a string, ...

  • Page 649

    Htmlcodeformat 649 htmlcodeformat description replaces special characters in a string with their html-escaped equivalents and inserts and tags at the beginning and end of the string. Returns html-escaped string string, enclosed in and tags. Return characters are removed; line feed characters are pre...

  • Page 650

    650 chapter 3: coldfusion functions example & this is another previous line was blank!!!"> #teststring# #htmlcodeformat(teststring)# #htmleditformat(teststring)#.

  • Page 651

    Htmleditformat 651 htmleditformat description replaces special characters in a string with their html-escaped equivalents. Returns html-escaped string string. Return characters are removed; line feed characters are preserved. Characters with special meanings in html are converted to html character e...

  • Page 652

    652 chapter 3: coldfusion functions the only difference between this function and htmlcodeformat is that htmlcodeformat surrounds the text in an html pre tag. Example & this is another previous line was blank!!!"> #teststring# #htmlcodeformat(teststring)# #htmleditformat(teststring)#.

  • Page 653

    Iif 653 iif description evaluates a boolean conditional dynamic expression. Depending on whether the expression is true or false, dynamically evaluates one of two string expressions and returns the result. This function is convenient for incorporating a cfif tag in-line in html. For general conditio...

  • Page 654

    654 chapter 3: coldfusion functions note: if you use number signs (#) in string_expression1 or string_expression2, coldfusion evaluates the part of the expression in number signs first. If you misuse the number signs, you can cause unexpected results from the iif function. For example, if you use nu...

  • Page 655

    Iif 655 #iif( hour(now()) gte 12, de("it is afternoon or evening"), de("it is morning"))#.

  • Page 656

    656 chapter 3: coldfusion functions incrementvalue description adds one to an integer. Returns the integer part of number, incremented by one. Category mathematical functions function syntax incrementvalue(number) see also decrementvalue parameters example returns the integer part of a number increm...

  • Page 657

    Inputbasen 657 inputbasen description converts string, using the base specified by radix, to an integer. Returns a number in the range 2-36, as a string. Category mathematical functions function syntax inputbasen(string, radix) see also formatbasen parameters example formatbasen converts a number to...

  • Page 658

    658 chapter 3: coldfusion functions insert description inserts a substring in a string after a specified character position. If position = 0 , prefixes the substring to the string. Returns a string. Category string functions function syntax insert(substring, string, position) see also removechars , ...

  • Page 659

    Int 659 int description calculates the closest integer that is smaller than number. For example, it returns 3 for int(3.3) and for int(3.7) ; it returns -4 for int(-3.3) and for int(-3.7 ). Returns an integer, as a string. Category mathematical functions function syntax int(number) see also ceiling ...

  • Page 660

    660 chapter 3: coldfusion functions isarray description determines whether a value is an array. Returns true, if value is an array, or a query column object. Category array functions , decision functions function syntax isarray(value [, number ]) see also array functions ; “modifying a coldfusion xm...

  • Page 661

    Isauthenticated 661 isauthenticated description this function is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications” in coldfusion mx developer’s guide. History coldfusion mx: this function is obsolete. It does not work in coldfusion...

  • Page 662

    662 chapter 3: coldfusion functions isauthorized description this function is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications” in coldfusion mx developer’s guide history coldfusion mx: this function is obsolete. It does not work i...

  • Page 663

    Isbinary 663 isbinary description determines whether a value is stored as binary data. Returns true, if the value is binary; false, otherwise. Category decision functions function syntax isbinary(value) see also tobinary , tobase64 , isnumeric , yesnoformat parameters example the following string is...

  • Page 664

    664 chapter 3: coldfusion functions.

  • Page 665

    Isboolean 665 isboolean description determines whether a value can be converted to boolean returns true, if the parameter can be converted to boolean; false, otherwise. Category decision functions function syntax isboolean(value) see also isnumeric , isvalid , yesnoformat parameters example isboolea...

  • Page 666

    666 chapter 3: coldfusion functions iscustomfunction description determines whether a name represents a custom function. Returns true, if name can be called as a custom function; false, otherwise. Category decision functions function syntax iscustomfunction(name) parameters usage the iscustomfunctio...

  • Page 667

    Iscustomfunction 667 iscustomfunction(mytestcfcobject.Testfunc)> mytestcfcobject.Testfunc is a function. Iscustomfunction(mytestcfcobject.Testfunc)> mytestcfcobject.Testfunc is a function..

  • Page 668

    668 chapter 3: coldfusion functions isdate description determines whether a string or java object can be converted to a date/time value. Returns true, if string can be converted to a date/time value; false, otherwise. Coldfusion converts the boolean return value to its string equivalent, "yes" or "n...

  • Page 669

    Isdebugmode 669 isdebugmode description determines whether debugging output is enabled. Returns true, if debugging mode is set in the coldfusion administrator; false if debugging mode is disabled. Category decision functions function syntax isdebugmode() see also cfsetting description if debugging o...

  • Page 670

    670 chapter 3: coldfusion functions isdefined description evaluates a string value to determine whether the variable named in it exists. This function is an alternative to the parameterexists function, which is deprecated. Returns true, if the variable is found, or, for a structure, if the specified...

  • Page 671

    Isdefined 671 during the first time through this template, the variable "form.Mystring" has not yet been defined, so we do not try to evaluate it..

  • Page 672

    672 chapter 3: coldfusion functions isk2serverabroker description this function is deprecated. Returns true, if k2broker is in configured with coldfusion; false, otherwise. Category decision functions , full-text search functions , query functions function syntax isk2serverabroker() see also getk2se...

  • Page 673

    Isk2serverdoccountexceeded 673 isk2serverdoccountexceeded description this function is deprecated. Returns true, if the document count limit is exceeded; false, otherwise. Category decision functions , full-text search functions , query functions function syntax isk2serverdoccountexceeded() see also...

  • Page 674

    674 chapter 3: coldfusion functions isk2serveronline description this function is deprecated because the k2server is always running when coldfusion is running. Returns true, if the k2server is available to perform a search; false, otherwise. Category decision functions , full-text search functions ,...

  • Page 675

    Isleapyear 675 isleapyear description determines whether a year is a leap year. Returns true, if year is a leap year; false, otherwise. Category date and time functions , decision functions function syntax isleapyear(year) see also daysinyear parameters example isleapyear(form.Thetestvalue)> year le...

  • Page 676

    676 chapter 3: coldfusion functions isnumeric description determines whether a string can be converted to a numeric value. Supports numbers in u.S. Number format. For other number support, use lsisnumeric . Returns true, if string can be converted to a number; false, otherwise. Category decision fun...

  • Page 677

    Isnumericdate 677 isnumericdate description evaluates whether a real number is a valid representation of a date (date/time object). Returns true, if the parameter represents a valid date/time object; false, otherwise. Category date and time functions , decision functions function syntax isnumericdat...

  • Page 678

    678 chapter 3: coldfusion functions.

  • Page 679

    Isobject 679 isobject description determines whether a value is an object. Returns true, if the value represents a coldfusion object. False if the value is any other type of data, such as an integer, string, date, or struct. Category decision functions function syntax isobject(value) see also isdate...

  • Page 680

    680 chapter 3: coldfusion functions returnvariable="mycolor"> the value of mycolor = #mycolor#.

  • Page 681

    Isprotected 681 isprotected description this function is obsolete. Use the newer security tools; see “conversion functions” on page 453 and chapter 16, “securing applications,” in coldfusion mx developer’s guide history coldfusion mx: this function is obsolete. It does not work in coldfusion mx and ...

  • Page 682

    682 chapter 3: coldfusion functions isquery description determines whether value is a query. Returns true, if value is a query. Category decision functions , query functions function syntax isquery(value) see also queryaddrow parameters example before the query is run, the value of getemployees is #...

  • Page 683

    Issimplevalue 683 issimplevalue description determines the type of a value. Returns true, if value is a string, number, boolean, or date/time value; false, otherwise. Category decision functions function syntax issimplevalue(value) see also isvalid parameters example before the query is run, the val...

  • Page 684

    684 chapter 3: coldfusion functions issoaprequest description determines whether a cfc is being called as a web service. Returns true if cfc is being called as a web service; false, otherwise. Category xml functions history coldfusion mx 7: added this function. Function syntax issoaprequest() see al...

  • Page 685

    Issoaprequest 685 "true")> as xml: " & xmlusername> "true")> as xml: " & xmlpassword> "authorized value", false)> "true")> as xml: " & xmlusername> "true")> as xml: " & xmlpassword> "authorized value", false)> "true")> as xml: " & xmlpassword> "authorized value", false)> "authorized value", false)>.

  • Page 686

    686 chapter 3: coldfusion functions isstruct description determines whether a variable is a structure. Returns true, if variable is a coldfusion structure or is a java object that implements the java.Lang.Map interface. The return value is false if the object in variable is a user-defined function (...

  • Page 687

    Isstruct 687 ) employee add complete --->.

  • Page 688

    688 chapter 3: coldfusion functions isuserinrole description determines whether an authenticated user belongs to the specified role. Returns true, if the authenticated user, belongs to the specified role; false, otherwise. Category security functions , decision functions function syntax isuserinrole...

  • Page 689

    Isvalid 689 isvalid description tests whether a value meets a validation or data type rule. Returns true, if the value conforms to the rule; false, otherwise. Category decision functions function syntax isvalid(type, value) isvalid("range", value, min, max) isvalid("regex" or "regular_expression", v...

  • Page 690

    690 chapter 3: coldfusion functions parameters usage the isvalid function lets you assure that validation is performed on the server. You can use the cfparam tag to perform equivalent validation. Parameter description type the valid format for the data; one of the following. For detailed information...

  • Page 691

    Isvalid 691 example the following example checks whether a user has submitted a numeric id and a valid email address and phone number. If any of the submitted values does not meet the validation test, it displays an error message. And isvalid("telephone", form.Phoneno)> the email address and phone n...

  • Page 692

    692 chapter 3: coldfusion functions iswddx description determines whether a value is a well-formed wddx packet. Returns true, if the value is a well-formed wddx packet; false, otherwise. Category decision functions , xml functions syntax iswddx(value) see also “using wddx” in chapter 35, “using xml ...

  • Page 693

    Iswddx 693 " > #packet# iswddx() returns #iswddx(packet)#.

  • Page 694

    694 chapter 3: coldfusion functions isxml description determines whether a string is well-formed xml text. Returns true, if the function parameter is a string that contains well-formed xml text; false, otherwise. Category decision functions , xml functions function syntax isxml(value) see also isxml...

  • Page 695

    Isxml 695 1 15.95 ' > xmlstring1 contains the following text: #htmlcodeformat(xmlstring1)# is it well formed xml text? #isxml(xmlstring1)# xmlstring2 contains the following text: #htmlcodeformat(xmlstring2)# is it well formed xml text? #isxml(xmlstring2)#.

  • Page 696

    696 chapter 3: coldfusion functions isxmlattribute description determines whether the function parameter is an xml document object model (dom) attribute node. Returns true, if the function argument is an xml attribute node; false, otherwise. Category decision functions , xml functions function synta...

  • Page 697

    Isxmlattribute 697 1 15.95 node.Xmlobject.Order.Xmlattributes.Id: #isxmlattribute(xmlobject.Order.Xmlattributes.Id)# xmlobject.Order.Items: #isxmlattribute(xmlobject.Order.Items)# lastnames[1] returned by xmlsearch: #isxmlattribute(lastnames[1])#.

  • Page 698

    698 chapter 3: coldfusion functions isxmldoc description determines whether the function parameter is a coldfusion xml document object. Returns true, if the function argument is an xml document object; false, otherwise. Category decision functions , xml functions function syntax isxmldoc(value) see ...

  • Page 699

    Isxmlelem 699 isxmlelem description determines whether the function parameter is an xml document object element. Returns true, if the function argument is an xml document object element; false, otherwise. Category decision functions , xml functions function syntax isxmlelem(value) see also isxml , i...

  • Page 700

    700 chapter 3: coldfusion functions isxmlnode description determines whether the function parameter is an xml document object node. Returns true, if the function argument is an xml document object node, including an element; false, otherwise. Category decision functions , xml functions function synt...

  • Page 701

    Isxmlnode 701 1 15.95 xmlobject: #isxmlnode(xmlobject)# xmlobject.Order.Items: #isxmlnode(xmlobject.Order.Items)# xmlobject.Order.Xmlattributes.Id: #isxmlnode(xmlobject.Order.Xmlattributes.Id)# lastnames[1] returned by xmlsearch: #isxmlnode(lastnames[1])#.

  • Page 702

    702 chapter 3: coldfusion functions isxmlroot description determines whether the function parameter is the root element of an xml document object. Returns true, if the function argument is the root object of an xml document object; false, otherwise. Category decision functions , xml functions functi...

  • Page 703

    Javacast 703 javacast description converts the data type of a coldfusion variable to pass as an argument to an overloaded method of a java object. Use only for scalar and string arguments. Returns the variable, as type type. Category string functions function syntax javacast(type, variable) see also...

  • Page 704

    704 chapter 3: coldfusion functions because there is not a one-to-one correspondence between internally stored coldfusion types and java scalar types, some conversions cannot be performed. Example the method foomethod in the class fooclass takes one overloaded argument. The fooclass class is defined...

  • Page 705

    Jsstringformat 705 jsstringformat description escapes special javascript characters, such as single-quotation mark, double-quotation mark, and newline. Returns a string that is safe to use with javascript. Category string functions function syntax jsstringformat(string) parameters usage escapes spec...

  • Page 706: Chapter 3

    706 chapter 3: coldfusion functions lcase description converts the alphabetic characters in a string to lowercase. Returns a string, converted to lowercase. Category string functions function syntax lcase(string) see also ucase parameters example your text, #form.Sampletext#, returned in lowercase i...

  • Page 707

    Left 707 left description returns the leftmost count characters in a string. Returns string; the first count characters in the string parameter. Category string functions function syntax left(string, count) see also right , mid , len parameters example your string #form.Mytext# only has #len(form.My...

  • Page 708

    708 chapter 3: coldfusion functions 1 3 5 7 9.

  • Page 709

    Len 709 len description determines the length of a string or binary object. Returns number; length of a string or a binary object. Category string functions function syntax len(string or binary object) see also tobinary , left , right , mid history coldfusion mx: changed unicode support: coldfusion ...

  • Page 710

    710 chapter 3: coldfusion functions listappend description concatenates a list or element to a list. Returns a copy of the list , with value appended. If delimiter = "" , returns a copy of the list, unchanged. Category list functions function syntax listappend(list, value [, delimiters ]) see also l...

  • Page 711

    Listappend 711 the original list: #temp# ....

  • Page 712

    712 chapter 3: coldfusion functions listchangedelims description changes a list delimiter. Returns a copy of the list, with each delimiter character replaced by new_delimiter. Category list functions function syntax listchangedelims(list, new_delimiter [, delimiters ]) see also listfirst , listquali...

  • Page 713

    Listcontains 713 listcontains description determines the index of the first list element that contains a specified substring. Returns index of the first list element that contains substring. If not found, returns zero. Category list functions function syntax listcontains(list, substring [, delimiter...

  • Page 714

    714 chapter 3: coldfusion functions as "two", both listcontains and listfind find it, in the second element: listcontains: the string "two" is in element #listcontains(alist, "two")# of the list. Listfind: the string "two" is in element #listfind(alist, "two")# of the list..

  • Page 715

    Listcontainsnocase 715 listcontainsnocase description determines the index of the first list element that contains a specified substring. Returns index of the first list element that contains substring, regardless of case. If not found, returns zero. Category list functions function syntax listconta...

  • Page 716

    716 chapter 3: coldfusion functions listdeleteat description deletes an element from a list. Returns a copy of the list, without the specified element. Category list functions function syntax listdeleteat(list, position [, delimiters ]) see also listgetat , listsetat , listlen ; “lists” in chapter 3...

  • Page 717

    Listdeleteat 717 listdeleteat(temp, "3")> the changed list: #temp2# this list element:#deleted_element# is no longer present at position three of the list..

  • Page 718

    718 chapter 3: coldfusion functions listfind description determines the index of the first list element in which a specified value occurs. Case-sensitive. Returns index of the first list element that contains value, with matching case. If not found, returns zero. The search is case-sensitive. Catego...

  • Page 719

    Listfind 719 select firstname, rtrim(lastname) as lname, phone, department from employees listfind(mylist, form.Mystring)> employee #listgetat(valuelist(searchemplastname.Firstname), temp)# #listgetat(valuelist(searchemplastname.Lname), temp)#, of the #listgetat(valuelist(searchemplastname.Departmen...

  • Page 720

    720 chapter 3: coldfusion functions listfindnocase description determines the index of the first list element in which a specified value occurs. Returns index of the first list element that contains value. If not found, returns zero. The search is case- insensitive. Category list functions function ...

  • Page 721

    Listfindnocase 721 select firstname, rtrim(lastname) as lname, phone, department from employees employee #listgetat(valuelist(searchemplastname.Firstname), temp)# #listgetat(valuelist(searchemplastname.Lname), temp)#, of the #listgetat(valuelist(searchemplastname.Department), temp)# department, can ...

  • Page 722

    722 chapter 3: coldfusion functions listfirst description gets the first element of a list. Returns the first element of a list. If the list is empty, returns an empty string. Category list functions function syntax listfirst(list [, delimiters ]) see also listgetat , listlast , listqualify ; “lists...

  • Page 723

    Listgetat 723 listgetat description gets a list element at a specified position. Returns index of the list element at position position. Category list functions function syntax listgetat(list, position [, delimiters ]) see also listfirst , listlast , listqualify , listsetat ; “lists” in chapter 3, “...

  • Page 724

    724 chapter 3: coldfusion functions #listlen(temp)# users. Username #counter#: #listgetat(temp, counter)#.

  • Page 725

    Listinsertat 725 listinsertat description inserts an element in a list. Returns a copy of the list , with value inserted at the specified position. Category list functions function syntax listinsertat(list, position, value [, delimiters ]) see also listdeleteat , listappend , listprepend , listsetat...

  • Page 726

    726 chapter 3: coldfusion functions listlast description gets the last element of a list. Returns the last element of the list. Category list functions function syntax listlast(list [, delimiters ]) see also listgetat , listfirst ; “lists” in chapter 3, “using coldfusion variables,” in coldfusion mx...

  • Page 727

    Listlast 727 before editing the list, it is: #valuelist(getmessageuser.Username)#. (users who posted more than once are listed more than once.) the first user in the list is: #listfirst(temp)# the rest of the list is: #listrest(temp)#. (users who posted more than once are listed more than once.) the...

  • Page 728

    728 chapter 3: coldfusion functions listlen description determines the number of elements in a list. Integer; the number of elements in a list. Category list functions function syntax listlen(list [, delimiters ]) see also listappend , listdeleteat , listinsertat , listprepend ; “lists” in chapter 3...

  • Page 729

    Listlen 729 #listlen(temp)# users. Username #counter#: #listgetat(temp, counter)#.

  • Page 730

    730 chapter 3: coldfusion functions listprepend description inserts an element at the beginning of a list. Returns a copy of the list , with value inserted at the first position. Category list functions function syntax listprepend(list, value [, delimiters ]) see also listappend , listinsertat , lis...

  • Page 731

    Listqualify 731 listqualify description inserts a string at the beginning and end of list elements. Returns a copy of the list, with qualifier before and after the specified element(s). Category list functions function syntax listqualify(list, qualifier [, delimiters ] [, elements ]) see also “lists...

  • Page 732

    732 chapter 3: coldfusion functions the contents of the unqualified list are as follows: #mylist# listqualify(mylist,"'",",","char")> the contents of the qualified list are as follows: #qualifiedlist1# listqualify(mylist,""",",","char")> the contents of the second qualified list are: #qualifiedlist2...

  • Page 733

    Listrest 733 listrest description gets a list, without its first element. Returns a copy of list, without the first element. If list has one element, returns an empty list. Category list functions function syntax listrest(list [, delimiters ]) see also listfirst , listgetat , listlast ; “lists” in c...

  • Page 734

    734 chapter 3: coldfusion functions listsetat description replaces the contents of a list element. Returns a copy of a list, with a new value assigned to the element at a specified position. Category list functions function syntax listsetat(list, position, value [, delimiters ]) see also listdeletea...

  • Page 735

    Listsetat 735 subjects posted in messages. Listsetat(temp, 2, "i changed this subject", ",")> (#counter#) subject: #listgetat(temptoo, counter)# note that element 2, "#changedelement#", has been altered to "i changed this subject" using listsetat..

  • Page 736

    736 chapter 3: coldfusion functions listsort description sorts list elements according to a sort type and sort order. Returns a copy of a list, sorted. Category list functions function syntax listsort(list, sort_type [, sort_order] [, delimiters ]) see also “lists” in chapter 3, “using coldfusion va...

  • Page 737

    Listsort 737 usage coldfusion ignores empty list elements; thus, the list "a,b,c,,,d" has four elements. Example select username, subject, posted from messages here is the unsorted list. #mylist# here is the list sorted alphabetically: #sortedlist# here is a numeric list that is to be sorted in desc...

  • Page 738

    738 chapter 3: coldfusion functions listtoarray description copies the elements of a list to an array. Returns an array category array functions , conversion functions , list functions function syntax listtoarray(list [, delimiters ]) see also arraytolist ; chapter 5, “using arrays and structures,” ...

  • Page 739

    Listvaluecount 739 listvaluecount description counts instances of a specified value in a list. The search is case-sensitive. Returns the number of instances of value in the list. Category list functions , string functions function syntax listvaluecount(list, value [, delimiters ]) see also listvalue...

  • Page 740

    740 chapter 3: coldfusion functions sales h3> there is only one person in #form.Departmentname#. There is only one person in #form.Departmentname#. There are #numberindepartment# people in #form.Departmentname#. There are #numberindepartment# people in #form.Departmentname#..

  • Page 741

    Listvaluecountnocase 741 listvaluecountnocase description counts instances of a specified value in a list. The search is case-insensitive. Returns the number of instances of value in the list. Category list functions function syntax listvaluecountnocase(list, value [, delimiters ]) see also listvalu...

  • Page 742

    742 chapter 3: coldfusion functions sales form.Departmentname)> there are no employees in #form.Departmentname# form.Departmentname)> cfoutput> there is only one person in #form.Departmentname#. There is only one person in #form.Departmentname#. There are #numberindepartment# people in #form.Departm...

  • Page 743

    Ljustify 743 ljustify description left justifies characters in a string of a specified length. Returns a copy of a string, left-justified. Category display and formatting functions , string functions function syntax ljustify(string, length) see also cjustify , rjustify parameters example ljustify(fo...

  • Page 744

    744 chapter 3: coldfusion functions log description calculates the natural logarithm of a number. Natural logarithms are based on the constant e (2.71828182845904). Returns the natural logarithm of a number. Category mathematical functions function syntax log(number) see also exp , log10 parameters ...

  • Page 745

    Log10 745 log10 description calculates the logarithm of number, to base 10. Returns number; the logarithm of number, to base 10. Category mathematical functions function syntax log10(number) see also exp , log parameters example your number, #form.Number# #form.Number# raised to the e power: #exp(fo...

  • Page 746

    746 chapter 3: coldfusion functions lscurrencyformat description formats a number in a locale-specific currency format. For countries that use the euro, the result depends on the jvm. Returns a formatted currency value. Category display and formatting functions , international functions function syn...

  • Page 747

    Lscurrencyformat 747 currency output the following table shows sample currency output. For locales that use euro, the local and international columns contains two entries. The first is entry is the result with a sun the 1.4.1- compliant jvm, the second entry is the result with a 1.3.1-compliant jvm....

  • Page 748

    748 chapter 3: coldfusion functions note: coldfusion maps spanish (modern) to the spanish (standard) format. To set the default display format of date, time, number, and currency values, use the setlocale function. Example lscurrencyformat returns a currency value using the locale convention. Defaul...

  • Page 749

    Lsdateformat 749 lsdateformat description formats the date part of a date/time value in a locale-specific format. Returns a formatted date/time value. If no mask is specified, the value is formatted according to the locale setting of the client computer. Category date and time functions , display an...

  • Page 750

    750 chapter 3: coldfusion functions parameters usage this function uses java standard locale formatting rules on all platforms. When passing date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. To calculate a diffe...

  • Page 751

    Lsdateformat 751.

  • Page 752

    752 chapter 3: coldfusion functions lseurocurrencyformat description formats a number in a locale-specific currency format. Returns a formatted currency value. For countries in the euro currency zone, the function uses the locale’s rule’s for formatting currency in euros. Category display and format...

  • Page 753

    Lseurocurrencyformat 753 currency output the following table shows examples of currency output: note: coldfusion uses the spanish (standard) formats for spanish (modern) and spanish (standard). Locale type = local type = international type = none chinese (china) ¥100,000.00 cny100,000.00 100,000.00 ...

  • Page 754

    754 chapter 3: coldfusion functions the following example shows how the function formats negative values. The format includes a negative sign before the value, or parentheses around the value, according to the formatting rules of the current locale. Example lseurocurrencyformat returns a currency va...

  • Page 755

    Lsiscurrency 755 lsiscurrency description determines whether a string is a valid representation of a currency amount in the current locale. Returns true, if the parameter is formatted as a valid currency amount, including the appropriate currency indicator. The return value is true for amounts in th...

  • Page 756

    756 chapter 3: coldfusion functions is the value "#form.Myvalue#" a proper currency value for #getlocale()#? Answer: #lsiscurrency(form.Myvalue)# select a locale for which you would like to check a currency value:.

  • Page 757

    Lsisdate 757 lsisdate description determines whether a string is a valid representation of a date/time value in the current locale. Returns true, if the string can be formatted as a date/time value in the current locale; false, otherwise. Category date and time functions , display and formatting fun...

  • Page 758

    758 chapter 3: coldfusion functions is the value "#form.Myvalue#" a proper date value for #getlocale()#? Answer: #lsisdate(form.Myvalue)# select a locale for which you would like to check a date value:.

  • Page 759

    Lsisnumeric 759 lsisnumeric description determines whether a string is a valid representation of a number in the current locale. Returns true, if the string represents a number the current locale; false, otherwise. Category decision functions , international functions , string functions function syn...

  • Page 760

    760 chapter 3: coldfusion functions lsnumberformat description formats a number in a locale-specific format. Returns a formatted number. • if no mask is specified, it returns the number formatted as an integer • if no mask is specified, truncates the decimal part; for example, it truncates 34.57 to ...

  • Page 761

    Lsnumberformat 761 note: if you do not specify a sign for the mask, positive and negative numbers do not align in columns. To put a plus sign or space before positive numbers and a minus sign before negative numbers, use the plus or hyphen mask character, respectively. Usage this function uses java ...

  • Page 762

    762 chapter 3: coldfusion functions an underscore determines whether the code is placed in the far or near position. Most code characters’ effect is determined by the field in which they are located. This example shows how to specify where to put parentheses to display negative numbers: to set the d...

  • Page 763

    Lsparsecurrency 763 lsparsecurrency description converts a locale-specific currency string into a formatted number. Attempts conversion by comparing the string with each the three supported currency formats (none, local, international) and using the first that matches. Returns a formatted number (st...

  • Page 764

    764 chapter 3: coldfusion functions for a list of the locale-specific formats used to parse the currency, see lscurrencyformat . Example lsparsecurrency coverts a locale-specific currency string to a number. Attempts conversion through each of the three default currency formats. Index = "locale" del...

  • Page 765

    Lsparsedatetime 765 lsparsedatetime description converts a string that is a valid date/time representation in the current locale into a date/time object. Returns a date/time object. Category date and time functions , display and formatting functions , international functions , string functions funct...

  • Page 766

    766 chapter 3: coldfusion functions valid dates are in the range 100 ad–9999 ad. Two digit years in the range 00-29 are interpreted as being 2000-2029. Two digit years in the range 30-99 are interpreted as being 1930-1999 this function corrects for differences between the current time zone and any t...

  • Page 767

    Lsparseeurocurrency 767 lsparseeurocurrency description formats a locale-specific currency string as a number. Attempts conversion through each of the default currency formats (none, local, international). Ensures correct handling of euro currency for euro zone countries. Returns a formatted number ...

  • Page 768

    768 chapter 3: coldfusion functions current locale: #locale# value in local currency: #localcurrency# parsed using lsparseeurocurrency: #lsparseeurocurrency(localcurrency)# value with international currency formatting: #intlcurrency# parsed using lsparseeurocurrency: #lsparseeurocurrency(intlcurrenc...

  • Page 769

    Lsparsenumber 769 lsparsenumber description converts a string that is a valid numeric representation in the current locale into a formatted number. Returns a formatted number that matches the value of the string. Category international functions , string functions function syntax lsparsenumber(strin...

  • Page 770

    770 chapter 3: coldfusion functions #lsnumberformat(1234.5678, "+_________.___")# #lsnumberformat(1234.5678, "-_________.___")# the actual number: #lsparsenumber(lsnumberformat(1234.5678, "_________"))#.

  • Page 771

    Lstimeformat 771 lstimeformat description formats the time part of a date/time string into a string in a locale-specific format. Returns a string representing the time value. Category date and time functions , display and formatting functions , international functions function syntax lstimeformat(ti...

  • Page 772

    772 chapter 3: coldfusion functions parameters usage this function uses java standard locale formatting rules on all platforms. When passing date/time value as a string, enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. To calculate a diffe...

  • Page 773

    Lstimeformat 773 #locale# #lstimeformat(now())# #lstimeformat(now(), ‘hh:mm:ss’)# #lstimeformat(now(), ‘hh:mm:sst’)# #lstimeformat(now(), ‘hh:mm:sstt’)# #lstimeformat(now(), ‘hh:mm:ss’)# #locale# #lstimeformat(now())# #lstimeformat(now(), ‘hh:mm:ss’)# #lstimeformat(now(), ‘hh:mm:sst’)# #lstimeformat...

  • Page 774

    774 chapter 3: coldfusion functions ltrim description removes leading spaces from a string. Returns a copy of the string, without leading spaces. Category display and formatting functions , string functions function syntax ltrim(string) see also rtrim , tobase64 parameters example your string:"#form...

  • Page 775

    Max 775 max description determines the greater of two numbers. Returns the greater of two numbers. Category mathematical functions function syntax max(number1, number2) see also min parameters example the maximum of the two numbers is #max(form.Mynum1, form.Mynum2)# the minimum of the two numbers is...

  • Page 776

    776 chapter 3: coldfusion functions mid description extracts a substring from a string. Returns a string; the set of characters from string, beginning at start, of length count. Category string functions function syntax mid(string, start, count) see also left , len , right parameters example your st...

  • Page 777

    Mid 777 type in some text enter a starting position (from the beginning of the entered text) how many characters do you want to show? 1 3 5 7 9.

  • Page 778

    778 chapter 3: coldfusion functions min description determines the lesser of two numbers. Returns the lesser of two numbers. Category mathematical functions function syntax min(number1, number2) see also max parameters example the maximum of the two numbers is #max(form.Mynum1, form.Mynum2)# the min...

  • Page 779

    Minute 779 minute description extracts the minute value from a date/time object. Returns the ordinal value of the minute, in the range 0–59. Category date and time functions function syntax minute(date) see also datepart , hash , second parameters usage when passing a date/time value as a string, yo...

  • Page 780

    780 chapter 3: coldfusion functions month description extracts the month value from a date/time object. Returns the ordinal value of the month, in the range 1 (january) – 12 (december). Category date and time functions function syntax month(date) see also datepart , monthasstring , quarter parameter...

  • Page 781

    Monthasstring 781 monthasstring description determines the name of the month that corresponds to month_number. Returns a string; the name of the specified month, in the current locale. Category date and time functions , string functions function syntax monthasstring(month_number) see also datepart ,...

  • Page 782

    782 chapter 3: coldfusion functions now description gets the current date and time of the computer running the coldfusion server. The return value can be passed as a parameter to date functions such as daysinyear or firstdayofmonth . Returns a date/time object; the current date and time of the compu...

  • Page 783

    Numberformat 783 numberformat description creates a custom-formatted number value. Supports the numeric formatting used in the u.S. For international number formatting, see lsnumberformat . Returns a formatted number value: • if no mask is specified, returns the value as an integer with a thousands ...

  • Page 784

    784 chapter 3: coldfusion functions note: if you do not specify a sign for the mask, positive and negative numbers do not align in columns. To put a plus sign or space before positive numbers and a minus sign before negative numbers, use the plus or minus sign, respectively. Usage this function uses...

  • Page 785

    Numberformat 785 when converting from string to double, to prevent rounding errors, this function adds a rounding factor of 1.5543122344752e-014 to the converted number. For example, without adding the rounding factor, converting the string value 1.275 to double with two digits of precision results ...

  • Page 786

    786 chapter 3: coldfusion functions paragraphformat description replaces characters in a string: • single newline characters (cr/lf sequences) with spaces • double newline characters with html paragraph tags ( ) returns a copy of the string, with characters converted. Category display and formatting...

  • Page 787

    Parameterexists 787 parameterexists description this function is deprecated. Use the isdefined function. Determines whether a parameter exists. Coldfusion does not evaluate the argument. History coldfusion mx: deprecated this function. It might not work, and might cause an error, in later releases..

  • Page 788

    788 chapter 3: coldfusion functions parsedatetime description parses a date/time string according to the english (u.S.) locale conventions. (to format a date/ time string for other locales, use the lsparsedatetime function.) returns a date/time object category date and time functions , display and f...

  • Page 789

    Parsedatetime 789 valid date enter an expression, and discover if it can be evaluated to a date value. #timeformat(now())#">.

  • Page 790

    790 chapter 3: coldfusion functions pi description gets the mathematical constant π , accurate to 15 digits. Returns the number 3.14159265358979. Category mathematical functions function syntax pi() see also asin , cos , sin , tan example the pi function returns the number #numberformat(pi(), "_.___...

  • Page 791

    Preservesinglequotes 791 preservesinglequotes description prevents coldfusion from automatically escaping single-quotation mark characters that are contained in a variable. Coldfusion does not evaluate the argument. Returns (none) category other functions function syntax preservesinglequotes(variabl...

  • Page 792

    792 chapter 3: coldfusion functions you code this function correctly as follows: (#preservesinglequotes(list0)#)"> this function ensures that coldfusion evaluates the code as follows: '1', '2', '3' example preservesinglequotes examplethis is a useful function for creating lists of information to ret...

  • Page 793

    Quarter 793 quarter description calculates the quarter of the year in which a date falls. Returns an integer, 1–4. Category date and time functions function syntax quarter(date) see also datepart , month parameters usage when passing a date/time value as a string, you must enclose it in quotation ma...

  • Page 794

    794 chapter 3: coldfusion functions queryaddcolumn description adds a column to a query and populates its rows with the contents of a one-dimensional array. Pads query columns, if necessary, to ensure that all columns have the same number of rows. Returns the number of the column that was added. Cat...

  • Page 795

    Queryaddcolumn 795 usage you can add columns to query objects, such as queries retrieved with the cfquery tag or queries created with the querynew function. You cannot use the queryaddcolumn function on a cached query. This function is useful for generating a query object from the arrays of output p...

  • Page 796

    796 chapter 3: coldfusion functions.

  • Page 797

    Queryaddrow 797 queryaddrow description adds a specified number of empty rows to a query. Returns the number of rows in the query category query functions function syntax queryaddrow(query [, number ]) see also queryaddcolumn , queryaddrow , querysetcell , querynew ; “creating a record set with a fu...

  • Page 798

    798 chapter 3: coldfusion functions querynew description creates an empty query (query object). Returns an empty query with a set of named columns, or an empty query. Category query functions function syntax querynew(columnlist [, columntypelist]) history coldfusion mx 7: added columntypelist parame...

  • Page 799

    Querynew 799 example the following example uses the querynew function to create an empty query with three columns. It populates two rows of the query and displays the contents of the query object and its metadata. Applications", 2)> the query object contents applications", 2)> #name# #time# #advance...

  • Page 800

    800 chapter 3: coldfusion functions querysetcell description sets a cell to a value. If no row number is specified, the cell on the last row is set. Returns true, if successful; false, otherwise. Category query functions function syntax querysetcell(query, column_name, value [, row_number ]) see als...

  • Page 801

    Quotedvaluelist 801 quotedvaluelist description gets the values of each record returned from an executed query. Coldfusion does not evaluate the arguments. Returns a delimited list of the values of each record returned from an executed query. Each value is enclosed in single-quotation marks. Categor...

  • Page 802

    802 chapter 3: coldfusion functions rand description generates a pseudo-random number. Returns a pseudo-random decimal number, in the range 0 – 1. Category mathematical functions , security functions function syntax rand([algorithm]) history coldfusion mx 7: added the algorithm parameter. See also r...

  • Page 803

    Randomize 803 randomize description seeds the pseudo-random number generator with an integer number, ensuring repeatable number patterns. Returns a pseudo-random decimal number, in the range 0–1. Category mathematical functions , security functions function syntax randomize(number[, algorithm]) hist...

  • Page 804

    804 chapter 3: coldfusion functions example the following example calls the randomize function to seed the random number generator and generates 10 random numbers. To show the effect of the seed, submit the form with the same value multiple times. Seed value is #form.Myrandomint# random number retur...

  • Page 805

    Randrange 805 randrange description generates a pseudo-random integer in the range between two specified numbers. Returns a pseudo-random integer. Category mathematical functions , security functions function syntax randrange(number1, number2[, algorithm]) history coldfusion mx 7: added the algorith...

  • Page 806

    806 chapter 3: coldfusion functions example the following example contains a form that requires random number range values, and lets you optionally specify a random number seed value. It uses cfform controls and attributes to specify a default range, ensure that the range fields have values, and val...

  • Page 807

    Refind 807 refind description uses a regular expression (re) to search a string for a pattern. The search is case sensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, see chapter 7, “using regular expressions in functions,” in coldfusion mx deve...

  • Page 808

    808 chapter 3: coldfusion functions usage this function finds the first occurrence of a regular expression in a string. To find the second and subsequent instances of the expression or of subexpressions in it, you call this function more than once, each time with a different start position. To deter...

  • Page 809

    Refind 809 the first call to refind to search this string is: refind("[a-za-z]+",teststring,1,"true") this function returns a structure that contains two arrays: pos and len. To create this structure you can use a cfset statement, for example: the number of elements in each array: #arraylen(st.Pos)#...

  • Page 810

    810 chapter 3: coldfusion functions refindnocase description uses a regular expression (re) to search a string for a pattern, starting from a specified position. The search is case-insensitive. For more information on regular expressions, including escape sequences, anchors, and modifiers, see chapt...

  • Page 811

    Refindnocase 811 usage this function finds the first occurrence of a regular expression in a string. To find the second and subsequent instances of the expression or of subexpressions in it, you call this function more than once, each time with a different start position. To determine the next start...

  • Page 812

    812 chapter 3: coldfusion functions the first call to refindnocase to search this string is: refindnocase("[[:alpha:]]+",teststring,1,"true") this function returns a structure that contains two arrays: pos and len. To create this structure you can use a cfset statement, for example: the number of el...

  • Page 813

    Releasecomobject 813 releasecomobject description releases a com object and frees up resources that it used. Returns nothing. Category extensibility functions function syntax releasecomobject(objectname) see also createobject , cfobject history coldfusion mx 6.1: added this function. Parameters usag...

  • Page 814

    814 chapter 3: coldfusion functions removechars description removes characters from a string. Returns a copy of the string, with count characters removed from the specified start position. If no characters are found, returns zero. Category string functions function syntax removechars(string, start, ...

  • Page 815

    Repeatstring 815 repeatstring description creates a string that contains a specified number of repetitions of the specified string. Returns a string. Category string functions function syntax repeatstring(string, count) see also cjustify , ljustify , rjustify parameters example repeatstring returns ...

  • Page 816

    816 chapter 3: coldfusion functions replace description replaces occurrences of substring1 in a string with substring2, in a specified scope. The search is case-sensitive. Returns the string, after making replacements. Category string functions function syntax replace(string, substring1, substring2 ...

  • Page 817

    Replacelist 817 replacelist description replaces occurrences of the elements from a delimited list in a string with corresponding elements from another delimited list. The search is case-sensitive. Returns a copy of the string, after making replacements. Category list functions , string functions fu...

  • Page 818

    818 chapter 3: coldfusion functions #replacelist(stringtoreplace,"dog,brown,fox,black", "cow,black,ferret,white")#.

  • Page 819

    Replacenocase 819 replacenocase description replaces occurrences of substring1 with substring2, in the specified scope. The search is case- insensitive. Returns a copy of the string, after making replacements. Category string functions function syntax replacenocase(string, substring1, substring2 [, ...

  • Page 820

    820 chapter 3: coldfusion functions rereplace description uses a regular expression (re) to search a string for a string pattern and replace it with another. The search is case-sensitive. Returns if the scope parameter is set to one , returns a string with the first occurrence of the regular express...

  • Page 821

    Rereplace 821 usage for details on using regular expressions, see chapter 7, “using regular expressions in functions,” in coldfusion mx developer’s guide. Example the rereplace function returns string with a regular expression replaced with substring in the specified scope. Case-sensitive search. Re...

  • Page 822

    822 chapter 3: coldfusion functions rereplacenocase description uses a regular expression to search a string for a string pattern and replace it with another. The search is case-insensitive. Returns • if scope = "one" : returns a string with the first occurrence of the regular expression replaced by...

  • Page 824

    824 chapter 3: coldfusion functions reverse description reverses the order of items, such as the characters in a string, the digits in a number, or the elements in an array. Returns a copy of string, with the characters in reverse order. Category string functions function syntax reverse(string) see ...

  • Page 825

    Right 825 right description gets a specified number of characters from a string, beginning at the right. Returns the specified number of characters from the end (or right side) of the specified string. Returns • if the length of the string is greater than or equal to count , the rightmost count char...

  • Page 826

    826 chapter 3: coldfusion functions please enter a string of more than 0 (zero) characters. Type in some text how many characters from the right do you want to show? 1 3 5 7 9.

  • Page 827

    Rjustify 827 rjustify description right justifies characters of a string. Returns a copy of a string, right-justified in the specified field length. Category display and formatting functions , string functions function syntax rjustify(string, length) see also cjustify , ljustify parameters example r...

  • Page 828

    828 chapter 3: coldfusion functions round description rounds a number to the closest integer that is larger than the input parameter. Returns an integer. Category mathematical functions function syntax round(number) see also ceiling , fix , int parameters usage use this function to round a number. T...

  • Page 829

    Rtrim 829 rtrim description removes spaces from the end of a string. Returns a copy of string, after removing trailing spaces. Category string functions function syntax rtrim(string) see also ltrim , trim parameters example your string:"#form.Mytext#" your string:"#rtrim(form.Mytext)#" (right trimme...

  • Page 830

    830 chapter 3: coldfusion functions second description extracts the ordinal for the second from a date/time object. Returns an integer in the range 0–59. Category date and time functions function syntax second(date) see also datepart , hash , minute parameters usage when passing a date/time object a...

  • Page 831

    Sendgatewaymessage 831 sendgatewaymessage description sends an outgoing message through a coldfusion mx event gateway. Returns string. The value returned depends on the gateway type. Category extensibility functions function syntax sendgatewaymessage(gatewayid, data) see also getgatewayhelper ; “im ...

  • Page 832

    832 chapter 3: coldfusion functions example the following example uses an instance of the cfml gateway to log messages asynchronously to a file. To use this example, you must configure an instance of the cfml gateway with the name “asynch logger” in the coldfusion mx administrator. This gateway inst...

  • Page 833

    Setencoding 833 setencoding description sets the character encoding (character set) of form and url scope variable values; used when the character encoding of the input to a form, or the character encoding of a url, is not in utf-8 encoding. Returns none category international functions , system fun...

  • Page 834

    834 chapter 3: coldfusion functions usage use this function when the character encoding of the input to a form or the character encoding of a url is not in utf-8 encoding. For example, traditional chinese characters are often in big5 encoding. This function resets url and form variables, so you shou...

  • Page 835

    Setlocale 835 setlocale description sets the country/language locale for coldfusion processing and the page returned to the client. The locale value determines the default format of date, time, number, and currency values, according to language and regional conventions. Returns the locale value prio...

  • Page 836

    836 chapter 3: coldfusion functions coldfusion determines the locale value as follows: • by default, coldfusion uses the jvm locale, and the default jvm locale is the operating system locale. You can set jvm locale value explicitly in coldfusion mx in the coldfusion administrator java and jvm settin...

  • Page 837

    Setprofilestring 837 setprofilestring description sets the value of a profile entry in an initialization file. Returns an empty string, upon successful execution; otherwise, an error message. Category system functions function syntax setprofilestring(inipath, section, entry, value) see also getprofi...

  • Page 838

    838 chapter 3: coldfusion functions timeout value should be greater than zero in order to provide time for user response. The timeout value in your initialization file is already #mytimeout#. Timeout is set to: #timeout#. Default directory is: #default#. Value = "c:\myboot.Ini">.

  • Page 839

    Setvariable 839 setvariable description this function is no longer required in well-formed coldfusion pages. Sets a variable in the name parameter to the value of the value parameter. Returns the new value of the variable. Category dynamic evaluation functions function syntax setvariable(name, value...

  • Page 840

    840 chapter 3: coldfusion functions your variable, #varname# the value of #varname# is #varnamevalue#.

  • Page 841

    Sgn 841 sgn description determines the sign of a number. Returns • 1, if number is positive. • 0, if number is 0. • -1, if number is negative. Category mathematical functions function syntax sgn(number) see also abs parameters example sgn determines the sign of a number. Returns 1 if number is posit...

  • Page 842

    842 chapter 3: coldfusion functions sin description calculates the sine of an angle that is entered in radians. Returns a number; the sine of the angle. Category mathematical functions function syntax sin(number) see also asin , cos , acos , tan , atn , pi parameters usage the range of the result is...

  • Page 843

    Sin 843 enter an angle in degrees to get its sine:.

  • Page 844

    844 chapter 3: coldfusion functions spanexcluding description gets characters from a string , from the beginning to a character that is in a specified set of characters. The search is case-sensitive. Returns a string; characters from string , from the beginning to a character that is in set. Categor...

  • Page 845

    Spanincluding 845 spanincluding description gets characters from a string , from the beginning to a character that is not in a specified set of characters. The search is case-sensitive. Returns a string; characters from string , from the beginning to a character that is not in set. Category string f...

  • Page 846

    846 chapter 3: coldfusion functions sqr description calculates the square root of a number. Returns number; square root of number. Category mathematical functions function syntax sqr(number) see also abs parameters usage the value in number must be greater than or equal to 0. Example returns the squ...

  • Page 847

    Stripcr 847 stripcr description deletes return characters from a string. Returns a copy of string, after removing return characters. Category display and formatting functions , string functions function syntax stripcr(string) see also paragraphformat parameters usage useful for preformatted (between...

  • Page 848

    848 chapter 3: coldfusion functions structappend description appends one structure to another. Returns true, upon successful completion; false, otherwise. Category structure functions function syntax structappend(struct1, struct2, overwriteflag) see also structure functions ; “modifying a coldfusion...

  • Page 849

    Structappend 849 the person struct before the append call: #myitem# the person struct after the append call: #myitem#.

  • Page 850

    850 chapter 3: coldfusion functions structclear description removes all data from a structure. Returns true, on successful execution; false, otherwise. Category structure functions function syntax structclear(structure) see also structure functions ; “modifying a coldfusion xml object” in chapter 35...

  • Page 851

    Structclear 851 structinsert(employee, "lastname", form.Lastname); structinsert(employee, "email", form.Email); structinsert(employee, "phone", form.Phone); structinsert(employee, "department", form.Department); structclear(employee);.

  • Page 852

    852 chapter 3: coldfusion functions structcopy description copies a structure. Copies top-level keys, values, and arrays in the structure by value; copies nested structures by reference. Returns a copy of a structure, with the same keys and values; if structure does not exist, throws an exception. C...

  • Page 853

    Structcopy 853 the following table shows how variables are assigned: example // this script creates a structure that structcopy copies by value. // create elements. S = structnew(); s.Array = arraynew(2); // assign simple values to original top-level structure fields. S.Number = 99; s.String = "hell...

  • Page 854

    854 chapter 3: coldfusion functions modified original values // simple values s.Number = #s.Number# s.String = #s.String# // array value s.Array[1][1] = #s.Array[1][1]# s.Array[1][2] = #s.Array[1][2]# copied structure values should be the same as the original. // simple values copied.Number = #copie...

  • Page 855

    Structcopy 855 s.Nested.Number = 100; s.Nested.String = "hello tommy (modified)"; s.Nested.Array[1][1] = "one one (modified)"; s.Nested.Array[1][2] = "one two (modified)"; modified original values // simple values s.Nested.Number = #s.Nested.Number# s.Nested.String = #s.Nested.String# // array value...

  • Page 856

    856 chapter 3: coldfusion functions structcount description counts the keys in a structure. Returns a number; if structure does not exist, throws an exception. Category structure functions function syntax structcount(structure) see also structure functions ; “modifying a coldfusion xml object” in ch...

  • Page 857

    Structcount 857 employee add complete #structcount(attributes.Empinfo)# columns added. --->.

  • Page 858

    858 chapter 3: coldfusion functions structdelete description removes an element from a structure. Returns boolean value. The value depends on the indicatenotexisting parameter value. Category structure functions function syntax structdelete(structure, key [, indicatenotexisting ]) see also structure...

  • Page 859

    Structdelete 859 structinsert(employee, "phone", phone); structinsert(employee, "department", department); before deletion, employee structure looks like this: did i delete the field "#form.Field#"? The code indicates: #rc# the structure now looks like this: select the field to be deleted: first nam...

  • Page 860

    860 chapter 3: coldfusion functions structfind description determines the value associated with a key in a structure. Returns the value associated with a key in a structure; if structure does not exist, throws an exception. Category structure functions function syntax structfind(structure, key) see ...

  • Page 861

    Structfind 861 employee add complete --->.

  • Page 862

    862 chapter 3: coldfusion functions structfindkey description searches recursively through a substructure of nested arrays, structures, and other elements, for structures whose values match the search key in the value parameter. Returns an array that contains structures with values that match value....

  • Page 863

    Structfindvalue 863 structfindvalue description searches recursively through a substructure of nested arrays, structures, and other elements for structures with values that match the search key in the value parameter. Returns an array that contains structures with values that match the search key va...

  • Page 864

    864 chapter 3: coldfusion functions structget description gets a structure(s) from a specified path. Returns an alias to the variable in the pathdesired parameter. If necessary, structget creates structures or arrays to make pathdesired a valid variable "path." category structure functions function ...

  • Page 865

    Structget 865 dog.Myscope.Test.Foo is not defined #dog.Myscope.Test.Foo# #request.Myscope[1].Test.Foo# #request.Myscope[1].Test[2].Foo#.

  • Page 866

    866 chapter 3: coldfusion functions structinsert description inserts a key-value pair into a structure. Returns true, upon successful completion. If structure does not exist, or if key exists and allowoverwrite = "false" , coldfusion throws an exception. Category structure functions function syntax ...

  • Page 867

    Structinsert 867 structinsert(employee, "lastname", form.Lastname); structinsert(employee, "email", form.Email); structinsert(employee, "phone", form.Phone); structinsert(employee, "department", form.Department); first name is #structfind(employee, "firstname")# last name is #structfind(employee, "l...

  • Page 868

    868 chapter 3: coldfusion functions structisempty description determines whether a structure contains data. Returns true, if structure is empty; if structure does not exist, coldfusion throws an exception. Category decision functions , structure functions function syntax structisempty(structure) see...

  • Page 869

    Structisempty 869 employee add complete.

  • Page 870

    870 chapter 3: coldfusion functions structkeyarray description finds the keys in a coldfusion structure. Returns an array of keys; if structure does not exist, coldfusion throws an exception. Category structure functions function syntax structkeyarray(structure) see also structure functions ; “modif...

  • Page 871

    Structkeyarray 871 value = "" hspace = "30" maxlength = "30"> value = "" hspace = "30" maxlength = "30"> value = "" hspace = "30" maxlength = "30"> value = "" hspace = "20" maxlength = "20"> value = "" hspace = "30" maxlength = "30"> value = "ok"> key#i# is #keystostruct[i]# value#i# is #employee[ke...

  • Page 872

    872 chapter 3: coldfusion functions structkeyexists description determines whether a specific key is present in a structure. Returns true, if key is in structure; if structure does not exist, coldfusion throws an exception. Category decision functions , structure functions function syntax structkeye...

  • Page 873

    Structkeylist 873 structkeylist description extracts keys from a coldfusion structure. Returns a list of keys; if structure does not exist, coldfusion throws an exception. Category structure functions function syntax structkeylist(structure [, delimiter]) see also structure functions ; “modifying a ...

  • Page 874

    874 chapter 3: coldfusion functions this example uses structnew function to create structure "employee" that supplies employee information. The fields are filled with the contents of the following form. After you enter employee information into structure, example uses structkeylist function to list ...

  • Page 875

    Structnew 875 structnew description creates a structure. Returns a structure. Category structure functions function syntax structnew() see also structure functions ; “structure functions” in chapter 5, “using arrays and structures,” in coldfusion mx developer’s guide parameters none example please f...

  • Page 876

    876 chapter 3: coldfusion functions structsort description returns a sorted array of the top level keys in a structure. Sorts using alphabetic or numeric sorting, and can sort based on the values of any structure element. Returns an array of top-level key names (strings), sorted by the value of the ...

  • Page 877

    Structsort 877 employee = structnew() ; employee["salary"] = salary ; // employee.Salary = salary ; employees["employee#i#"] = employee ; departments["department#i#"] = structnew() ; departments["department#i#"].Boss = employee ; } list of employees based on the salary (text search): 1) #arraytolist...

  • Page 878

    878 chapter 3: coldfusion functions structupdate description updates a key with a value. Returns true, on successful execution; if the structure does not exist, coldfusion throws an error. Category structure functions function syntax structupdate(structure, key, value) see also structure functions ;...

  • Page 879

    Tan 879 tan description calculates the tangent of an angle that is entered in radians. Returns a number; the tangent of an angle. Category mathematical functions function syntax tan(number) see also atn , cos , acos , sin , asin , pi parameters usage to convert degrees to radians, multiply degrees b...

  • Page 880

    880 chapter 3: coldfusion functions enter an angle in degrees to get its tangent:.

  • Page 881

    Timeformat 881 timeformat description formats a time value using u.S. English time formatting conventions. Returns a custom-formatted time value. If no mask is specified, returns a time value using the hh:mm tt format. For international time formatting, see lstimeformat . Category date and time func...

  • Page 882

    882 chapter 3: coldfusion functions parameters usage when passing a date/time value as a string, you must enclose it in quotation marks. Otherwise, it is interpreted as a number representation of a date/time object. Database query results for date and time values can vary in sequence and formatting ...

  • Page 883

    Timeformat 883 timeformat function. For example: dateformat(now(), "yyyy-mm-dd")#t#timeformat(now(), "hh:mm:ss") produces: #dateformat(now(), "yyyy-mm-dd")#t#timeformat(now(), "hh:mm:ss")# cfoutput>.

  • Page 884

    884 chapter 3: coldfusion functions tobase64 description calculates the base64 representation of a string or binary object. The base64 format uses printable characters, allowing binary data to be sent in forms and e-mail, and stored in a database or file. Returns the base64 representation of a strin...

  • Page 885

    Tobase64 885 usage macromedia recommends that you use the binaryencode function to convert binary data to base64-encoded data in all new applications. The following string is the concatenation of all characters (32 to 255) from the ascii table. #chardata# tobase64(chardata)> tobase64(binarydata)>.

  • Page 886

    886 chapter 3: coldfusion functions tobinary description calculates the binary representation of base64-encoded data. Returns the binary representation of base64-encoded data. Category conversion functions , string functions function syntax tobinary(string_in_base64 or binary_value) see also • binar...

  • Page 887

    Tobinary 887 tobinary(data64)> representation of string data..

  • Page 888

    888 chapter 3: coldfusion functions toscript description creates a javascript or actionscript expression that assigns the value of a coldfusion variable to a javascript or actionscript variable. This function can convert coldfusion strings, numbers, arrays, structures, and queries to javascript or a...

  • Page 889

    Toscript 889 usage to use a coldfusion variable in javascript or actionscript, the toscript function must be in a cfoutput region and be surrounded by number signs (#). For example, the following code uses the toscript function to convert a coldfusion variable to a javascript variable: var #toscript...

  • Page 890

    890 chapter 3: coldfusion functions an actionscript-style array does not require you to include the wddx.Js file, and creates a variable that you can use in actionscript on a flash format form, for example, in an onchange attribute. If the outputformat parameter is false, setting asformat to true ca...

  • Page 891

    Toscript 891 { document.Write("myarray[" + i + "]: " + jsarray[i] + ""); } this section converts the following query object to both wddx format and actionscript type javascript objects. Select firstname,lastname from employee where firstname = 'john' the query in coldfusion javascript generated by t...

  • Page 892

    892 chapter 3: coldfusion functions tostring description converts a value to a string. Returns a string. Category conversion functions , string functions function syntax tostring(value[, encoding]) see also tobase64 , tobinary , charsetencode ; chapter 35, “using xml and wddx,” in coldfusion mx deve...

  • Page 893

    Tostring 893 parameters usage this function can convert simple values and binary values that do not contain byte zero. If this function cannot convert a value, it throws an exception. This function can also convert an xml document object to a string xml representation. Macromedia recommends that you...

  • Page 894

    894 chapter 3: coldfusion functions tostring(databinary)> the following is the string representation of the binary data. #datastring#.

  • Page 895

    Trim 895 trim description removes leading and trailing spaces from a string. Returns a copy of string, after removing leading and trailing spaces. Category string functions function syntax trim(string) see also ltrim , rtrim parameters example your string:"#form.Mytext#" your string:"#trim(form.Myte...

  • Page 896

    896 chapter 3: coldfusion functions ucase description converts the alphabetic characters in a string to uppercase. Returns a copy of a string, converted to uppercase. Category string functions function syntax ucase(string) see also lcase parameters example your text, #form.Sampletext#, returned in u...

  • Page 897

    Urldecode 897 urldecode description decodes a url-encoded string. Returns a copy of a string, decoded. Category conversion functions , other functions , string functions function syntax urldecode(urlencodedstring[, charset]) see also urlencodedformat ; “tags and functions for globalizing” in chapter...

  • Page 898

    898 chapter 3: coldfusion functions usage url encoding formats some characters with a percent sign and the two-character hexadecimal representation of the character. For example, a character whose code is 129 is encoded as %81 . A space is encoded with a plus sign. Query strings in http are always u...

  • Page 899

    Urlencodedformat 899 urlencodedformat description generates a url-encoded string. For example, it replaces spaces with %20 , and non- alphanumeric characters with equivalent hexadecimal escape sequences. Passes arbitrary strings within a url (coldfusion automatically decodes url parameters that are ...

  • Page 900

    900 chapter 3: coldfusion functions usage url encoding formats some characters with a percent sign and the two-character hexadecimal representation of the character. For example, a character whose code is 129 is encoded as %81 . A space is encoded with a plus sign. Query strings in http are always u...

  • Page 901

    Urlsessionformat 901 urlsessionformat description depending on whether a client computer accepts cookies, this function does the following: • if the client does not accept cookies: automatically appends all required client identification information to a url • if the client accepts cookies: does not...

  • Page 902

    902 chapter 3: coldfusion functions val description converts numeric characters that occur at the beginning of a string to a number. Returns a number. If conversion fails, returns zero. Category conversion functions , string functions function syntax val(string) see also isnumeric parameters usage t...

  • Page 903

    Val 903 value = "is the beginning numeric?" name = "">.

  • Page 904

    904 chapter 3: coldfusion functions valuelist description inserts a delimiter between each value in an executed query. Coldfusion does not evaluate the arguments. Returns a delimited list of the values of each record returned from an executed query. Category list functions , query functions function...

  • Page 905

    Week 905 week description from a date/time object, determines the week number within the year. Returns an integer in the range 1–53; the ordinal of the week, within the year. Category date and time functions function syntax week(date) see also datepart parameters usage when passing date as a string,...

  • Page 906

    906 chapter 3: coldfusion functions wrap description wraps text so that each line has a specified maximum number of characters. Returns string containing the wrapped text. Category string functions function syntax wrap(string, limit[, strip]) see also cfmail history coldfusion mx 6.1: added this fun...

  • Page 907

    Writeoutput 907 writeoutput description appends text to the page-output stream. This function writes to the page-output stream regardless of conditions established by the cfsetting tag. Category other functions , system functions function syntax writeoutput(string ) parameters usage within the cfque...

  • Page 908

    908 chapter 3: coldfusion functions xmlchildpos description gets the position of a child element within an xml document object. Returns the position, in an xmlchildren array, of the nth child that has the specified name. Category xml functions function syntax xmlchildpos(elem, childname, n) see also...

  • Page 909

    Xmlchildpos 909 laura ingalls elempos=xmlchildpos(xmlobject.Employee.Name[1], "status", 2); arraydeleteat(xmlobject.Employee.Name[1].Xmlchildren, elempos);.

  • Page 910

    910 chapter 3: coldfusion functions xmlelemnew description creates an xml document object element. Returns an xml document object element. Category xml functions function syntax xmlelemnew(xmlobj[, namespace], childname) see also cfxml , isxmlelem , xmlchildpos , xmlformat , xmlnew , xmlparse ; chap...

  • Page 911

    Xmlelemnew 911 else mydoc.Myroot.Xmltext = "the value of testvar is false."; for (i = 1; i lte 4; i = i + 1) { mydoc.Myroot.Xmlchildren[i] = xmlelemnew(mydoc,"childnode"); mydoc.Myroot.Xmlchildren[i].Xmltext = "this is child node " & i &"."; }.

  • Page 912

    912 chapter 3: coldfusion functions xmlformat description escapes special xml characters in a string so that the string can be used as text in xml. Returns a copy of the string parameter that is safe to use as text in xml. Category string functions , xml functions function syntax xmlformat(string) s...

  • Page 913

    Xmlformat 913 #"> #xmlformat("body of element with , "" and & goes here.")#.

  • Page 914

    914 chapter 3: coldfusion functions xmlgetnodetype description determines the type of an xml document object node. Returns a string identifying the xml node type. The following values are valid: if the argument is not a document object node, the function generates an error. Category xml functions fu...

  • Page 915

    Xmlgetnodetype 915 imported from france 1 15.95 xmlobject: #xmlgetnodetype(xmlobject)# xmlobject.Order: #xmlgetnodetype(xmlobject.Order)# now check the types of all the nodes in the xmlobject.Order.Items.Item element’s xmlnodes array. Note the many apparently empty text nodes generated by whitespace...

  • Page 916

    916 chapter 3: coldfusion functions xmlnew description creates an xml document object. Returns an empty xml document object. Category xml functions function syntax xmlnew([casesensitive]) see also cfxml , isxmldoc , tostring , xmlformat , xmlparse , xmlvalidate ; chapter 35, “using xml and wddx” in ...

  • Page 917

    Xmlnew 917 example the following example creates and displays a coldfusion document object: mydoc = xmlnew(); mydoc.Xmlroot = xmlelemnew(mydoc,"myroot"); if (testvar is true) mydoc.Myroot.Xmltext = "the value of testvar is true."; else mydoc.Myroot.Xmltext = "the value of testvar is false."; for (i ...

  • Page 918

    918 chapter 3: coldfusion functions xmlparse description converts xml text into an xml document object. Returns an xml document object. Category conversion functions , xml functions function syntax xmlparse(xmltext [[, casesensitive ], validator]) see also cfxml , isxml , tostring , xmlformat , xmln...

  • Page 919

    Xmlparse 919 the casesensitive parameter value determines whether identifiers whose characters are of varying case, but are otherwise the same, refer to different components; for example: • if true, the element or attribute names “name” and “name” refer to different elements or attributes. • if fals...

  • Page 920

    920 chapter 3: coldfusion functions standard paint thinner 3 8.95 the custorder.Dtd file is as follows: id cdata #required> firstname cdata #required lastname cdata #required accountnum cdata #required> id cdata #required> the cfml file is as follows. It uses a filename for the xml file and a url fo...

  • Page 921

    Xmlsearch 921 xmlsearch description uses an xpath language expression to search an xml document object. Returns an array of xml object nodes that match the search criteria. Category xml functions function syntax xmlsearch(xmldoc, xpathstring) see also cfxml , isxml , xmlchildpos , xmlparse , xmltran...

  • Page 922

    922 chapter 3: coldfusion functions laura ingalls the cfml file contains the following lines: myxmldoc = xmlparse("c:\cfusionmx7\wwwroot\examples\employeesimple.Xml"); selectedelements = xmlsearch(myxmldoc, "/employee/name/last"); for (i = 1; i lte arraylen(selectedelements); i = i + 1) writeoutput(...

  • Page 923

    Xmltransform 923 xmltransform description applies an extensible stylesheet language transformation (xslt) to xml. The xml can be in string format or an xml document object. Returns a string containing the results of applying the xslt to the xml. Category conversion functions , xml functions function...

  • Page 924

    924 chapter 3: coldfusion functions if the xslt code contains include statements with relative paths, coldfusion resolves them relative to the location of the xslt file, or for an xsl string, the location of the current coldfusion page. Example the following example converts an xml document that rep...

  • Page 925

    Xmltransform 925 the cfml file has the following lines: variable="xmltrans"> #xmltransform(xmldoc, xmltrans)# variable="xmltrans"> #xmltransform(xmldoc, xmltrans)#.

  • Page 926

    926 chapter 3: coldfusion functions xmlvalidate description uses a document type definition (dtd) or xml schema to validate an xml text document or an xml document object. Returns the following validation structure: category xml functions function syntax xmlvalidate(xmldoc[, validator]) see also cfx...

  • Page 927

    Xmlvalidate 927 usage if you specify a relative url or filename in a parameter, coldfusion uses the directory (or, for urls, the virtual directory) that contains the current coldfusion page as the path root. The validato r parameter specifies a dtd or schema to use to validate the document. If you o...

  • Page 928

    928 chapter 3: coldfusion functions the custorder.Xsd file is as follows: elementformdefault="qualified"> elementformdefault="qualified"> the cfml file is as follows. It uses a filename for the xml file and a url for the schema. The xml and url paths must be absolute. Myresults=xmlvalidate("c:\cfusi...

  • Page 929

    Xmlvalidate 929 did custorder.Xml validate against custorder.Xsd? #results.Status# dump of myresults structure returned by xmlvalidate.

  • Page 930

    930 chapter 3: coldfusion functions year description from a date/time object, gets the year value. Returns the year value of date. Category date and time functions function syntax year(date) see also datepart , isleapyear parameters usage when passing a date as a string, enclose it in quotation mark...

  • Page 931

    Yesnoformat 931 yesnoformat description evaluates a number or boolean value. Returns yes, for a nonzero value; no for zero, false , and no boolean values, and an empty string ( "") . Category decision functions , display and formatting functions function syntax yesnoformat(value) see also isbinary ,...

  • Page 932

    932 chapter 3: coldfusion functions.

  • Page 933: Chapter 4

    933 chapter 4 coldfusion mx flash form style reference this chapter describes the styles that you can specify in macromedia coldfusion mx 7 forms tags when you display the form or form element in flash format. Contents styles valid for all controls . . . . . . . . . . . . . . . . . . . . . . . . . ....

  • Page 934

    934 chapter 4: coldfusion mx flash form style reference styles valid for all controls the following styles are valid for all coldfusion flash format form tags except for cfformitem tags with the following type attributes, which do not take style attributes: • html • space • text these styles do not ...

  • Page 935

    Styles valid for all controls 935 dropshadow n format: boolean; controls the visibility of the component's drop shadow. The default value is false. This style must be used with borderstyle="solid". For drop shadows to appear on containers, set backgroundcolor or backgroundimage. Otherwise, since the...

  • Page 936

    936 chapter 4: coldfusion mx flash form style reference styles for cfform the following styles apply to the cfform tag: styles for cfformgroup with horizontal or vertical type atributes the following styles apply to the cfformgroup tag with type attributes horizontal or vertical : themecolor y forma...

  • Page 937

    Styles for box-style cfformgroup elements 937 styles for box-style cfformgroup elements the following styles apply to the cfformgroup tag with the following type attributes. Some types have additional attributes, which are listed in the following sections. • hbox • vbox • hdividedbox • vdividedbox •...

  • Page 938

    938 chapter 4: coldfusion mx flash form style reference styles specific to cfformgroup with panel type attribute the following additional styles apply to the cfformgroup tag with type="panel" : styles for cfformgroup with accordion type attribute the following styles apply to the cfformgroup tag wit...

  • Page 939

    Styles for cfformitem with hrule or vrule type attributes 939 styles for cfformgroup with tabnavigator type attribute the following styles apply to the cfformgroup tag with the type="tabnavigator" : styles for cfformitem with hrule or vrule type attributes the following styles apply to the formitem ...

  • Page 940

    940 chapter 4: coldfusion mx flash form style reference styles for cfinput with radiobutton, checkbox, button, image, or submit type attributes the following styles apply cfinput tags with the following type attribute values: • button • checkbox • image • radiobutton • submit in some cases, a style ...

  • Page 941

    Styles for cfselect with size attribute value of 1 941 styles for cftextarea tag and cfinput with text, password, or hidden type attributes the following style applies to the following tags and tag-attribute combinations: • textarea • cfinput type="hidden" • cfinput type="password" • cfinput type="t...

  • Page 942

    942 chapter 4: coldfusion mx flash form style reference styles for cfselect with size attribute value greater than 1 the following styles apply to the cfselect tag when the size attribute is greater than 1; that is, if the control is a list box that displays two or more options at a time: styles for...

  • Page 943

    Styles for the cftree tag 943 styles for the cfgrid tag the following styles apply to the cfgrid tag: styles for the cftree tag the following styles apply to the cftree tag: style inh description horizontalalign n horizontal alignment of children in the container. The default value is left. Possible...

  • Page 944

    944 chapter 4: coldfusion mx flash form style reference.

  • Page 945: Chapter 5

    945 chapter 5 application.Cfc reference this chapter describes the methods that you implement in application.Cfc to handle macromedia coldfusion mx 7 application events. It also describes the variables that you set in the cfc to configure application characteristics. Contents application variables ....

  • Page 946

    946 chapter 5: application.Cfc reference the following table briefly describes the variables that you can set to control the application behavior. For more details, see the cfapplication tag. Method summary the following table briefly describes the application event methods that you can implement in...

  • Page 947

    Method summary 947 all parameters to these methods are positional. You can use any names for these parameters. When a request executes, coldfusion mx runs the cfc methods in the following order: 1. Onapplicationstart (if not run before for this application) 2. Onsessionstart (if not run before for t...

  • Page 948

    948 chapter 5: application.Cfc reference onapplicationend description runs when an application times out or the server is shutting down. Syntax ... See also onapplicationstart , method summary , “managing the application with application.Cfc” in chapter 13, “designing and optimizing a coldfusion app...

  • Page 949

    Onapplicationstart 949 onapplicationstart description runs when coldfusion mx receives the first request for a page in the application. Syntax ... Boolean> see also onapplicationend , method summary , “managing the application with application.Cfc” in chapter 13, “designing and optimizing a coldfusi...

  • Page 950

    950 chapter 5: application.Cfc reference this application encountered an error please contact support. Text="cfdocexamples db not available. Message: #cfcatch.Message# detail: #cfcatch.Detail# native error: #cfcatch.Nativeerrorcode#" > application.Availableresources=0; application.Counter1=1; text="...

  • Page 951

    Onerror 951 onerror description runs when an uncaught exception occurs in the application. Syntax ... See also method summary , “handling errors in application.Cfc” in coldfusion mx developer’s guide parameters coldfusion mx passes the following parameters to the method: returns this method does not...

  • Page 952

    952 chapter 5: application.Cfc reference if an exception occurs while processing the onerror method, or if the onerror method uses a cfthrow tag, the coldfusion mx standard error handling mechanisms handle the exception. These mechanisms include: any error handlers specified by cferror tags in the a...

  • Page 953

    Onrequest 953 onrequest description runs when a request starts, after the onrequeststart event handler. If you implement this method, it must explicitly call the requested page to process it. Syntax ... ... See also onrequeststart , onrequestend , method summary , “managing requests in application.C...

  • Page 954

    954 chapter 5: application.Cfc reference • code in this method that precedes the call to the target page can perform the same functions as the onrequeststart method, and shares the variables scope with the target page. • code in this method that follows the call to the target page can perform the sa...

  • Page 955

    Onrequestend 955 onrequestend description runs at the end of a request, after all other cfml code. Syntax ... See also onrequeststart , onrequest , method summary , “managing requests in application.Cfc” in coldfusion mx developer’s guide parameters coldfusion mx passes the following parameters to t...

  • Page 956

    956 chapter 5: application.Cfc reference a very simple authuserfooter.Cfm page consists of the following code: a very simple noauthuserfooter.Cfm page consists of the following code: to test this example, implement code for logging in a user, or try the example with and without the following line in...

  • Page 957

    Onrequeststart 957 onrequeststart description runs when a request starts. Syntax ... Boolean> see also onrequest , onrequestend , method summary , “managing requests in application.Cfc” in coldfusion mx developer’s guide parameters coldfusion mx passes the following parameters to the method: returns...

  • Page 958

    958 chapter 5: application.Cfc reference if ((hour(now()) gt 1) and (hour(now()) lt 3)) { writeoutput("the system is undergoing periodic maintenance. Please return after 3:00 am eastern time."); return false; } else { this.Start=now(); return true; }.

  • Page 959

    Onsessionend 959 onsessionend description runs when a session ends. Syntax ... See also onsessionstart , method summary , “managing sessions in application.Cfc” in coldfusion mx developer’s guide parameters coldfusion mx passes the following parameters to the method: returns this method does not ret...

  • Page 960

    960 chapter 5: application.Cfc reference • you must use the applicationscope parameter to access the application scope. You cannot reference the application scope directly; for example, use arguments.Applicationscope.Myvariable, not application.Myvariable. Use a named lock when you reference variabl...

  • Page 961

    Onsessionstart 961 onsessionstart description runs when a session starts. Syntax ... See also onsessionend , method summary , “managing sessions in application.Cfc” in coldfusion mx developer’s guide returns this method does not return a value; do not use the cfreturn tag. Usage this method is usefu...

  • Page 962

    962 chapter 5: application.Cfc reference.

  • Page 963: Chapter 6

    963 chapter 6 coldfusion mx event gateway reference this chapter describes the java interfaces available for building macromedia coldfusion mx 7 custom cfxs in java. Contents gateway development interfaces and classes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 963 cf...

  • Page 964

    964 chapter 6: coldfusion mx event gateway reference gateway interface coldfusion.Eventgateway.Gateway interface for implementing coldfusion mx event gateways. A class that implements this interface defines a coldfusion mx event gateway type that you can use in coldfusion mx applications. The class ...

  • Page 965

    Gateway interface 965 constructor description instantiates a gateway. Category event gateway development syntax public void gatewayname() public void gatewayname(string id) public void gatewayname(string id, string configfile) see also setgatewayid , “class constructor” in chapter 45, “creating cust...

  • Page 966

    966 chapter 6: coldfusion mx event gateway reference getgatewayid description returns the gateway id that identifies the gateway instance. Category event gateway development syntax public string getgatewayid() see also setgatewayid , “providing gateway class service and information routines” in chap...

  • Page 967

    Gateway interface 967 gethelper description returns an instance of the gatewayhelper class, if any for the gateway type. Category event gateway development syntax public gatewayhelper gethelper() see also gatewayhelper interface ; “providing gateway class service and information routines” in chapter...

  • Page 968

    968 chapter 6: coldfusion mx event gateway reference getstatus description returns the gateway status. Category event gateway development syntax public int getstatus() see also “providing gateway class service and information routines” in chapter 45, “creating custom event gateways” in coldfusion mx...

  • Page 969

    Gateway interface 969 outgoingmessage description sends a message from coldfusion to a message receiver. Category event gateway development syntax public string outgoingmessage(coldfusion.Eventgateway.Cfevent message) see also “responding to a coldfusion function or listener cfc” in chapter 45, “cre...

  • Page 970

    970 chapter 6: coldfusion mx event gateway reference retcode="failed"; } } else if (data.Get("originatorid") != null && message != null) { socketserverthread st = ((socketserverthread)socketregistry.Get(data.Get("originatorid"))); if(st != null) st.Writeoutput(message); else { log.Error("cannot send...

  • Page 971

    Gateway interface 971 restart description stops a gateway if it is running and starts it up. Category event gateway development syntax public void restart() see also start , stop usage in most cases, you implement this method as a call to the stop method followed by a start method, but you may be ab...

  • Page 972

    972 chapter 6: coldfusion mx event gateway reference setcfclisteners description sets the array of listener cfcs that the gateway sends messages to. Category event gateway development syntax public void setcfclisteners(string[] listeners) see also constructor , getgatewayid , setcfcpath , “providing...

  • Page 973

    Gateway interface 973 setgatewayid description sets the gateway id that uniquely identifies the gateway instance. Category event gateway development syntax public void setgatewayid(string id) see also constructor , getgatewayid , “providing gateway class service and information routines” in chapter ...

  • Page 974

    974 chapter 6: coldfusion mx event gateway reference start description starts a gateway running. Category event gateway development syntax public void start() see also restart , stop , “the start method” in chapter 45, “creating custom event gateways” in coldfusion mx developer’s guide usage start a...

  • Page 975

    Gateway interface 975 stop description stops a gateway if it is running. Category event gateway development syntax public void stop() see also restart , start , “the stop method” in chapter 45, “creating custom event gateways” in coldfusion mx developer’s guide usage stops a gateway by performing an...

  • Page 976

    976 chapter 6: coldfusion mx event gateway reference gatewayhelper interface coldfusion.Eventgateway.Gatewayhelper coldfusion mx includes a coldfusion.Eventgateway.Gatewayhelper java marker interface, with no methods. Implement this interface to define a class that provides gateway-specific utility ...

  • Page 977

    Gatewayservices class 977 gatewayservices class coldfusion.Eventgateway.Gatewayservices the gateway class uses the coldfusion.Eventgateway.Gatewayservices class to interact with the coldfusion event gateway services. This class has the following methods: signature description gatewayservices getgate...

  • Page 978

    978 chapter 6: coldfusion mx event gateway reference getgatewayservices description static method that returns the gatewayservices object. Gateway code can call this method at any time, if required. Category event gateway development syntax gatewayservices getgatewayservices() see also “gatewayservi...

  • Page 979

    Gatewayservices class 979 addevent description sends a cfevent instance to coldfusion for dispatching to a listener cfc. Category event gateway development syntax boolean addevent(cfevent msg) see also getmaxqueuesize , getmaxqueuesize , “responding to incoming messages” in chapter 45, “creating cus...

  • Page 980

    980 chapter 6: coldfusion mx event gateway reference getlogger description returns a coldfusion logger object that the event gateway can use to log information in a file. Category event gateway development syntax coldfusion.Eventgateway.Logger getlogger([string logfile]) see also logger class , “log...

  • Page 981

    Gatewayservices class 981 getmaxqueuesize description returns the maximum size of the coldfusion event queue, as set in the coldfusion mx administrator. Category event gateway development syntax int getmaxqueuesize() see also addevent , getqueuesize returns the integer maximum number of messages tha...

  • Page 982

    982 chapter 6: coldfusion mx event gateway reference getqueuesize description returns the current size of the coldfusion event queue that handles all messages for all gateways. Category event gateway development syntax int getqueuesize() see also addevent , getmaxqueuesize returns the integer number...

  • Page 983

    Cfevent class 983 cfevent class coldfusion.Gateway.Cfevent the gateway class sends and receives cfevent instances to communicate with the coldfusion listener cfc or application. The cfevent instances correspond to cfml cfevent structure s that coldfusion application listener cfc methods receive and ...

  • Page 984

    984 chapter 6: coldfusion mx event gateway reference cfevent description cfevent constructor. Category event gateway development syntax cfevent(string gatewayid) see also getgatewayid , “cfml cfevent structure” on page 1004 , “cfevent class” in chapter 45, “creating custom event gateways” in coldfus...

  • Page 985

    Cfevent class 985 getcfcmethod description gets the name of the cfc method that processes the message. Category event gateway development syntax string getcfcmethod() see also getcfcpath , getcfctimeout , setcfcmethod , “cfml cfevent structure” on page 1004 , “cfevent class” in chapter 45, “creating...

  • Page 986

    986 chapter 6: coldfusion mx event gateway reference getcfcpath description gets the path to the listener cfc that processes this message. Category event gateway development syntax string getcfcpath() see also getcfcmethod , getcfctimeout , setcfcpath , “cfml cfevent structure” on page 1004 , “cfeve...

  • Page 987

    Cfevent class 987 getcfctimeout description gets the time-out, in seconds, for the listener cfc to process the event request. Category event gateway development syntax string getcfctimeout() see also getcfcmethod , getcfcpath , setcfctimeout , “cfml cfevent structure” on page 1004 , “cfevent class” ...

  • Page 988

    988 chapter 6: coldfusion mx event gateway reference getdata description returns the data map that contains the message contents and other gateway-specific information. Category event gateway development syntax map getdata() see also setdata , “cfml cfevent structure” on page 1004 , “cfevent class” ...

  • Page 989

    Cfevent class 989 getgatewayid description returns the gateway id field of the cfevent object. Category event gateway development syntax string getgatewayid(cfevent event) see also cfevent , “cfml cfevent structure” on page 1004 , “cfevent class” in chapter 45, “creating custom event gateways” in co...

  • Page 990

    990 chapter 6: coldfusion mx event gateway reference getgatewaytype description returns the gateway type field of the cfevent object. Category event gateway development syntax string getgatewaytype() see also setgatewaytype , “cfml cfevent structure” on page 1004 , “cfevent class” in chapter 45, “cr...

  • Page 991

    Cfevent class 991 getoriginatorid description identifies the originator of an incoming message. Some gateway types also use this field for the destination of an outgoing message. Category event gateway development syntax string getoriginatorid() see also setoriginatorid , “cfml cfevent structure” on...

  • Page 992

    992 chapter 6: coldfusion mx event gateway reference setcfcmethod description sets the name of the cfc method that will processes an incoming message. Category event gateway development syntax void setcfcmethod(string method) see also getcfcmethod , setcfcpath , setcfctimeout , “cfml cfevent structu...

  • Page 993

    Cfevent class 993 setcfcpath description specifies the listener cfc that will process this event. Category event gateway development syntax void setcfcpath(string path) see also getcfcpath , setcfcmethod , setcfctimeout , “cfevent class” in chapter 45, “creating custom event gateways” in coldfusion ...

  • Page 994

    994 chapter 6: coldfusion mx event gateway reference setcfctimeout description sets the time-out, in seconds, during which the listener cfc must process the event request and return before coldfusion gateway services terminates the request. Category event gateway development syntax void setcftimeout...

  • Page 995

    Cfevent class 995 setdata description adds the gateway-specific data, including any message contents, as a java map to the cfevent object category event gateway development syntax void setdata(map data) see also getdata , “cfml cfevent structure” on page 1004 , “cfevent class” in chapter 45, “creati...

  • Page 996

    996 chapter 6: coldfusion mx event gateway reference setgatewaytype description identifies the type of event gateway. Category event gateway development syntax void setgatewaytype(string gatewaytype) see also parameters getgatewaytype , “cfml cfevent structure” on page 1004 , “cfevent class” in chap...

  • Page 997

    Cfevent class 997 setoriginatorid description identifies the originator of an incoming message. Category event gateway development syntax void setoriginatorid(string originatorid) see also getoriginatorid , “cfml cfevent structure” on page 1004 , “cfevent class” in chapter 45, “creating custom event...

  • Page 998

    998 chapter 6: coldfusion mx event gateway reference logger class coldfusion.Eventgateway.Logger note: this class is in the coldfusion.Log package, not the coldfusion.Eventgateway package, which contains all other event gateway-related interfaces and classes. The logger class logs messages to a file...

  • Page 999

    Logger class 999 debug description writes a log entry with a debugging severity to the coldfusion mx logger. The entry includes the severity, thread id, date, time, and a text message. Category event gateway development syntax debug(string message) debug(throwable th) debug(string message, throwable...

  • Page 1000

    1000 chapter 6: coldfusion mx event gateway reference error description writes a log entry with an error severity to the coldfusion mx logger. The entry includes the severity, thread id, date, time, and a text message. Category event gateway development syntax error(string message) error(throwable t...

  • Page 1001

    Logger class 1001 fatal description writes a log entry with a fatal severity to the coldfusion mx logger. The entry includes the severity, thread id, date, time, and a text message. Category event gateway development syntax fatal(string message) fatal(throwable th) fatal(string message, throwable th...

  • Page 1002

    1002 chapter 6: coldfusion mx event gateway reference info description writes a log entry with an information severity to the coldfusion mx logger. The entry includes the severity, thread id, date, time, and a text message. Category event gateway development syntax info(string message) info(throwabl...

  • Page 1003

    Logger class 1003 warn description writes a log entry with a warning severity to the coldfusion mx logger. The entry includes the severity, thread id, date, time, and a text message. Category event gateway development syntax warn(string message) warn(throwable th) warn(string message, throwable th) ...

  • Page 1004

    1004 chapter 6: coldfusion mx event gateway reference cfml cfevent structure the cfml listener cfc methods receive messages in the form of a cfevent structure that corresponds to the cfevent class that gateway developers use. This structure has the following fields. Some of the fields might not be u...

  • Page 1005

    Im gateway cfc incoming message methods 1005 im gateway cfc incoming message methods you write the following cfc methods to handle incoming messages from an xmpp or lotus sametime instant messaging gateway. Note: the method names assume a default gateway configuration. Coldfusion lets you change the...

  • Page 1006

    1006 chapter 6: coldfusion mx event gateway reference onaddbuddyrequest description handles incoming requests for users to add the gateway user name as one of their buddies. Syntax onaddbuddyrequest(cfevent) see also onincomingmessage , onaddbuddyresponse , onbuddystatus , onimservermessage paramete...

  • Page 1007

    Im gateway cfc incoming message methods 1007 example the following example searches for the requested buddy’s name in a data source and, if it finds a unique entry, adds the buddy and updates the buddy’s status information in an application scope buddystatus structure. If it doesn’t find the name, i...

  • Page 1008

    1008 chapter 6: coldfusion mx event gateway reference.

  • Page 1009

    Im gateway cfc incoming message methods 1009 onaddbuddyresponse description handles incoming responses from other users to requests from the gateway to be added to their buddy lists. Also receives requests from buddies to have you remove them from your buddy list. Syntax onaddbuddyresponse(cfevent) ...

  • Page 1010

    1010 chapter 6: coldfusion mx event gateway reference application.Buddystatus[#cfevent.Data.Sender#]=structnew(); } //set the buddy status information to indicate buddy was added. Application.Buddystatus[#cfevent.Data.Sender#].Status= "buddy accepted us"; application.Buddystatus[#cfevent.Data.Sender...

  • Page 1011

    Im gateway cfc incoming message methods 1011 onbuddystatus description handles incoming messages indicating online status (presence) changes of users on the gateway’s buddy list. Syntax onbuddystatus(cfevent) see also onincomingmessage , onaddbuddyrequest , onaddbuddyresponse , onimservermessage par...

  • Page 1012

    1012 chapter 6: coldfusion mx event gateway reference example the following example keeps an application scope structure up-to-date with a buddy’s status. It also uses the gatewayhelper object getbuddystatus method to get the buddy’s custom away message, if any. Text="in onbuddystatus, sender is #cf...

  • Page 1013

    Im gateway cfc incoming message methods 1013 onimservermessage description handles incoming error and status messages from the im server. Syntax onimservermessage(cfevent) see also onincomingmessage , onaddbuddyrequest , onaddbuddyresponse , onbuddystatus parameters this method must take one paramet...

  • Page 1014

    1014 chapter 6: coldfusion mx event gateway reference onincomingmessage description handles incoming instant messages from other users. Optionally returns a response to the message sender. Syntax onincomingmessage(cfevent) see also onaddbuddyrequest , onaddbuddyresponse , onbuddystatus , onimserverm...

  • Page 1015

    Im gateway cfc incoming message methods 1015.

  • Page 1016

    1016 chapter 6: coldfusion mx event gateway reference im gateway message sending commands you use the sendgatewaymessage cfml function or the return value of a cfc listener method to send outgoing messages. The coldfusion mx 7 im gateway accepts the following outgoing message commands: the message s...

  • Page 1017

    Im gateway gatewayhelper class methods 1017 im gateway gatewayhelper class methods the gatewayhelper class returned by the cfml getgatewayhelper function includes the following methods: addbuddy getdenylist getstatusasstring removedeny adddeny getname getstatustimestamp removepermit addpermit getnic...

  • Page 1018

    1018 chapter 6: coldfusion mx event gateway reference addbuddy description adds a buddy to the buddy list for the gateway user id and asks to have the im server send messages with the buddy’s online presence state to the gateway. Syntax boolean = addbuddy(name, nickname, group) see also getbuddyinfo...

  • Page 1019

    Im gateway gatewayhelper class methods 1019 adddeny description tells the im server to add the specified user to the deny list for the gateway’s user id. If the gateway’s permit mode value is deny_some, the specified user cannot receive messages on the gateway’s presence state. Syntax boolean = addd...

  • Page 1020

    1020 chapter 6: coldfusion mx event gateway reference addpermit description tells the im server to add the specified user to the permit list for the gateway’s user id. If the gateway’s permit mode is permit_some, the specified user receive messages on the gateway’s presence state. Syntax boolean = a...

  • Page 1021

    Im gateway gatewayhelper class methods 1021 getbuddyinfo description gets information about the specified user from the buddy list, deny list, and permit list. Syntax array = getbuddyinfo(name) see also addbuddy , getbuddylist , removebuddy , “using the gatewayhelper object” in chapter 43, “using th...

  • Page 1022

    1022 chapter 6: coldfusion mx event gateway reference example see “gatewayhelper example”, in chapter 43, “using the instant messaging event gateways” in coldfusion mx developer’s guide, which uses all gatewayhelper class methods. For an example of using this method to get the buddy custom away mess...

  • Page 1023

    Im gateway gatewayhelper class methods 1023 getbuddylist description gets the buddy list for the gateway’s user id. Syntax array = getbuddylist() see also addbuddy , getbuddyinfo , removebuddy , “using the gatewayhelper object” in chapter 43, “using the instant messaging event gateways” in coldfusio...

  • Page 1024

    1024 chapter 6: coldfusion mx event gateway reference getcustomawaymessage description returns the gateway’s custom away message if it has been set by the gatewayhelper object setstatus method. Syntax string = getcustomawaymessage() see also getstatusasstring , getstatustimestamp , isonline , setsta...

  • Page 1025

    Im gateway gatewayhelper class methods 1025 getdenylist description returns the list of users that the im server has been told not to send state information about the gateway, if the permit mode is set to deny_some. Syntax array = getdenylist() see also adddeny , addpermit , getpermitlist , getpermi...

  • Page 1026

    1026 chapter 6: coldfusion mx event gateway reference getname description returns the gateway's user name. Syntax string = getname() see also getprotocolname , numberofmessagesreceived , numberofmessagessent , setnickname , “using the gatewayhelper object” in chapter 43, “using the instant messaging...

  • Page 1027

    Im gateway gatewayhelper class methods 1027 getnickname description returns the gateway’s nickname (display name), if it has been set using the gatewayhelper object setnickname method. Syntax string = getnickname() see also getname , getprotocolname , numberofmessagesreceived , numberofmessagessent ...

  • Page 1028

    1028 chapter 6: coldfusion mx event gateway reference getpermitlist description returns the list of users that the im server has been told to send state information about the gateway. Syntax array = getpermitlist() see also adddeny , addpermit , getdenylist , getpermitmode , removedeny , removepermi...

  • Page 1029

    Im gateway gatewayhelper class methods 1029 getpermitmode description gets the gateway’s permit mode from the im server. The permit mode determines whether all users can get the gateway’s online state information, or whether the server uses a permit list or a deny list to control which users get sta...

  • Page 1030

    1030 chapter 6: coldfusion mx event gateway reference getprotocolname description gets the name of the gateway’s instant messaging protocol. Syntax string = getprotocolname() see also getname , getnickname , numberofmessagesreceived , numberofmessagessent , setnickname , “using the gatewayhelper obj...

  • Page 1031

    Im gateway gatewayhelper class methods 1031 getstatusasstring description gets the online status of the gateway as a text string. Syntax string = getstatusasstring() see also getcustomawaymessage , getstatustimestamp , isonline , setstatus , “using the gatewayhelper object” in chapter 43, “using the...

  • Page 1032

    1032 chapter 6: coldfusion mx event gateway reference getstatustimestamp description gets the date and time that the gateway changed its online status. Syntax date-time object = getstatustimestamp() see also getcustomawaymessage , getstatusasstring , isonline , setstatus , “using the gatewayhelper o...

  • Page 1033

    Im gateway gatewayhelper class methods 1033 isonline description determines whether the gateway is connected to the instant messaging server. Syntax boolean = isonline() see also getcustomawaymessage , getstatusasstring , getstatustimestamp , setstatus , “using the gatewayhelper object” in chapter 4...

  • Page 1034

    1034 chapter 6: coldfusion mx event gateway reference numberofmessagesreceived description gets the number of messages received by the gateway since it was started. Syntax integer = numberofmessagesreceived() see also getname , getnickname , getprotocolname , numberofmessagessent , setnickname , “us...

  • Page 1035

    Im gateway gatewayhelper class methods 1035 numberofmessagessent description gets the number of messages sent by the gateway since it was started. Syntax integer = numberofmessagessent() see also getname , getnickname , getprotocolname , numberofmessagesreceived , setnickname , “using the gatewayhel...

  • Page 1036

    1036 chapter 6: coldfusion mx event gateway reference removebuddy description removes an id from a group in the buddy list for the gateway and tells the im server not to send the gateway messages with the buddy’s online presence state. Syntax boolean = removebuddy(name, group) see also addbuddy , ge...

  • Page 1037

    Im gateway gatewayhelper class methods 1037 removedeny description removes an id from a group in the deny list for the gateway. If the gateway’s permit mode is deny_some, the specified user can receive messages on the gateway’s presence state. Syntax boolean = removedeny(name, group) see also addden...

  • Page 1038

    1038 chapter 6: coldfusion mx event gateway reference removepermit description removes an id from a group in the permit list for the gateway. If the gateway’s permit mode is permit_some, the specified user cannot receive messages on the gateway's presence state. Syntax boolean = removepermit(name, g...

  • Page 1039

    Im gateway gatewayhelper class methods 1039 setnickname description sets the gateway’s nickname (display name). Syntax boolean = setnickname(name) see also getname , getnickname , getprotocolname , numberofmessagesreceived , numberofmessagessent , “using the gatewayhelper object” in chapter 43, “usi...

  • Page 1040

    1040 chapter 6: coldfusion mx event gateway reference setpermitmode description sets the gateway’s permit mode on the im server. The permit mode determines whether all users can get the gateway's online state information, or whether the server uses a permit list or a deny list to control which users...

  • Page 1041

    Im gateway gatewayhelper class methods 1041 setstatus description sets the online presence status of the gateway, including any custom away message. Syntax boolean = setstatus(status, customawaymsg) see also getcustomawaymessage , getstatusasstring , getstatustimestamp , isonline , “using the gatewa...

  • Page 1042

    1042 chapter 6: coldfusion mx event gateway reference sms gateway cfevent structure and commands this section describes the detailed contents of the following structures that you use in the sms gateway listener cfcs and cfml sendgatewaymessage functions: • sms gateway incoming message cfevent struct...

  • Page 1043

    Sms gateway incoming message cfevent structure 1043 sms gateway incoming message cfevent structure the sms gateway puts the following information in a cfevent instance that it sends to the cfc listener method: field value originatorid contents of the pdu source_addr field, the address of the device ...

  • Page 1044

    1044 chapter 6: coldfusion mx event gateway reference for more information on the meanings of some of these fields and how to handle incoming sms messages an sms gateway listener cfc method, see “handling incoming messages” in chapter 44, “using the sms event gateway” in coldfusion mx developer’s gu...

  • Page 1045

    Sms gateway message sending commands 1045 sms gateway message sending commands coldfusion applications that use gateways of the short message service (sms) type can send the following commands to the event gateway in an outgoing message: • submit command • submitmulti command • data command.

  • Page 1046

    1046 chapter 6: coldfusion mx event gateway reference submit command to send a message to a single destination address in an smpp submit_sm pdu, the structure that you used in the data parameter of a sendgatewaymessage function or the return variable of the cfc listener method has the following fiel...

  • Page 1047

    Sms gateway message sending commands 1047 example the following example onincomingmessage method of a listener cfc uses the submit command to echo incoming sms messages to the message originator:.

  • Page 1048

    1048 chapter 6: coldfusion mx event gateway reference submitmulti command to send a single text message to multiple recipients using an smpp submit_multi pdu, the data parameter of a sendgatewaymessage function or the return variable of the cfc listener method usually has the following fields. For m...

  • Page 1049

    Sms gateway message sending commands 1049 example the following example onincomingmessage method sends a response that echoes an incoming message to the originator address, and sends a copy of the response to a second address:.

  • Page 1050

    1050 chapter 6: coldfusion mx event gateway reference data command to send binary data to a single destination address in an smpp data_sm pdu, the data parameter of a sendgatewaymessage function or the return variable of the cfc listener method must have the following fields. For more information ab...

  • Page 1051

    Sms gateway message sending commands 1051 example the following example onincomingmessage method converts an incoming message to binary data, and sends the binary version of the message back to the originator address:.

  • Page 1052

    1052 chapter 6: coldfusion mx event gateway reference cfml event gateway sendgatewaymessage data parameter the coldfusion cfml gateway type enables you to invoke cfc methods asynchronously. The structure that you use in the sendgatewaymessage function data parameter can include two types of fields: ...

  • Page 1053

    Cfml event gateway sendgatewaymessage data parameter 1053 the cfc method uses the originatorid and the message, file, and type fields of the cfevent parameter’s data field to specify the log file and message. If (not isdefined("cfevent.Data.File")) { cfevent.Data.File="defaulteventlog"; } if (not is...

  • Page 1054

    1054 chapter 6: coldfusion mx event gateway reference.

  • Page 1055: Chapter 7

    1055 chapter 7 coldfusion c++ cfx reference this chapter describes the macromedia coldfusion mx 7 cfxapi classes and methods. Contents c++ class overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1055 deprecated class methods. . ....

  • Page 1056

    1056 chapter 7: coldfusion c++ cfx reference deprecated class methods the following cfxapi classes and methods are deprecated. They do not work, and might cause an error, in later releases. Ccfxexception class an abstract class that represents an exception thrown during processing of a coldfusion ex...

  • Page 1057

    Ccfxexception class 1057 ccfxexception::geterror description provides basic user output for exceptions that occur during processing. Ccfxexception::getdiagnostics description provides detailed user output for exception that occur during processing. Example this code block shows how geterror and getd...

  • Page 1058

    1058 chapter 7: coldfusion c++ cfx reference ccfxquery class an abstract class that represents a query used or created by a coldfusion extension (cfx). Queries contain one or more columns of data that extend over a varying number of rows. Class methods ccfxquery::addrow syntax int ccfxquery::addrow(...

  • Page 1059

    Ccfxquery class 1059 example the following example shows the addition of two rows to a three-column ('city', 'state', and 'zip') query: // first row int irow ; irow = pquery->addrow() ; pquery->setdata( irow, icity, "minneapolis" ) ; pquery->setdata( irow, istate, "mn" ) ; pquery->setdata( irow, izi...

  • Page 1060

    1060 chapter 7: coldfusion c++ cfx reference ccfxquery::getdata syntax lpcstr ccfxquery::getdata(int irow, int icolumn) description gets a data element from a row and column of a query. Row and column indexes begin with 1. You can determine the number of rows in a query by calling ccfxquery::getrowc...

  • Page 1061

    Ccfxquery class 1061 example the following example retrieves the name of a query and writes it back to the user: ccfxquery* pquery = prequest->getquery() ; prequest->write( "the query name is: " ) ; prequest->write( pquery->getname() ) ; ccfxquery::getrowcount syntax int ccfxquery::getrowcount(void)...

  • Page 1062

    1062 chapter 7: coldfusion c++ cfx reference example the following example shows the addition of two rows to a three-column ('city', 'state', and 'zip') query: // first row int irow ; irow = pquery->addrow() ; pquery->setdata( icity, irow, "minneapolis" ) ; pquery->setdata( istate, irow, "mn" ) ; pq...

  • Page 1063

    Ccfxrequest class 1063 ccfxrequest::addquery syntax ccfxquery* ccfxrequest::addquery(lpcstr lpszname, ccfxstringset* pcolumns) description adds a query to the calling template. The query can be accessed by cfml tags (for example, cfoutput or cftable ) within the template. After calling addquery , th...

  • Page 1064

    1064 chapter 7: coldfusion c++ cfx reference example the following example adds a query named 'people' to the calling template. The query has two columns ('firstname' and 'lastname') and two rows: // create a string set and add the column names to it ccfxstringset* pcolumns = prequest->createstrings...

  • Page 1065

    Ccfxrequest class 1065 ccfxrequest::createstringset syntax ccfxstringset* ccfxrequest::createstringset(void) description allocates and returns an instance. Always use this function to create string sets, as opposed to directly using the new operator. Returns returns an object of ccfxstringset class ...

  • Page 1066

    1066 chapter 7: coldfusion c++ cfx reference returns returns the value of the attribute passed to the tag. If no attribute of that name was passed to the tag, an empty string is returned. Parameters example the following example retrieves an attribute named destination and writes its value back to t...

  • Page 1067

    Ccfxrequest class 1067 ccfxrequest::getcustomdata syntax lpvoid ccfxrequest::getcustomdata(void) description gets the custom (tag specific) data for the request. This method is typically used from within subroutines of a tag implementation to extract tag data from a request. Returns returns a pointe...

  • Page 1068

    1068 chapter 7: coldfusion c++ cfx reference example the following example retrieves the query that was passed to the tag. If no query was passed, an exception is thrown: ccfxquery* pquery = prequest->getquery() ; if ( pquery == null ) { prequest->throwexception( "missing query parameter", "you must...

  • Page 1069

    Ccfxrequest class 1069 ccfxrequest::setcustomdata syntax void ccfxrequest::setcustomdata(lpvoid lpvdata) description sets custom (tag specific) data to carry with the request. Use this function to store request specific data to pass to procedures within your custom tag implementation. Parameters exa...

  • Page 1070

    1070 chapter 7: coldfusion c++ cfx reference example the following example sets the value of a variable named 'messagesent' based on the success of an operation performed by the custom tag: bool bmessagesent; ...Attempt to send the message... If ( bmessagesent == true ) { prequest->setvariable( "mes...

  • Page 1071

    Ccfxrequest class 1071 ccfxrequest::write syntax void ccfxrequest::write(lpcstr lpszoutput) description writes text output back to the user. Parameters example the following example creates a buffer to hold an output string, fills the buffer with data, and writes the output back to the user: char bu...

  • Page 1072

    1072 chapter 7: coldfusion c++ cfx reference ccfxstringset class abstract class that represents a set of ordered strings. Strings can be added to a set and can be retrieved by a numeric index (index values for strings are 1-based). To create a string set, use ccfxrequest::createstringset . Class met...

  • Page 1073

    Ccfxstringset class 1073 description gets the number of strings in a string set. The value can be used with ccfxstringset::getstring to iterate over the strings in the set (recall that the index values for strings in the list begin at 1). Returns returns the number of strings contained in the string...

  • Page 1074

    1074 chapter 7: coldfusion c++ cfx reference ccfxstringset::getstring syntax lpcstr ccfxstringset::getstring(int iindex) description retrieves the string located at the passed index (index values are 1-based). Returns returns the string located at the passed index. Parameters example the following e...

  • Page 1075: Chapter 8

    1075 chapter 8 coldfusion java cfx reference this chapter describes the java interfaces available for building macromedia coldfusion mx 7 custom cfxs in java. Contents class libraries overview. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10...

  • Page 1076

    1076 chapter 8: coldfusion java cfx reference custom tag interface public abstract interface customtag interface for implementing custom tags. Classes that implement this interface can be specified in the class attribute of the java cfx tag. For example, in a class mycustomtag, which implements this...

  • Page 1077

    Query interface 1077 parameters query interface public abstract interface query interface to a query used or created by a custom tag. A query contains tabular data organized by named columns and rows. Methods addrow description adds a row to a query. Call this method to append a row to a query. Retu...

  • Page 1078

    1078 chapter 8: coldfusion java cfx reference int icity = 1, istate = 2, izip = 3 ; // first row int irow = query.Addrow() ; query.Setdata( irow, icity, "minneapolis" ) ; query.Setdata( irow, istate, "mn" ) ; query.Setdata( irow, izip, "55345" ) ; // second row irow = query.Addrow() ; query.Setdata(...

  • Page 1079

    Query interface 1079 getcolumns description returns an array of strings containing the names of the columns in the query. Category query interface syntax public string[] getcolumns() example the following example retrieves the array of columns, then iterates over the list, writing each column name b...

  • Page 1080

    1080 chapter 8: coldfusion java cfx reference parameters example the following example iterates over the rows of a query and writes the data back to the user in a simple, space-delimited format: int irow, icol ; int nnumcols = query.Getcolumns().Length ; int nnumrows = query.Getrowcount() ; for ( ir...

  • Page 1081

    Query interface 1081 example the following example retrieves the number of rows in a query and writes it back to the user: query query = request.Getquery() ; int rows = query.Getrowcount() ; response.Write( "the number of rows in the query is " + integer.Tostring(rows) ) ; setdata description sets a...

  • Page 1082

    1082 chapter 8: coldfusion java cfx reference query.Setdata( irow, icity, "st. Paul" ) ; query.Setdata( irow, istate, "mn" ) ; query.Setdata( irow, izip, "55105" ) ; request interface public abstract interface request interface to a request made to a customtag. The interface includes methods for ret...

  • Page 1083

    Request interface 1083 example the following example checks whether the user passed an attribute named destination to the tag; if not, it throws an exception: if ( ! Request.Attributeexists("destination") ) { throw new exception( "missing destination parameter", "you must pass a destination paramete...

  • Page 1084

    1084 chapter 8: coldfusion java cfx reference syntax public string getattribute(string name) see also attributeexists , getattributelist , getintattribute , getattribute parameters example the following example retrieves an attribute named destination and writes its value back to the user: string st...

  • Page 1085

    Request interface 1085 getintattribute description retrieves the value of the passed attribute as an integer. Returns -1 if the attribute does not exist. Use attributeexists to test whether an attribute was passed to the tag. Use getintattribute(string,int) to return a default value rather than thro...

  • Page 1086

    1086 chapter 8: coldfusion java cfx reference syntax public query getquery() example the following example retrieves a query that was passed to a tag. If no query was passed, an exception is thrown: query query = request.Getquery() ; if ( query == null ) { throw new exception( "missing query paramet...

  • Page 1087

    Response interface 1087 response interface public abstract interface response interface to response generated from a custom tag. This interface includes methods for writing output, generating queries, and setting variables in the calling page. Methods addquery description adds a query to the calling...

  • Page 1088

    1088 chapter 8: coldfusion java cfx reference 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() ; query.Setdata( irow, ifirstname, "john" ) ; query.Setdata( irow...

  • Page 1089

    Response interface 1089 write description outputs text back to the user. Category response interface syntax public void write(string output) parameters example the following example outputs the value of the destination attribute: response.Write( "destination = " + request.Getattribute("destination")...

  • Page 1090

    1090 chapter 8: coldfusion java cfx reference debugging classes reference the constructors and methods supported by the debugrequest , debugresponse , and debugquery classes are as follows. These classes also support the other methods of the request , response , and query interfaces, respectively. D...

  • Page 1091: Chapter 9

    1091 chapter 9 wddx javascript objects this chapter provides information about javascript objects and functions used to wddx in a macromedia coldfusion mx 7 application. Contents javascript object overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 1092

    1092 chapter 9: wddx javascript objects wddxserializer object the wddxserializer object includes functions that serialize any javascript data structure. For more information on using this object, see “using wddx” in chapter 35, “using xml and wddx” in coldfusion mx developer’s guide. Functions the o...

  • Page 1093

    Wddxserializer object 1093 if (wddxpacket != null) { formfield.Value = wddxpacket; } else { alert("couldn't serialize data"); } } serializevariable description serializes a property of a structure. If an object is not a string, number, array, boolean, or date, wddxserializer treats it as a structure...

  • Page 1094

    1094 chapter 9: wddx javascript objects serializevalue description recursively serializes eligible data in a passed instance. Eligible data includes: • string • number • boolean • date • array • recordset • any javascript object this function serializes null values as empty strings. Syntax object.Se...

  • Page 1095

    Wddxrecordset object 1095 write description appends data to a serialized data stream. Syntax object.Write( str ) parameters return value returns an updated serialized data stream as a string. Usage this is an internal function; you do not typically call it. Example this example is from the wddxseria...

  • Page 1096

    1096 chapter 9: wddx javascript objects returns html table of the wddxrecordset object data. Usage convenient for debugging and testing record sets. The boolean parameter escapestrings determines whether & characters in string values are escaped as & in html. Example select message_id, thread_id, us...

  • Page 1097

    Wddxrecordset object 1097 usage adds a column to every row of the wddx record set. Initially the new column’s values are set to null. Example this example calls the addcolumn function: // create a new record set rs = new wddxrecordset(); // add a new column rs.Addcolumn("newcolumn"); // extend the r...

  • Page 1098

    1098 chapter 9: wddx javascript objects // extend the record set by 3 rows rs.Addrows(3); // set an element in the first row // newvalue is a previously defined variable rs.Setfield(0, "newcolumn", newvalue); getfield description returns the element in the specified row/column position. Syntax objec...

  • Page 1099

    Wddxrecordset object 1099 parameters return value integer. Returns the number of rows in the wddxrecordset instance. Usage call this function before a looping construct to determine the number of rows in a record set. Example this example calls the getrowcount function: function dumpwddxrecordset(r)...

  • Page 1100

    1100 chapter 9: wddx javascript objects // add a new column rs.Addcolumn("newcolumn"); // extend the record set by 3 rows rs.Addrows(3); // set an element in the first row // newvalue is a previously defined variable rs.Setfield(0, "newcolumn", newvalue); wddxserialize description serializes a recor...

  • Page 1101: Chapter 10

    1101 chapter 10 coldfusion actionscript functions this chapter explains the syntax and usage of the two macromedia coldfusion mx 7 server-side actionscript functions, cf.Query and cf.Http . Contents cf.Query . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ...

  • Page 1102

    1102 chapter 10: coldfusion actionscript functions cf.Query description performs queries against coldfusion data sources. Return value returns a recordset object. Syntax cf.Query ({ datasource:"data source name", sql:"sql stmts", username:"username", password:"password", maxrows:number, timeout:mill...

  • Page 1103

    Cf.Query 1103 you can manipulate the record set returned by the cf.Query function using methods in the recordset actionscript class. The following are some of the methods available in the recordset class: • recordset.Getcolumnnames • recordset.Getlength • recordset.Getitemat • recordset.Getitemid • ...

  • Page 1104

    1104 chapter 10: coldfusion actionscript functions cf.Http description executes http post and get operations on files. (post operations upload mime file types to a server, or post cookie, formfield, url, file, or cgi variables directly to a server.) return value returns an object containing properti...

  • Page 1105

    Cf.Http 1105 usage you can write the cf.Http function using named arguments or positional arguments. You can invoke all supported arguments using the named argument style, as follows: cf.Http({method:"method", url:"url", username:"username", password:"password", resolveurl:"yes or no", params:arrayv...

  • Page 1106

    1106 chapter 10: coldfusion actionscript functions cf.Http(method, url, username, password); cf.Http(method, url, params, username, password); note: do not use curly braces {} with positional arguments. The following parameters can only be passed as an array of objects in the params argument in the ...

  • Page 1107

    Cf.Http 1107 you access these attributes using the get function: function basicget() { url = "http://localhost:8100/"; // invoke with just the url. This is an http get. Result = cf.Http(url); return result.Get("filecontent"); } note: for more information on using server-side actionscript, see chapte...

  • Page 1108

    1108 chapter 10: coldfusion actionscript functions { url = "http://localhost:8100/"; // invoke with just the url. This is an http get. Result = cf.Http(url); return result.Get("filecontent"); } // example showing simple array created to pass params arguments function postwithparams() { // set up the...