background image

CFML Reference

Summary of Contents for COLDFUSION MX 61-CFML

Page 1: ...CFML Reference...

Page 2: ...dia Inc or other entities and may be registered in certain jurisdictions including internationally This product includes code licensed from RSA Data Security This guide contains links to third party w...

Page 3: ...tion and session variables 23 Custom tag variables 24 Request variable 24 Form variable 24 ColdFusion tag specific variables 24 ColdFusion query variables 25 CFCATCH variables 25 CFDIRECTORY variables...

Page 4: ...ol tags 40 Forms tags 40 Internet Protocol tags 41 Page processing tags 41 Variable manipulation tags 41 Other tags 41 Tag changes since ColdFusion 5 42 New tags attributes and values 42 Deprecated ta...

Page 5: ...nection File and directory operations 141 cfftp action listDir 145 cffunction 146 cfgraph 149 cfgraphdata 151 cfgrid 152 How data is returned from cfgrid 156 Using the href attribute 158 cfgridcolumn...

Page 6: ...foutput 263 cfparam 265 cfpop 267 cfprocessingdirective 271 cfprocparam 274 cfprocresult 278 cfproperty 280 cfquery 282 cfqueryparam 286 cfregistry 290 cfregistry action getAll 291 cfregistry action g...

Page 7: ...List functions 369 Mathematical functions 370 Other functions 370 Query functions 370 String functions 370 Structure functions 371 System functions 371 XML functions 371 Function changes since ColdFu...

Page 8: ...reateObject object types 423 CreateObject COM object 424 CreateObject component object 425 CreateObject CORBA object 426 CreateObject Java or EJB object 428 CreateObject web service object 429 CreateO...

Page 9: ...483 GetCurrentTemplatePath 484 GetDirectoryFromPath 485 GetEncoding 487 GetException 488 GetFileFromPath 489 GetFunctionList 490 GetHttpRequestData 491 GetHttpTimeString 493 GetK2ServerDocCount 494 G...

Page 10: ...540 IsObject 541 IsProtected 543 IsQuery 544 IsSimpleValue 545 IsStruct 546 IsUserInRole 548 IsWDDX 549 IsXmlDoc 551 IsXmlElem 552 IsXmlRoot 553 JavaCast 554 JSStringFormat 556 LCase 557 Left 558 Len...

Page 11: ...TimeFormat 621 LTrim 623 Max 624 Mid 625 Min 626 Minute 627 Month 628 MonthAsString 629 Now 630 NumberFormat 631 ParagraphFormat 634 ParameterExists 635 ParseDateTime 636 Pi 638 PreserveSingleQuotes 6...

Page 12: ...3 StructCount 697 StructDelete 698 StructFind 700 StructFindKey 701 StructFindValue 702 StructGet 703 StructInsert 705 StructIsEmpty 707 StructKeyArray 708 StructKeyExists 710 StructKeyList 711 Struct...

Page 13: ...GetRowCount 755 CCFXQuery SetData 756 CCFXRequest class 757 Class members 757 CCFXRequest AddQuery 758 CCFXRequest AttributeExists 759 CCFXRequest CreateStringSet 759 CCFXRequest Debug 760 CCFXRequest...

Page 14: ...778 getAttribute 778 getAttributeList 779 getIntAttribute 779 getQuery 780 getSetting 780 Response interface 782 Methods 782 addQuery 782 setVariable 783 write 784 writeDebug 784 Debugging classes ref...

Page 15: ...Contents 15 setField 796 wddxSerialize 797 CHAPTER 7 ColdFusion ActionScript Functions 799 CF query 800 CF http 801...

Page 16: ...16 Contents...

Page 17: ...ow to manage the ColdFusion environment including connecting to your data sources and configuring security for your applications Part II describes Verity search tools and utilities that you can use fo...

Page 18: ...ine 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...

Page 19: ...d Variables This chapter provides information on ColdFusion reserved words and lists scope variables Contents Reserved words 20 Scope specific built in variables 22 ColdFusion tag specific variables 2...

Page 20: ...l of the following are reserved words IS Is iS and is 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 us...

Page 21: ...O GOTO GRANT GROUP HAVING HOUR IDENTITY IMMEDIATE IN INDICATOR INITIALLY INNER INPUT INSENSITIVE INSERT INT INTEGER INTERSECT INTERVAL INTO IS ISOLATION JOIN KEY LANGUAGE LAST LEADING LEFT LEVEL LIKE...

Page 22: ...les TIME TIMESTAMP TIMEZONE_ HOUR TIMEZONE_ MINUTE TO TRAILING TRANSACTION TRANSLATE TRANSLATION TRIM TRUE UNION UNIQUE UNKNOWN UPDATE UPPER USAGE USER USING VALUE VALUES VARCHAR VARYING VIEW WHEN WHE...

Page 23: ...orts the Variables scope Unscoped variables created with the cfset tag acquire the Variables scope by default For example the variable created by the statement CFSET linguist Chomsky can be referenced...

Page 24: ...Request variables store data about the processing of one page request Request variables store data in a structure that can be passed to nested tags such as custom tags and processed once To provide i...

Page 25: ...CFCATCH Detail CFCATCH ErrNumber CFCATCH NativeErrorCode CFCATCH SQLState CFCATCH LockName CFCATCH LockOperation CFCATCH MissingFileName CFCATCH TagContext CFCATCH ErrorCode CFCATCH ExtendedInfo CFDIR...

Page 26: ...FERROR Diagnostics CFERROR Mailto or CFERROR DateTime CFFILE ACTION Upload variables File variables are read only Use the CFFILE prefix to reference file variables for example CFFILE ClientDirectory T...

Page 27: ...th row 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 conten...

Page 28: ...e 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 ex...

Page 29: ...CEPT CGI HTTP_IF_MODIFIED_SINCE CGI HTTP_USER_AGENT The CERT_ISSUER CERT_SUBJECT CLIENT_CERT_ENCODED variables are available only when you use client certificates CGI environment variables When a brow...

Page 30: ...the information protocol this request came in with Format protocol revision SERVER_PORT Port number to which the request was sent REQUEST_METHOD Method with which the request was made For HTTP this i...

Page 31: ...mat software version library version HTTP_IF_MODIFIED_SINCE The last time the page was modified The browser determines whether to set this variable usually in response to the server having sent the LA...

Page 32: ...32 Chapter 1 Reserved Words and Variables...

Page 33: ...interact with data sources manipulate data and display output CFML tag syntax is similar to HTML element syntax This chapter contains categorized and alphabetical lists of the tags followed by the det...

Page 34: ...ches exceptions in ColdFusion pages cfchart Data output tags Generates and displays a chart cfchartdata Data output tags Defines chart data points cfchartseries Data output tags Defines style in which...

Page 35: ...a grid row used with cfgrid cfgridupdate Forms tags Directly updates ODBC data source from edited grid data cfheader Data output tags Page processing tags Generates HTTP headers cfhtmlhead Forms tags...

Page 36: ...ternet Protocol tags Attaches a file or adds a header to an e mail message cfmailpart Forms tags Internet Protocol tags Contains one part of a multi part mail message cfmodule Application framework ta...

Page 37: ...Forms tags Creates a drop down list box form element used in cfform tag cfset Variable manipulation tags Defines a variable cfsetting Other tags Variable manipulation tags Defines and controls ColdFu...

Page 38: ...dling tags Flow control tags Catches exceptions in ColdFusion pages cfupdate Database manipulation tags Updates rows in a database data source cfwddx Extensibility tags Serializes and de serializes CF...

Page 39: ...ags 40 Internet Protocol tags 41 Page processing tags 41 Variable manipulation tags 41 Other tags 41 Application framework tags Database manipulation tags Data output tags Debugging tags cfapplication...

Page 40: ...rt cfcollection cfinvokeargument cfreturn cfcomponent cflogin cfsearch cfexecute cfloginuser cfwddx cfftp cflogout cfxml cfdirectory cffile cfftp cfabort cfexecute cfrethrow cfbreak cfexit cfswitch cf...

Page 41: ...ble manipulation tags Other tags cfftp cfldap cfmailpart cfhttp cfmail cfpop cfhttpparam cfmailparam cfcache cfheader cfsetting cfcontent cfhtmlhead cfsilent cfflush cfinclude cfcookie cfregistry cfse...

Page 42: ...MX cfcache timespan attribute ColdFusion MX cachedirectory attribute ColdFusion MX cfchart All ColdFusion MX cfchartdata All ColdFusion MX cfchartseries All ColdFusion MX cfcollection list value of ac...

Page 43: ...userName attribute ColdFusion MX 6 1 password attribute ColdFusion MX 6 1 wrapText attribute ColdFusion MX 6 1 cfmailparam type attribute ColdFusion MX 6 1 cfmailpart All ColdFusion MX 6 1 cfobject Al...

Page 44: ...raph All ColdFusion MX cfgraphdata All ColdFusion MX cfgridupdate connectString attribute ColdFusion MX dbName attribute ColdFusion MX dbServer attribute ColdFusion MX dbType attribute ColdFusion MX p...

Page 45: ...rnal attribute ColdFusion MX cfservlet All ColdFusion MX cfservletparam All ColdFusion MX cfslider img attribute ColdFusion MX imgStyle attribute ColdFusion MX grooveColor attribute ColdFusion MX cfst...

Page 46: ...r than ColdFusion 5 Tag Attribute or value Obsolete as of this ColdFusion release cfauthenticate All ColdFusion MX cfimpersonate All ColdFusion MX cfindex action attribute value optimize ColdFusion MX...

Page 47: ...g with the showError attribute but do not define an error page using cferror page processing stops when the cfabort tag is reached The message in showError displays to the client When you use this tag...

Page 48: ...value cfloop from 1 to 4 index Counter on the second time through the loop cfabort cfif Counter is 2 cfabort processing is stopped and subsequent operations are not carried out cfelse cfset myVariabl...

Page 49: ...ported message_to_display_for_nonJava_browser param_1 applet_parameter_name param_2 applet_parameter_name param_n applet_parameter_name See also cfform cfobject cfservlet History ColdFusion MX Removed...

Page 50: ...tensions section p This example applet copies text that you type into a form Type some text and then click copy to see the copied text cfform action index cfm cfapplet appletsource copytext name copyt...

Page 51: ...vailable Server Session and Application scope variables are stored in memory as structures In earlier releases only Session and Application scope variables were stored this way You cannot access the U...

Page 52: ...datasource_name in ODBC or native data source You must create storage repository in the Administrator registry in the system registry cookie on client computer in a cookie Scalable If client disables...

Page 53: ...ionvariables This tag is placed in a special file calledApplication cfm that is run before any other CF page in a directory where the Application cfm file appears cfapplication name ETurtle sessionTim...

Page 54: ...e data type of the argument any array binary boolean date guid The argument must be a UUID or GUID of the form xxxxxxxx xxxx xxxx xxxx xxxxxxxxxxxx where each x is a character representing a hexadecim...

Page 55: ...description from the database cfquery name Description datasource cfsnippets SELECT Descript FROM Courses WHERE Number Course_Number cfquery Specify the variable that the function returns cfreturn Des...

Page 56: ...is appended to an array whose name is thistag collectionName Within the custom tag code the attributes passed to the tag by using the attributeCollection attribute are saved as independent values wit...

Page 57: ...s obsolete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX this tag is obsolet...

Page 58: ...a query to find a value In our example a list of values corresponding to courses in the Snippets datasource When the conditions of the query are met CFBREAK stops the loop p Please enter a Course Numb...

Page 59: ...and cachedirectory attributes They might not work and might cause an error in later releases Added the timespan attribute Changed how pages are cached the default action attribute value cache caches...

Page 60: ...on servercache server side caching only Not recommended optimal same as cache directory Optional cf_root cache Absolute path of cache directory timespan Optional Page is flushed only whencfcache actio...

Page 61: ...rsonalized copy of a page for other users Debug settings have no effect on cfcache unless the application page enables debugging When generating a cached file cfcache uses cfsetting showDebugOutput No...

Page 62: ...he following line matches red blue or green cfcase value red blue green You can use the delimiter attribute to specify one or more delimiters to use in place of the comma For example the following lin...

Page 63: ...lue 9 8 delimiters cfset grade B cfcase cfcase value 7 6 delimiters cfset grade C cfcase cfcase value 5 4 delimiters cfset grade D cfcase cfdefaultcase cfset grade F cfdefaultcase cfswitch cfoutput Yo...

Page 64: ...value is the same as in ColdFusion 5 Type 4 100 Java no native methods the value might be different If your application depends on SQLSTATE values for flow control the application might produce unexpe...

Page 65: ...example you could define a type as follows cfthrow type MyApp BusinessRuleException InvalidAccount If you have the following cfcatch tag it will handle the exception cfcatch type MyApp BusinessRuleExc...

Page 66: ...type database Native error code associated with exception Database drivers typically provide error codes to diagnose failing database operations Default 1 cfcatch SQLState Applies to type database SQL...

Page 67: ...Allaire ColdFusion HTTPContinue COM Allaire ColdFusion HTTPCookieValueNotPassed COM Allaire ColdFusion HTTPCreated COM Allaire ColdFusion HTTPFailure COM Allaire ColdFusion HTTPFileInvalidPath COM Al...

Page 68: ...ColdFusion HTTPPaymentRequired COM Allaire ColdFusion HTTPPreconditionFailed COM Allaire ColdFusion HTTPProxyAuthenticationRequired COM Allaire ColdFusion HTTPRequestURITooLarge COM Allaire ColdFusion...

Page 69: ...contents of the tag stack are p cfloop index i from 1 to ArrayLen CFCATCH TAGCONTEXT cfset sCurrent CFCATCH TAGCONTEXT i br i sCurrent ID sCurrent LINE sCurrent COLUMN sCurrent TEMPLATE cfloop cfoutp...

Page 70: ...font size fontBold yes or no fontItalic yes or no labelFormat number currency percent date xAxisTitle title text yAxisTitle title text xAxisType scale or category yAxisType scale or category sortXAxi...

Page 71: ...lies to charts that have more than one data series Relative positions of series default ColdFusion determines relative positions based on graph types cluster stacked percent foregroundColor black Colo...

Page 72: ...and scale sortXAxis no yes display column labels in alphabetic order along X axis no Ignored if xAxisType attribute is scale show3D no yes display chart with three dimensional appearance no xOffset 0...

Page 73: ...s or none showMarkers yes Applies to chartseries type attribute values line curve and scatter yes display markers at data points no markerSize Automatic Size of data point marker in pixels Integer pie...

Page 74: ...following W3C HTML 4 named color value or hex values For all other color values you must enter the hex value For more color names that are supported by popular browsers see www w3 org TR css3 color Fl...

Page 75: ...s data is submitted to the cfchartseries tag Category Data output tags Extensibility tags Syntax cfchartdata item text value number See also cfchart cfchartseries History ColdFusion MX Added this tag...

Page 76: ...ColdFusion MX 6 1 Changed interpolation behavior the tag now interpolates data points on line charts with multiple series ColdFusion MX Added this tag Attributes Attribute Req Opt Default Description...

Page 77: ...fchart tag seriesLabel Optional Text of data series label seriesColor Optional Color of the main element such as the bars of a chart For a pie chart the color of the first slice Hex value or supported...

Page 78: ...ay No error is thrown Example This example shows the use of cfcol and cftable to align information returned from a query query selects information from cfsnippets data source cfquery name GetEmployees...

Page 79: ...tEmployees startRow 1 colSpacing 3 HTMLTable colheaders each cfcol tag sets the width of a column in the table the header information and the text CFML for the cell cfcol header b ID b align Left widt...

Page 80: ...ol such as Vspider or MKVDK Category Extensibility tags Syntax cfcollection action action collection collection_name path path_to_verity_collection language language name queryname See also cfexecute...

Page 81: ...ete collection directories map creates a map to the collection It is not necessary to specify this value ColdFusion maps collections automatically optimize optimizes the structure and contents of the...

Page 82: ...rs use code such as the following cfcollection action list name myCollections cfoutput query myCollections name br cfoutput To add content to a collection use cfindex To search a collection use cfsear...

Page 83: ...se cfset collpath opt coldfusionmx verity collections cfif Process form input and do the requested cfcollection operation cfif IsDefined form CollectionName AND IsDefined form CollectionAction cfif fo...

Page 84: ...f cfif Form to specify the collection name and action form action CGI SCRIPT_NAME method POST select name CollectionAction option value Create Create this collection option value Optimize Optimize thi...

Page 85: ...A component method is invoked in the following ways Within the cfinvoke tag in a ColdFusion page Within a URL that calls a CFC file and passes a method name as a URL parameter Within the cfscript tag...

Page 86: ...al Name of parent component from which to inherit methods and properties output Optional Component body displayable text is processed as standard CFML Specifies whether constructor code in the compone...

Page 87: ...ge output Note This tag executes only if it is enabled in the ColdFusion Administrator For more information see Configuring and Administering ColdFusion MX Category Data output tags Syntax cfcontent t...

Page 88: ...16 For example type text html type text html charset ISO 8859 1 deleteFile Optional No Applies only if you specify a file with the file attribute Yes deletes the file on the server after sending its c...

Page 89: ...in the browser the browser displays the file without asking users whether to save it if you use a cfheader tag similar to the following cfheader name Content Disposition value filename filename ext F...

Page 90: ...mple 2 h3 p This example shows how reset attribute changes output for text p p reset Yes 123 cfcontent type text html reset Yes 456 p p This example shows how reset attribute changes output for text p...

Page 91: ...can include any printable ASCII characters except commas semicolons or white space characters value Optional Value to assign to cookie variable Must be a string or variable that can be stored as a str...

Page 92: ...de use the following line cfoutput cookie person name cfoutput Example This example shows how to set delete a cfcookie variable Select users who have entered comments into sample database cfquery name...

Page 93: ...e LastAOLVisitor value Email expires NOW cfif cfloop If the timeVisited cookie is not set set a value cfif IsDefined Cookie TimeVisited is False cfcookie name TimeVisited value Now expires 10 cfif cfi...

Page 94: ...ntents of the cfdefaultcase tag body can include HTML and text and CFML tags functions variables and expressions You can specify only one cfdefaultcase tag within a cfswitch tag You can put the cfdefa...

Page 95: ...irectory action list no longer returns the values of the Archive and System attributes On UNIX and Linux cfdirectory action list does not return any information in the mode column Attributes Attribute...

Page 96: ...pplicable mode Empty column retained for backward compatibility with ColdFusion 5 applications on UNIX You can use the following result columns in standard CFML expressions preceding the result column...

Page 97: ...e case sensitive The following 2 characters have special meaning in the pattern and are called metacharacters matches any zero or more characters matches any single character The following table shows...

Page 98: ...rmation for the object Attributes 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 us...

Page 99: ...le cell is empty this tag displays empty string Example This example shows how to use this tag to display a URL variable URL variables contain parameters that are passed in a URL string in a page requ...

Page 100: ...ression HTML and CFML tags cfelse HTML and CFML tags cfif See also cfif cfelseif cfabort cfbreak cfexecute cfexit cflocation cfloop cfswitch cfthrow cftry Usage If the values of the expressions in the...

Page 101: ...e cfexit cflocation cfloop cfswitch cfthrow cftry Usage If the value of the expression in this tag is true and the values of the expressions in the containing cfif tag and preceding cfelseif tags are...

Page 102: ...custom error page in Developing ColdFusion MX Applications exception a exception of the type specified by the exception attribute validation errors recognized by sever side type validation request an...

Page 103: ...xception condition Uses the full range of CFML tags Error variables must be in cfoutput tags Can handle specific exception types or display general information for exceptions Request Includes the erro...

Page 104: ...template request_err cfm mailTo admin mywebsite com Example of the page to handle this error html head title We re sorry An Error Occurred title head body Request and Exception error diagnostics Detai...

Page 105: ...please contact error mailTo with the following information p p ul li b Your Location b error remoteAddress li b Your Browser b error browser li b Date and Time the Error Occurred b error dateTime li b...

Page 106: ...an extension for example C myapp exe arguments Optional Command line variables passed to application If specified as string it is processed as follows Windows passed to process control subsystem for p...

Page 107: ...s output in a file cfexecute name C WinNT System32 netstat exe arguments e outputFile C Temp output txt timeout 1 cfexecute variable Optional Variable in which to put program output If no outputfile o...

Page 108: ...on its location and execution mode Example h3 cfexit Example h3 p cfexit can be used to abort the processing of the currently executing CFML custom tag Execution resumes following the invocation of t...

Page 109: ...the expected attribute variables is not present an error message is generated and cfexit returns control to the calling page cfif NOT IsDefined attributes myValue2 cfset caller result Value2 is not de...

Page 110: ...g syntax depends on the action attribute value See the following sections See also cfdirectory History ColdFusion MX 6 1 Changed file path requirements if you do not specify an absolute file path the...

Page 111: ...ew file cffile action Write file GetTempDirectory foobar txt output form the_text cfif cfif form action is read read existing file cffile action Read file GetTempDirectory foobar txt variable readText...

Page 112: ...s depending on whether the file exists select name action cfif fileExists is no option value new Make new file cfif cfif fileExists is yes option value add Add to existing file option value delete Del...

Page 113: ...file to which to append content of output attribute If not an absolute path starting a with a drive letter and a colon or a forward or backward slash it is relative to the ColdFusion temporary directo...

Page 114: ...maintained Each value must be specified explicitly For example if you specify attributes readOnly all other attributes are overwritten readOnly hidden normal charset Optional JVM default file charact...

Page 115: ...nd a colon or a forward or backward slash it is relative to the ColdFusion temporary directory which is returned by the GetTempDirectory function destination Required Pathname of a directory or file o...

Page 116: ...d file cffile action delete file c files upload Variables DeleteFileName Attribute Req Opt Default Description action Required Type of file manipulation that the tag performs file Required Pathname of...

Page 117: ...ired Pathname of the file to move If not an absolute path starting a with a drive letter and a colon or a forward or backward slash it is relative to the ColdFusion temporary directory which is return...

Page 118: ...he file If omitted the file s attributes are maintained Each value must be specified explicitly For example if you specify attributes readOnly all other attributes are overwritten readOnly hidden norm...

Page 119: ...Type of file manipulation that the tag performs file Required Pathname of the file to read If not an absolute path starting a with a drive letter and a colon or a forward or backward slash it is relat...

Page 120: ...ulating the contents of text files You can also use the variable that is created by a cffile action read operation in the ArrayToList and ListToArray functions Note If you use this tag to read a file...

Page 121: ...ame variable var_name See also cfdirectory Attributes Usage You convert the binary file to Base64 to transfer it to another site Example The following example creates a variable named aBinaryObj to co...

Page 122: ...ed Pathname of file to rename If not an absolute path starting a with a drive letter and a colon or a forward or backward slash it is relative to the ColdFusion temporary directory which is returned b...

Page 123: ...cffile 123 cffile action rename source c files memo keymemo doc destination c files memo oldmemo doc...

Page 124: ...to upload the file If not an absolute path starting a with a drive letter and a colon or a forward or backward slash it is relative to the ColdFusion temporary directory which is returned by the GetT...

Page 125: ...s 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 readO...

Page 126: ...file tmp foo mode 644 output some text This example appends to a file and sets permissions to read write rw for all cffile action append destination home tomj testing txt mode 666 output Is this a tes...

Page 127: ...e manipulation that the tag performs file Required Pathname of the file to write If not an absolute path starting a with a drive letter and a colon or a forward or backward slash it is relative to the...

Page 128: ...eates the file tmp foo with permissions rw r r owner read write group read other read cffile action write file tmp foo mode 644 This example appends to the file and sets permissions to read write rw f...

Page 129: ...stination home tomj testing txt mode 666 output Is this a test This example uploads a file and gives it the permissions owner group other read write execute cffile action upload fileField fieldname de...

Page 130: ...cfcontent cfcookie cfform cfheader cfhtmlhead cflocation and SetLocale These tags and functions normally modify the HTML header but cannot do so after a cfflush tag because the cfflush sends the head...

Page 131: ...you will agree it was worth the short wait H2 cfflush cfflush interval 10 Delay Loop to make it seem harder cfloop index randomindex from 1 to 200000 step 1 cfset random rand cfloop Now slowly output...

Page 132: ...es cfform See also cfapplet cfgrid cfinput cfselect cfslider cftextinput cftree cftreeitem History ColdFusion MX Deprecated the enableCAB attribute It might not work and might cause an error in later...

Page 133: ...page 312 cftree controls Overrides the cftreeitem expand attribute If true expands previously selected elements The cftree completePath attribute must be set to Yes cfgrid controls has no effect This...

Page 134: ...ignored If you specify a value in quotation marks you must escape them by doubling them for example passThrough readonly Yes Any form field name from the cfform tag or an HTML form that ends in one of...

Page 135: ...is True AND form textSample is not h3 Results of Credit Card Input h3 Your credit card number cfoutput form textSample cfoutput was valid under the MOD 10 algorithm cfif cfif IsDefined form sampleSlid...

Page 136: ...example from 1 to 10 by sliding control p 1 cfslider name sampleSlider label Sample Slider range 1 10 message Please enter a value from 1 to 10 scale 1 bold No italic No refreshlabel No 10 td tr tabl...

Page 137: ...ot work and might cause an error in later releases Usage Use this tag to move files between a ColdFusion server and an FTP server This tag does not move files between a ColdFusion server and a client...

Page 138: ...ed if action open User name to pass in the FTP operation password Required if action open Password to log in the user server Required if action open FTP server to which to connect for example ftp myse...

Page 139: ...to Session or Application variable the connection remains open for the current page only and you do not have to close it manually Changes to a cached connection such as changing retryCount or timeout...

Page 140: ...topOnError Yes name ListFiles directory connection my_query cfoutput query ListFiles name br cfoutput p Close the connection cfftp action close connection My_query stopOnError Yes p Did it succeed cfo...

Page 141: ...me new file or directory name proxyServer proxy server passive Yes or No See also cfhttp cfldap cfmail cfpop Attributes Attribute Req Opt Default Description action Required if connection is not cache...

Page 142: ...auto transferMode Optional Auto ASCII FTP transfer mode Binary FTP transfer mode Auto FTP transfer mode failIfExists Optional Yes Yes if a local file with same name exists getFile fails No directory R...

Page 143: ...myConnection username myUserName password myUserName allaire com server ftp allaire com action open stopOnError Yes p Did it succeed cfoutput cfftp succeeded cfoutput cfftp connection myConnection act...

Page 144: ...144 Chapter 2 ColdFusion Tags action close stopOnError Yes p Did it succeed cfoutput cfftp succeeded cfoutput...

Page 145: ...he row number of each file directory entry returned by the listDir operation A separate row is created for each entry Note Previously supported query column values that pertain to system specific info...

Page 146: ...rwise any String a type name data type of the function return value any array binary boolean date guid The argument must be a UUID or GUID of the form xxxxxxxx xxxx xxxx xxxx xxxxxxxxxxxx where each x...

Page 147: ...ge public available to a locally executing page or component method remote available to a locally or remotely executing page or component method or a remote client through a URL Flash or a web service...

Page 148: ...for the returnType attribute the function must return a string that is in ColdFusion variable name format that is the function must return a string that starts with a letter underscore or Unicode curr...

Page 149: ...Sets item label text font If the Valuelabelfont Itemlabelfont and Legendfont values differ ColdFusion uses the last value that you specify in the tag Arial is not supported it is mapped to Dialog Leg...

Page 150: ...slabel selected series row value or an empty string javascript executes client side scripts Urlcolumn Ignored This attribute generates a graph but the url link is missing data that the linked page may...

Page 151: ...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 i...

Page 152: ...Yes or No bold Yes or No textColor web color href URL hrefKey column_name target URL_target appendKey Yes or No highlightHref Yes or No onValidate javascript_function onError text gridDataAlign positi...

Page 153: ...mn widths so that all columns display within grid width No sets columns to equal widths User can resize columns Horizontal scroll bars are not available because if you specify a column width and set a...

Page 154: ...onal URL o r query column name that contains a URL to hyperlink each grid cell with hrefKey Optional The query column to use for the value appended to the href URL of each cell instead of the cell s v...

Page 155: ...derTextColor Optional Black Text color of grid control row headers Options same as for textColor attribute colHeaders Optional see description Yes Yes displays column headers in grid control No colHea...

Page 156: ...a returned falls into one of these categories Simple data returned from simple select operations Complex data returned from insert update and delete operations selectMode Optional Browse Selection mod...

Page 157: ...ather the data from the form variables the tag collects data writes SQL calls and updates the data source If you cannot use cfgridupdate if for example you must distribute the returned data to more th...

Page 158: ...appended to the URL The value of selection is determined by the value of the selectMode attribute If selectMode Single selection is the value of the column clicked If selectMode Row selection is a de...

Page 159: ...rowHeaderBold No colHeaders Yes colHeaderAlign LEFT colHeaderItalic No colHeaderBold No selectColor Red selectMode EDIT pictureBar No insertButton To insert deleteButton To delete sortAscendingButton...

Page 160: ...160 Chapter 2 ColdFusion Tags html...

Page 161: ...aderTextColor web color dataAlign position headerAlign position numberFormat format values Comma separated strings and or numeric range valuesDisplay Comma separated strings and or numeric range value...

Page 162: ...e textColor C2 LT 0 red pink This means If value in Column 2 is less than 0 display value in red otherwise display value in pink See Using expressions in textColor and bgColor attributes on page 164 A...

Page 163: ...lays as check box if cell is editable user can change checkmark string_noCase user can sort grid data as case insensitive text headerFont Optional as specified by cfgrid Column header font headerFontS...

Page 164: ...condition Value for textColor if condition evaluates to false If the string in the expression can be interpreted as a number the comparisons in the expression are interpreted as numeric Otherwise the...

Page 165: ...placeholder Period Location of mandatory decimal point 0 Located to left or right of mandatory decimal point pads with zeros Puts parentheses around mask if number is less than 0 Puts plus sign befor...

Page 166: ...mn NAME City header City cfgridcolumn NAME Country header Country cfloop index Counter from 1 to ListLen MyList1 cfgridrow data ListGetAt MyList1 Counter ListGetAt MyList2 Counter cfloop cfgrid cfform...

Page 167: ...olor red selectmode edit picturebar no insertbutton to insert deletebutton to delete sortascendingbutton sort asc sortdescendingbutton sort desc cfgridcolumn name Dept_ID header Department headeralign...

Page 168: ...lumn name Dept_ID header Department headeralign left dataalign left bold yes italic no select yes display yes headerbold no headeritalic yes cfgridcolumn name CorNumber header Course headeralign left...

Page 169: ...et cfform cfinput cfselect cfslider cftextinput cftree History ColdFusion MX Deprecated the connectString dbName dbServer dbtype provider and providerDSN attributes They do not work and might cause an...

Page 170: ...ined form gridEntered is True cfgridupdate grid FirstGrid dataSource cfsnippets tableName CourseList keyOnly Yes cfif tableQualifier Optional Table qualifier if supported Purpose SQL Server and Oracle...

Page 171: ...Content Disposition uses the default file character encoding to encode this header s value so the name of a file can include characters in the character encoding used in the file Attributes Attribute...

Page 172: ...ple h3 p cfheader generates custom HTTP response headers to return to the client p This example forces browser client to purge its cache of requested file cfheader name Expires value Now statusCode Re...

Page 173: ...page an error is thrown Example body This example shows the use of cfhtmlhead cfhtmlhead text meta name Description content This is an example of a generated header p cfhtmlhead writes the text speci...

Page 174: ...me name queryname columns query_columns firstrowasheaders yes or no delimiter character textQualifier character cfhttpparam tags optional for some methods cfhttp See also cfhttpparam GetHttpRequestDat...

Page 175: ...nformation to the server for processing Requires one or more cfhttpparam tags Often used for submitting form like data PUT Requests the server to store the message body at the specified URL Use this m...

Page 176: ...luding the URL query string and form or file data and the response The following list includes commonly used values utf 8 iso 8859 1 windows 1252 us ascii shift_jis iso 2022 jp euc jp euc kr big5 euc...

Page 177: ...ter for example RequestTime 120 ColdFusion uses the lesser of the URL timeout and the timeout attribute value this ensures that the request times out before or at the same time as the page If the URL...

Page 178: ...ldFusion uses the multipart form data content type for all parts If Yes ColdFusion also sends the request s charset in each Content Type description All form field data must be encoded in this charact...

Page 179: ...attribute and the firstrowasHeader attribute is true the default the column names specified by this attribute replace the first line of the response You can use this behavior to replace the column nam...

Page 180: ...r encoding specified by the response Content Type header cfhttp errorDetail If the connection to the HTTP server fails contains details about the failure For instance Unknown host my co com otherwise...

Page 181: ...attribute and set firstrowasheaders No ColdFusion generates column names of the form Column_1 Column2 etc The cfhttp tag checks to ensure that column names in the data returned by the tag start with a...

Page 182: ...ddress method GET resolveurl Yes throwOnError Yes Parse the xml and output a list of resources cfset xmlDoc XmlParse CFHTTP FileContent Get the array of resource elements the xmlChildren of the xmlroo...

Page 183: ...pparam type transaction type name data name value data value file filename encoded Yes or No mimeType MIME type designator See also cfhttp GetHttpRequestData cfftp cfldap cfmail cfmailparam cfpop Hist...

Page 184: ...o append to the cfhttp url attribute ColdFusion URL encodes the query string FormField Specifies a form field to send ColdFusion URL encodes the Form field by default Cookie Specifies a cookie to send...

Page 185: ...ldnames key list depends on the position of the cfhttpparam tag with the file relative to the cfhttp tags with the form data URL encoding preserves special characters such as the ampersand when they a...

Page 186: ...186 Chapter 2 ColdFusion Tags br CGI variable CGI cgi_test br br Note that the CGI variable is URL encoded cfoutput...

Page 187: ...s a Boolean you do not have to define the True condition explicitly This example uses the IsArray function cfif IsArray myarray If successful IsArray evaluates to Yes the string equivalent of the Bool...

Page 188: ...fif Trim City is San Diego OR Trim City is Santa Ana h4 Featured Center in cfif Trim City is San Diego San Diego cfelse Santa Ana cfif h4 b Name Address b Name Address1 City State br b Contact b Conta...

Page 189: ...s obsolete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX This tag is obsolet...

Page 190: ...edence Attribute Req Opt Default Description taglib Required Tag library URI The path must be relative to the web root and start with the current page location or a directory specified in the Administ...

Page 191: ...must be on the page that uses the imported tags For example if you use a cfimport tag on a page that you include with the cfinclude call you cannot use the imported tags on the page that has the cfinc...

Page 192: ...page 2 In directories mapped in the ColdFusion Administrator for the included file The included file must be a syntactically correct and complete CFML page For example to output data from within the...

Page 193: ...1 custom_value custom2 custom_value URLpath URL extensions file_extensions query query_name recurse Yes or No language language See also cfcollection cfexecute cfobject cfreport cfsearch cfwddx Histor...

Page 194: ...y name Permits searching collections by title or displaying a separate title from the key key Depends on action attributevalue see Usage section empty string Absolute path and filename if type file Ab...

Page 195: ...ppropriate European or Asian Verity Locales language pack Specifying this attribute is required optional or unnecessary blank For this action attribute value purge delete update or refresh collection...

Page 196: ...2 custom2 for ACTION UPDATE 2 TYPE FILE key is a query result set column cfquery name bookquery datasource book select from book where bookid file cfquery cfoutput query bookquery url description br c...

Page 197: ...n snippets action update type path key c inetpub wwwroot cfdocs snippets urlpath http localhost cfdocs snippets custom1 custom1 custom2 custom2 recurse no extensions for ACTION UPDATE 6 TYPE PATH wher...

Page 198: ...root cfdocs snippets urlpath http localhost cfdocs snippets custom1 custom1 custom2 custom2 recurse yes extensions htm html cfm cfml cflock ACTION REFRESH 3 TYPE CUSTOM cfquery name book datasource bo...

Page 199: ...m recurse no cflock ACTION DELETE 4 TYPE PATH key is a query result set column cflock name verity timeout 60 cfquery name bookquery datasource book select from book where bookid path1 cfquery cfoutput...

Page 200: ...200 Chapter 2 ColdFusion Tags for ACTION PURGE cflock name verity timeout 60 cfindex action purge collection snippets cflock...

Page 201: ...ext entry have 13 16 digits ColdFusion MX Changed the cfform tag preserveData attribute behavior if it is set to True ColdFusion checks radio and check box values only if their value matches the poste...

Page 202: ...ucceeds and False otherwise If used the validate attribute is ignored pattern Required if validate regular_ expression JavaScript regular expression pattern to validate input Omit leading and trailing...

Page 203: ...or information on using JavaScript regular expressions with this tag see Chapter 27 Building Dynamic Forms in Developing ColdFusion MX Applications Example this example shows the use of cfinput within...

Page 204: ...204 Chapter 2 ColdFusion Tags message Enter a correctly formatted date dd mm yy validate date required No input type Submit name value send my information cfform...

Page 205: ...se sensitive Must be the same case used when table was created tableOwner Optional For data sources that support table ownership such as SQL Server Oracle and Sybase SQL Anywhere use this field to spe...

Page 206: ...fquery name GetComments dataSource cfsnippets SELECT CommentID EMail FromUser Subject CommtType MessText Posted Processed FROM Comments cfquery html head head h3 cfinsert Example h3 p First show a lis...

Page 207: ...cfinsert 207 input type hidden name posted value cfoutput Now cfoutput pre input type Submit name value insert my comment form...

Page 208: ...ribute Category Extensibility tags Syntax Syntax 1 this syntax invokes a method of a component cfinvoke component component name or reference method method name returnVariable variable name argumentCo...

Page 209: ...ntax shows instantiation with the cfobject tag This cfinvoke syntax applies to instantiating a web service with the cfobject tag and to instantiating a web service with the createobject function cfobj...

Page 210: ...nistrator Web Services webservice Required The URL of the WSDL file for the web service timeout Optional The timeout for the web service request in seconds proxyServer Optional http proxyHost system p...

Page 211: ...n attribute For example the params struct contains three keys a 1 b 1 c 1 The following call is evaluated as if the arguments were passed to the method in the order a 3 b 2 c 1 cfinvoke a 2 b 2 argume...

Page 212: ...ing code in a ColdFusion page named wscfml cfm cfinvoke webservice http www xmethods net sd 2001 BabelFishService wsdl method BabelFish translationmode en_es sourcedata Hello world friend returnVariab...

Page 213: ...ag to dynamically determine the arguments to be passed For example you can use conditional processing to determine the argument name or you can use a cfif tag to determine whether to execute the cfinv...

Page 214: ...214 Chapter 2 ColdFusion Tags name sourcedata value Hello world friend cfinvoke cfoutput varName cfoutput...

Page 215: ...ps secure multi_field_security_string separator separator_character delimiter delimiter_character See also cfftp cfhttp cfmail cfmailparam cfpop Chapter 23 Managing LDAP Directories in Developing Cold...

Page 216: ...Requires dn name Required if action Query Name of LDAP query The tag validates the value timeout Optional 60 Maximum length of time in seconds to wait for LDAP processing maxRows Optional Maximum numb...

Page 217: ...ype Optional replace How to process an attribute in a multi value list add appends it to any attributes delete deletes it from the set of attributes replace replaces it with specified attributes You c...

Page 218: ...ColdFusion illegal characters are automatically mapped to the underscore character therefore column names in the query result set might not exactly match the names of the LDAP attributes For usage ex...

Page 219: ...nn dc edu filter cn name attributes cn o title mail telephonenumber sort cn ASC Display results center table border 0 cellspacing 2 cellpadding 2 tr th colspan 5 cfoutput results recordCount matches f...

Page 220: ...rd file This tag has no effect if you use it after the cfflush tag on a page Example h3 cflocation Example h3 p This tag redirects the browser to a web resource normally you would use this tag to go t...

Page 221: ...y or exclusive CFML to be synchronized cflock See also cfapplication cfassociate cfmodule Chapter 15 Using Persistent Data and Locking in Developing ColdFusion MX Applications Attributes Attribute Req...

Page 222: ...lay set or update variables in a shared scope use the scope attribute to identify the scope as Server Application or Session Deadlocks A deadlock is a state in which no request can execute the locked...

Page 223: ...u can skip any pair of these lock unlock steps For example if you do not have to lock the Server scope you can skip Steps 3 and 4 Similar rules apply for named locks For more information see the follo...

Page 224: ...ock for the application wide variable that keeps track of the number of turtlenecks sold For a more efficient but more complex way of handling Application scope locking see Developing ColdFusion MX Ap...

Page 225: ...ld Please select color and size p table cellspacing 2 cellpadding 2 border 0 tr td Select a color td td select type Text name color option red option white option blue option turquoise option black op...

Page 226: ...essage text to log log Optional If you omit the file attribute writes messages to standard log file Ignored if you specify file attribute Application writes to Application log normally used for applic...

Page 227: ...specify No for the application attribute the corresponding entry in the list is empty You can disable cflog tag execution For more information see the ColdFusion Administrator Basic Security page The...

Page 228: ...ntication information ColdFusion MX Added this tag Attributes 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 t...

Page 229: ...shed using a one way algorithm in the Authorization header ColdFusion gets the username from the web server and sets the cflogin password value to the empty string You can use these values in the cflo...

Page 230: ...login remains in effect until the session expires or the user is logged out by the cflogin tag ColdFusion MX Added this tag Attributes Usage Used inside the cflogin tag to identify the authenticated...

Page 231: ...cflogin cfloginuser Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX 6 1 Changed behavior if the Session scope is enabled a login remains in effect unti...

Page 232: ...repeatedly until one or more conditions are met This tag supports the following types of loops cfloop index loop on page 233 cfloop conditional loop on page 235 cfloop looping over a query on page 23...

Page 233: ...internal representation of floating point numbers Note The to value is evaluated once when the cfloop tag is encountered Any change to this value within the loop block or within the expression that ev...

Page 234: ...is loop is as follows The loop index is 1 The loop index is 2 The loop index is 3 The loop index is 4 As before the value of j is decremented by one for each iteration but this does not affect the val...

Page 235: ...ession cfloop See also cfabort cfbreak cfexecute cfexit cfif cflocation cfswitch cfthrow cftry Attributes Example The following example increments CountVar from 1 to 5 Set the variable CountVar to 0 c...

Page 236: ...cfoutput br cfloop The cfloop tag also iterates over a record set with dynamic start and stop points This gets the next n sets of records from a query This example loops from the 10th through the 20th...

Page 237: ...cfloop looping over a query 237 dataSource Library maxRows 5 SELECT TemplateName FROM Templates cfquery cfloop query TemplateName cfinclude template TemplateName cfloop...

Page 238: ...er in the delimiters attribute in any order For example this loop processes commas colons and slashes as list delimiters cfloop index ListElement list John Paul George Ringo delimiters cfoutput ListEl...

Page 239: ...he collection is referenced In the cfoutput section the name property of the file2 item is referenced for display Example This example uses a COM object to output a list of files In this example FFunc...

Page 240: ...th query query_name group query_column groupcasesensitive yes or no startrow query_row maxrows max_msgs server serverspecs port port_id mailerid headerid timeout seconds spoolenable yes or no Optional...

Page 241: ...enerated For example to send messages that give customers status updates Status of Order Number Order_ID replyto Optional Address es to which the recipient is directed to send replies failto Optional...

Page 242: ...ify the MIME type query Optional Name of cfquery from which to draw data for message s Use this attribute to send more than one message or to send query results within a message group Optional Current...

Page 243: ...essing Mail addresses can have any of the following forms port Optional TCP IP port on which SMTP server listens for requests normally 25 A value here overrides the Administrator mailerID Optional Col...

Page 244: ...in the order they are listed until it connects to a server ColdFusion does not try to connect to a server that was unavailable in the last 60 seconds Example h3 cfmail Example h3 Delete the surroundin...

Page 245: ...cfmail 245 p input type Submit name form...

Page 246: ...le uses cfmailparam to attach files and add header to a message p cfmail from peter domain com To paul domain com Subject See Important Attachments and Reply Attribute Req Opt Default Description file...

Page 247: ...lparam 247 cfmailparam name Importance value Hich Please review the new logo Tell us what you think cfmailparam file c work readme txt type text plain cfmailparam file c work logo gif type image gif c...

Page 248: ...t contents cfmailpart cfmail History ColdFusion MX 6 1 Added this tag See also cfmail cfmailparam cfpop cfftp cfhttp cfldap cfcontent Wrap Chapter 35 Sending and Receiving E Mail in Developing ColdFus...

Page 249: ...ssage h3 p You are reading this message as strong HTML strong p p Your mail reader handles HTML text p cfmailpart cfmail wraptext Optional Do not wrap text Specifies the maximum line length in charact...

Page 250: ...the attributeCollection parameter ColdFusion now uses the name value that is within the attributeCollection parameter Earlier releases did not process this consistently Attributes Attribute Req Opt D...

Page 251: ...fmodule Example h3 p This view only example shows use of cfmodule to call a custom tag inline p p This example uses a sample custom tag that is saved in myTag cfm in the snippets directory You can als...

Page 252: ...HTMLCodeFormat CFMODULE NAME myTag X 3 attributeCollection attrCollection1 Y 4 cfoutput P The result cfoutput result cfoutput Call the tag using the short cut notation CF_myTag X 3 attributeCollectio...

Page 253: ...Note On UNIX this tag does not support COM objects See also cfargument cfcomponent cffunction cfinvoke cfinvokeargument cfproperty cfreturn History ColdFusion MX Changed instantiation behavior this ta...

Page 254: ...EView utility Note On UNIX this tag does not support COM objects Syntax cfobject type com action action class program_ID name text context context server server_name See also ReleaseComObject cfcollec...

Page 255: ...br HR cfoutput Get the 3rd object in the collection cfset emp obj Item 3 cfoutput The last name in the third item is emp lastname br HR cfoutput Loop over all the objects in the collection p Looping t...

Page 256: ...d component name but is all lower case If it does not find the file it looks for a file name that matches the component name exactly with the identical character casing Example separate instantiation...

Page 257: ...rba java The other object types do not take the type attribute context Required ior ColdFusion uses Interoperable Object Reference IOR to access CORBA server nameservice ColdFusion uses naming service...

Page 258: ...258 Chapter 2 ColdFusion Tags Example cfobject type corba context ior class c myobject ior name GetName...

Page 259: ...mple code 2 Use the init method with appropriate arguments to call a constructor For example cfset ret myObj init arg1 arg2 Calling a public method on the object without first calling the init method...

Page 260: ...creates the Weblogic Environment object which is used to get InitialContext The context object is used to look up the EJBHome interface The call to create results in getting an instance of stateless s...

Page 261: ...xy object for a web service You can enter the absolute URL in this tag or refer to a web service that is entered in the ColdFusion Administrator To minimize potential code maintenance enter the web se...

Page 262: ...he query cache Category Database manipulation tags Syntax cfobjectcache action clear See also cfobject History ColdFusion 5 Added this tag Attributes Attribute Req Opt Default Description action Requi...

Page 263: ...groups or eliminates duplicate entries as specified by the grouping attribute values if any It also sets the query currentRow variable to the current row being processed If you nest cfoutput blocks t...

Page 264: ...recordCount cfoutput total records in our query Using the maxRows parameter we are limiting our display to 4 rows p cfoutput query GetCourses maxRows 4 Dept_ID CorName CorLevel br cfoutput p The next...

Page 265: ...e ColdFusion returns an error Attribute Req Opt Default Description name Required Name of parameter to test such as Client Email or Cookie BackgroundColor If omitted and if the parameter does not exis...

Page 266: ...L pages Example This example shows how to use CFPARAM to define default values for page variables cfparam name storeTempVar default my default value cfparam name tempVar default my default value check...

Page 267: ...HTML parts Changed the attachment name separator the TAB character is now the separator between attachment names in the attachments and attachmentfiles query fields if a message has multiple attachmen...

Page 268: ...t of message numbers to get or delete Invalid message numbers are ignored Ignored if uid is specified uid UID or a comma delimited list of UIDs to get or delete Invalid UIDs are ignored attachment Pat...

Page 269: ...s a tab separated list of all the attachment names The queryname attachments column contains a tab separated list of the locations of the attachment files Use the cffile tag to delete these temporary...

Page 270: ...Server cfif IsDefined form server make sure server username are not empty cfif form server is not and form username is not cfpop server server username UserName password pwd action GETHEADERONLY name...

Page 271: ...tive pageencoding page encoding literal string or cfprocessingdirective suppressWhiteSpace Yes or No pageEncoding page encoding literal string CFML tags cfprocessingdirective See also cfcol cfcontent...

Page 272: ...multiple cfprocessingdirective tags in one page that specify the pageEncoding attribute they must all specify the same value if not ColdFusion throws an error If you specify only the pageencoding att...

Page 273: ...space whitespaceSetting code to whose output the setting is applied cfprocessingdirective The suppresswhitespace attribute only affects code that you put between the cfprocessingdirective begin tag an...

Page 274: ...ldFusion MX uses JDBC 2 2 and does not support named parameters Changed the maxLength attribute behavior it now applies to IN and INOUT parameter values Attributes Attribute Req Opt Default Descriptio...

Page 275: ...ype Different database systems might support different subsets of this list See your DBMS documentation for information on supported parameter types CF_SQL_BIGINT CF_SQL_BIT CF_SQL_BLOB CF_SQL_CHAR CF...

Page 276: ...pParam1 in out EmpTyp pParam2 in out DeptTyp pParam3 in integer pParam4 out varchar2 END foo_data CREATE OR REPLACE PACKAGE BODY Foo_Data AS PROCEDURE RefCurProc pParam1 in out EmpTyp pParam2 in out...

Page 277: ...text ENAME cfcol header JOB text JOB cfcol header SALARY text SAL cfcol header DEPT NUMBER text DEPTNO cftable hr b The second result set b br cftable query rs2 colHeaders HTMLTable border 1 cfcol he...

Page 278: ...rsor type which passes a parameter by reference Parameters that are passed this way can be allocated and deallocated from memory within the execution of one application To use reference cursors in pac...

Page 279: ...output The output param value foo br cfoutput h3 The Results Information h3 cfoutput query RS1 name DATE_COL br cfoutput p cfoutput hr p Record Count RS1 recordCount p Columns RS1 columnList hr cfoutp...

Page 280: ...name Must be a static value type Optional any A string identifies the property data type any array binary boolean date guid The argument must be a UUID or GUID of the form xxxxxxxx xxxx xxxx xxxx xxxx...

Page 281: ...name State type string cfproperty name Country type string cfcomponent This component represnts a complex data type that can be used in a component that is exported as a web service such as the follow...

Page 282: ...er date cachedWithin timespan Either of the following debug Yes or No or debug SQL statement s cfquery See also cfinsert cfprocparam cfprocresult cfqueryparam cfstoredproc cftransaction cfupdate chapt...

Page 283: ...ms timeout Maximum number of seconds that each action of a query is permitted to execute before returning an error The cumulative time may exceed this value For JDBC statements ColdFusion sets this at...

Page 284: ...ecommends that you use the DateFormat and TimeFormat functions to format values from queries For more information and examples see TechNote 22183 ColdFusion Server 5 and 4 5 x with Oracle Formatting D...

Page 285: ...font size 1 ParkName font td td valign top font size 1 Region font td td valign top font size 1 State font td tr cfoutput If the total number of records is less than or equal to the total number of r...

Page 286: ...r databases from unauthorized users For more information see Security Bulletin ASB99 04 Multiple SQL Statements in Dynamic Queries at www macromedia com devnet security security_zone asb99 04 html Cha...

Page 287: ..._SQL_DECIMAL CF_SQL_DOUBLE CF_SQL_FLOAT CF_SQL_IDSTAMP CF_SQL_INTEGER CF_SQL_LONGVARCHAR CF_SQL_MONEY CF_SQL_MONEY4 CF_SQL_NUMERIC CF_SQL_REAL CF_SQL_REFCURSOR CF_SQL_SMALLINT CF_SQL_TIME CF_SQL_TIMES...

Page 288: ...OAT CF_SQL_DOUBLE CF_SQL_TINYINT CF_SQL_MONEY CF_SQL_MONEY4 CF_SQL_DECIMAL CF_SQL_NUMERIC and CF_SQL_BIGINT For these types a data value can be converted to a date supported by the target data source...

Page 289: ...tFirst datasource cfsnippets SELECT FROM employees WHERE LastName cfqueryparam value LastName cfsqltype CF_SQL_VARCHAR maxlength 17 cfquery cfoutput query getFirst p Course Number FirstName LastName D...

Page 290: ...her tags Variable manipulation tags Syntax The tag syntax depends on the action attribute value See the following sections cfregistry action getAll on page 291 cfregistry action get on page 292 cfregi...

Page 291: ...try action getAll branch HKEY_LOCAL_MACHINE Software Microsoft Java VM type Any name RegQuery p h1 cfregistry action getAll h1 cftable query RegQuery colHeaders HTMLTable border Yes cfcol header b Ent...

Page 292: ...s cfregistry with the Get Action cfregistry action get branch HKEY_LOCAL_MACHINE Software Microsoft Java VM entry ClassPath type String variable RegValue h1 cfregistry action get h1 cfoutput p Java Cl...

Page 293: ...tead of setting one here cfset FileName dummy cfm cfregistry action set branch HKEY_LOCAL_MACHINE Software cflangref entry LastCFM01 type String value FileName h1 cfregistry action set h1 Attribute Re...

Page 294: ...ined beneath it Example cfregistry action delete branch HKEY_LOCAL_MACHINE Software cflangref tempkey entry LastCFM01 h1 cfregistry action delete h1 Attribute Req Opt Default Description action Requir...

Page 295: ...e The connection is not subject to any ColdFusion data source specific restrictions For example the Crystal Reports server can access a data source regardless of whether it is disabled in the ColdFusi...

Page 296: ...ly the information for a subset of the report cfreport report reports monthlysales rpt Departments Department International cfreport p Substitute your report files and filters for this code cfreport c...

Page 297: ...the handler raises the exceptions again with details intact so that a higher level handler can process the error information If you used the cfthrow tag the type and details of the original exception...

Page 298: ...pulate a structure with name value pairs and return the structure with this tag To access the result value from this tag you use the variable scope that is the value of the cfinvoke tag returnVariable...

Page 299: ...cfreturn 299 cffunction cfcomponent...

Page 300: ...age This tag requires an end tag You cannot use this tag to suppress output from a tag library Example The following example uses a custom tag to generate a report and saves the report in the variable...

Page 301: ...e path path_to_file startDate date startTime time url URL port port_number publish Yes or No endDate date endTime time interval seconds requestTimeOut seconds username username password password proxy...

Page 302: ...Required if action update URL of the page to execute port Optional 80 Port to use on the server that is specified by the url parameter If resolveURL yes retrieved document URLs that specify a port nu...

Page 303: ...on the specified day of each month for 30 or 31 day months and the last day of February For example if you schedule a monthly job to start on January 30 the job will run on January 30 February 28 or...

Page 304: ...This tag uses ColdFusion functions expressions and operators You can read and write ColdFusion variables within this tag For a detailed description of the CFScript scripting language including documen...

Page 305: ...Object component nasdaq quote invocation using ordered arguments res quote getLastTradePrice macr cfscript The following example shows how to use an attribute collection within the cfscript tag to pas...

Page 306: ...Using Web Services in Developing ColdFusion MX Applications Example p This simple example shows variable declaration and manipulation cfif IsDefined form myValue cfif IsNumeric form myValue cfset x f...

Page 307: ...ndexed in the following ways In ColdFusion with the cfindex tag In the ColdFusion Administrator which calls the cfindex tag Using a native Verity indexing tool such as Vspider or MKVDK For more inform...

Page 308: ...s and or registered collection name s For a registered collection specify the collection name For an unregistered collection specify an absolute path Registered names are listed in the ColdFusion Adm...

Page 309: ...ar mySearch 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 Developing ColdFusion MX App...

Page 310: ...custom1 br custom2 name custom2 br summary name summary br recordcount name recordcount br currentrow name currentrow br columnlist name columnlist br recordssearched name recordssearched br cfoutput...

Page 311: ...br title book titleE br score book score br custom1 book custom1 br custom2 book custom2 br summary book summary br recordcount book recordcount br currentrow book currentrow br columnlist book column...

Page 312: ...display at one time The default 1 displays a drop down list Any other value displays a list box with size number of entries visible at one time required Optional No Yes a list element must be selecte...

Page 313: ...add other HTML input tag attributes and values to this tag use the passThrough attribute They are passed through to the select tag that ColdFusion generates for the cfselect control when creating a fo...

Page 314: ...sentation of Data h3 h4 Click on an employee s last name and hit see information for this employee to see expanded information h4 cfselect name EmployeeNames message Select an Employee Name size getEm...

Page 315: ...ld No bgcolor Teal selectmode BROWSE picturebar No cfgridcolumn name LastName header Last Name headeralign LEFT dataalign LEFT bold No italic No select Yes display Yes headerbold No headeritalic No cf...

Page 316: ...server as ColdFusion use code such as the following in which path specifies a servlet JSP or anything else GetPageContext include path GetPageContext forward path For more information see the JSP Pag...

Page 317: ...to the servlet 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 GetPageCon...

Page 318: ...the following line is a valid ColdFusion cfset tag for deleting the MyVariable variable from the Application scope cfset StructDelete Application MyVariable Arrays The following example assigns a new...

Page 319: ...riable myVar exists only when the function myFunct executes and it is not available elsewhere on the ColdFusion page COM objects In this example a COM object is created A cfset defines a value for eac...

Page 320: ...passed from another page h3 cfif p cfset can also be used to collect environmental variables such as the time the IP address of the user or another function or expression cfset the_date DateFormat Now...

Page 321: ...d by the first cfcatch block that could handle an exception of its type Attributes Usage The cfsetting requestTimeout attribute replaces the use of requestTmeOut within a URL To enforce a page timeout...

Page 322: ...tput Yes the IsDebugMode function returns Yes otherwise No ColdFusion MX 6 1 allows a cfsetting end tag however this end tag does not effect processing The cfsetting attributes affect code inside and...

Page 323: ...nt cfsilent See also cfcache cfflush cfheader cfhtmlhead cfinclude cfsetting Usage This tag requires an end tag Example h3 cfsilent h3 cfsilent cfset a 100 cfset b 99 cfset c b a cfoutput Inside cfsil...

Page 324: ...o tickMarkMinor Yes or No tickMarkImages URL1 URL2 URLn tickMarkLabels Yes or No or list lookAndFeel motif or windows or metal vertical Yes or No bgColor color textColor color font font_name fontSize...

Page 325: ...e if validation fails Specify only the function name height Optional 40 Slider control height in pixels width Optional Slider control width in pixels vSpace Optional Vertical spacing above and below s...

Page 326: ...n does not automatically swap width and height values No renders slider horizontally bgColor Optional Background color of slider label For a hex value use the form bgColor xxxxxx where x 0 9 or A F us...

Page 327: ...responding controls on the user entry form For more information see the cfform tag entry Example This example shows how to use cfslider within cfform h3 cfslider Example h3 p cfslider used within a cf...

Page 328: ...on MX uses Type 4 JDBC drivers Attributes 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 proced...

Page 329: ...Example This view only example executes a Sybase stored procedure that returns three result sets two of which we want The stored procedure returns the status code and one output parameter which we dis...

Page 330: ...code within this tag must be within a cfcase or cfdefaultcase tag Otherwise ColdFusion throws an error Use this tag followed by one or more cfcase tags Optionally include a cfdefaultcase tag This tag...

Page 331: ...ase is output p cfoutput query GetEmployees cfswitch expression Trim Department cfcase value Sales FirstName LastName is in b sales b br br cfcase cfcase value Accounting FirstName LastName is in b ac...

Page 332: ...ws_table colSpacing number_of_spaces headerLines number_of_lines HTMLTable border colHeaders startRow row_number cftable See also cfcol cfoutput cfcontent cfprocessingdirective cflog cftable Attribute...

Page 333: ...me LastName EMail Phone Department FROM Employees cfquery html body h3 cftable Example h3 Note use of HTMLTable attribute to display cftable as an HTML table rather than as PRE formatted information c...

Page 334: ...eger vSpace integer hSpace integer align alignment bgColor color textColor color maxLength integer notSupported text See also cfapplet cfform cfgrid cfgridcolumn cfgridrow cfgridupdate cfinput cfselec...

Page 335: ...object and input object value are passed to routine which should return True if validation succeeds False otherwise The validate attribute is ignored pattern Required if validate regular_ expression J...

Page 336: ...ne texttop absbottom middle absmiddle right bgColor Optional Background color of control For a hex value use the form textColor xxxxxx where x 0 9 or A F use two pound signs or none any color in hex f...

Page 337: ...ut control is used Example h3 cftextinput Example h3 cftextinput provides simple validation for text fields in cfform and control over font information displayed in cfform input boxes for text For exa...

Page 338: ...his tag can throw ColdFusion component method exceptions Attributes Attribute Req Opt Default Description type Optional Application A custom type Application Do not enter another predefined type types...

Page 339: ...lass has constructors that take parameters such as a message you can use the special init method to invoke the constructor as in the following line If you do not need to specify any constructor attrib...

Page 340: ...red yes cfquery name empQuery datasource ExampleApps SELECT LASTNAME FIRSTNAME EMAIL FROM tblEmployees WHERE LASTNAME LIKE arguments lastName cfquery cfif empQuery recordcount LT 1 cfthrow type noQuer...

Page 341: ...section Category Debugging tags Variable manipulation tags Syntax cftrace abort Yes or No category string inline Yes or No text string type format var variable_name cftrace See also cfdump cferror cf...

Page 342: ...2 23 58 58 5187 ms 10 C cfusion wwwroot generic cfm line 14 category thisPage generic cfm ABORTED thisPage For a complex variable ColdFusion lists the variable name and the number of elements in the o...

Page 343: ...end tag Within a transaction block you can write queries to more than one database but you must commit or rollback a transaction to one database before writing a query to another Using CFML error hand...

Page 344: ...RT INTO Courses Number Descript VALUES myNumber myDescription cfquery cfquery name insertNewCourseToList datasource Snippets INSERT INTO CourseList CorNumber CorDesc Dept_ID CorName CorLevel LastUpdat...

Page 345: ...r No bold Yes or No height integer width integer vSpace integer hSpace integer align alignment border Yes or No hScroll Yes or No vScroll Yes or No notSupported text cftree See also cfapplet cfform cf...

Page 346: ...tional JavaScript function to validate user input The form object input object and input object value are passed to the specified routine which should return True if validation succeeds False otherwis...

Page 347: ...ery takes a list of employees and uses cftree and cfselect to display the results cfgrid is used to show an alternate means of displaying the same data set a default for the employeeNames variable cfp...

Page 348: ...ta Loop through the query to create each branch of the cftree h3 cftree Presentation of Data h3 h4 Click on the folders to drill down and reveal information h4 p cftreeitem is used to create the branc...

Page 349: ...rm is submitted When populating a tree with data from a cfquery specify columns in a delimited list Example value dept_id emp_id display Optional value Tree item label When populating a tree with data...

Page 350: ...employeeNames cfif cfquery Use cfform when using other cfinput tools cfform action cfindex cfm imgopen Optional Icon displayed with open tree item You can specify icon filename with a relative path Yo...

Page 351: ...No cftreeitem value Department display Department parent Emp_ID queryAsRoot No expand No cftreeitem value Department parent Department expand No queryAsRoot No cftreeitem value Phone display Phone par...

Page 352: ...lay Yes headerbold No headeritalic No cfgridcolumn name Department header Department headeralign LEFT dataalign LEFT bold Yes italic No select No display Yes headerbold No headeritalic No cfgridcolumn...

Page 353: ...y block put the code that might throw an exception followed by one ore more cfcatch tags that catch and process exceptions This tag requires an end tag Example cftry example using TagContext to displa...

Page 354: ...354 Chapter 2 ColdFusion Tags cfoutput cfcatch cftry...

Page 355: ...ble to update For ORACLE drivers must be uppercase For Sybase driver case sensitive must be in same case as used when the table was created tableOwner Optional For data sources that support table owne...

Page 356: ...TE Example title cfset css_path css cfinclude template resource include mm_browsersniff cfm head body H3 CFUPDATE Example H3 If we are updating a record don t show the entire list cfif IsDefined url C...

Page 357: ...cfupdate 357 cftable cfif body html...

Page 358: ...fdump cfexecute cfindex cfobject cfreport cfsearch History ColdFusion MX Changed column name case behavior ColdFusion preserves the case of column names in JavaScript Earlier releases converted query...

Page 359: ...ge_Id Thread_id Username from messages cfquery The recordset data is p cfoutput query q Message_ID Thread_ID Username br cfoutput p Serialize data to WDDX format Serializing CFML data p cfwddx action...

Page 360: ...sion Tags Deserialize to a variable named wddxResult Deserializing WDDX packet p cfwddx action wddx2cfml input wddxText output qnew The recordset data is p cfoutput query qnew Message_ID Thread_ID Use...

Page 361: ...s text that displays the value of the ColdFusion variable testVar The code creates four nested child elements which are generated by an indexed cfloop tag The cfdump tag displays the XML document obje...

Page 362: ...362 Chapter 2 ColdFusion Tags cfloop MyDoc cfxml cfdump var MyDoc...

Page 363: ...oldFusion Functions This chapter lists and categorizes ColdFusion Markup Language CFML functions Contents Function list 364 Functions by category 367 Function changes since ColdFusion 5 372 Function d...

Page 364: ...ctions ParameterExists ArrayLen GetProfileString ParseDateTime ArrayMax GetTempDirectory Pi ArrayMin GetTempFile PreserveSingleQuotes ArrayNew GetTemplatePath Quarter ArrayPrepend GetTickCount QueryAd...

Page 365: ...eateTimeSpan IsXmlElem Sqr CreateUUID IsXmlRoot StripCR DateAdd JavaCast StructAppend DateCompare JSStringFormat StructClear DateConvert LCase StructCopy DateDiff Left StructCount DateFormat Len Struc...

Page 366: ...Month LSCurrencyFormat ValueList Fix LSDateFormat Week FormatBaseN LSEuroCurrencyFormat Wrap GetAuthUser LSIsCurrency WriteOutput GetBaseTagData LSIsDate XmlChildPos GetBaseTagList LSIsNumeric XmlElem...

Page 367: ...s 369 International functions 369 List functions 369 Mathematical functions 370 Other functions 370 Query functions 370 String functions 370 Structure functions 371 System functions 371 XML functions...

Page 368: ...rt GetHttpTimeString Minute DateDiff GetTickCount Month DirectoryExists IsDebugMode IsObject IsXmlRoot FileExists IsDefined IsQuery LSIsCurrency IIf IsK2ServerABroker IsSimpleValue LSIsDate IsArray Is...

Page 369: ...tExceeded DateConvert LSIsCurrency LSParseDateTime LSParseNumber GetEncoding LSCurrencyFormat LSIsNumeric LSTimeFormat GetHttpTimeString LSDateFormat LSNumberFormat SetEncoding GetLocale LSEuroCurren...

Page 370: ...ring Abs BitNot FormatBaseN Randomize ACos BitOr IncrementValue RandRange ArrayAvg BitSHLN InputBaseN Round ArraySum BitSHRN Int Sgn ASin BitXor Log Sin Atn Ceiling Log10 Sqr BitAnd Cos Max Tan BitMas...

Page 371: ...h LSParseNumber Right Insert LTrim RJustify JavaCast Mid RTrim Duplicate StructCount StructGet StructKeyList IsStruct StructDelete StructInsert StructNew StructAppend StructFind StructIsEmpty StructSo...

Page 372: ...ColdFusion MX 6 1 GetAuthUser All ColdFusion MX GetEncoding All ColdFusion MX GetMetaData All ColdFusion MX GetPageContext All ColdFusion MX GetProfileSections All ColdFusion MX IsObject All ColdFusi...

Page 373: ...ue Deprecated as of this ColdFusion release getMetricData cachepops parameter ColdFusion MX getK2ServerDocCount All ColdFusion MX 6 1 getK2ServerDocCount Limit All ColdFusion MX 6 1 getTemplatePath Al...

Page 374: ...absolute value of a number Category Mathematical functions Function syntax Abs number See also Sgn Parameters Example h3 Abs Example h3 p The absolute value of the following numbers 1 3 4 3 2 6 is cfo...

Page 375: ...t its arccosine value cfif IsDefined FORM CosNum cfif IsNumeric FORM CosNum cfif Abs FORM CosNum LESS THAN OR EQUAL TO 1 cfoutput ACos FORM CosNum ACos FORM cosNum Radians cfoutput br or br cfoutput A...

Page 376: ...ets SELECT FirstName LastName FROM Employees cfquery create an array cfset myArray ArrayNew 1 set element one to show where we are cfset myArray 1 Test Value loop through the query append these names...

Page 377: ...be dynamically generated on the screen It uses the Fieldnames variable with the ListLen function to determine the number of fields on the form cfset FormElem 2 cfif Isdefined Form Submit cfif Form Sub...

Page 378: ...IsDefined FORM submit cfset myNumberArray ArrayNew 1 cfset Count 1 cfloop index ListItem list Form Fieldnames cfif Left ListItem 3 is Num cfset myNumberArray Count Val Evaluate number Count cfset coun...

Page 379: ...create a new array cfset MyArray ArrayNew 1 populate an element or two cfset MyArray 1 Test cfset MyArray 2 Other Test output the contents of the array p Your array contents are cfoutput ArrayToList...

Page 380: ...L objects Changed thrown exceptions this function can throw the InvalidArrayIndexException error Parameters Throws If this function attempts to delete an element at position 0 or specifies a value for...

Page 381: ...to insert an element at position 0 or specifies a value for position that is greater than the size of array this function throws an InvalidArrayIndexException error Example h3 ArrayInsertAt Example h...

Page 382: ...le h3 ArrayIsEmpty Example h3 create a new array cfset MyArray ArrayNew 1 populate an element or two cfset MyArray 1 Test cfset MyArray 2 Other Test output the contents of the array p Your array conte...

Page 383: ...ets SELECT FirstName LastName FROM Employees cfquery create an array cfset myArray ArrayNew 1 set element one to show where we are cfset myArray 1 Test Value loop through the query and append these na...

Page 384: ...o elements in the array cfif IsDefined FORM submit cfset myNumberArray ArrayNew 1 cfset myNumberArray 1 number1 cfset myNumberArray 2 number2 cfif Form Submit is Maximum Value use ArrayMax to find the...

Page 385: ...s cfif IsDefined FORM submit cfset myNumberArray ArrayNew 1 cfset myNumberArray 1 FORM number1 cfset myNumberArray 2 FORM number2 cfif Form Submit is Minimum Value use ArrayMin to find the smallest nu...

Page 386: ...yToList does not function properly if the Array is not initialized with ArraySet cfset temp ArraySet MyNewArray 1 6 set some elements cfset MyNewArray 1 Sample Value cfset MyNewArray 3 43 cfset MyNewA...

Page 387: ...ayNew 1 set element one to show where we are cfset myArray 1 Test Value loop through query Append names successively before last element list reverses itself from the standard queried output as it kee...

Page 388: ...on Category Array functions Function syntax ArrayResize array minimum_size Parameters Example h3 ArrayResize Example h3 perform a query to get the list cfquery name GetCourses datasource cfsnippets SE...

Page 389: ...eters Example h3 ArraySet Example h3 Make an array cfset MyNewArray ArrayNew 1 ArrayToList does not function properly if the Array has not been initialized with ArraySet cfset temp ArraySet MyNewArray...

Page 390: ...l order For example in a textnocase desc sort of d a a b A the following occurs ColdFusion MX returns d b A a a Earlier ColdFusion releases return d b a a A Parameters Parameter Description array Name...

Page 391: ...t cfquery name GetEmployeeNames datasource cfsnippets SELECT FirstName LastName FROM Employees cfquery create an array cfset myArray ArrayNew 1 loop through the query and append these names successive...

Page 392: ...ields to the first two elements in the array cfif IsDefined FORM submit cfset myNumberArray ArrayNew 1 cfset myNumberArray 1 number1 cfset myNumberArray 2 number2 cfif Form Submit is Add use ArraySum...

Page 393: ...tions Function syntax ArraySwap array position1 position2 Parameters Example h3 ArraySwap Example h3 cfset month ArrayNew 1 cfset month 1 February cfset month 2 January cfset temp ArraySwap month 1 2...

Page 394: ...st element cfloop query GetEmployeeNames cfset temp ArrayAppend myArray FirstName LastName cfloop show the resulting array as a list cfset myList ArrayToList myArray sort that array descending alphabe...

Page 395: ...value of 65536 Earlier releases supported 1 255 Parameters Example h3 Asc Example h3 if the character string is not empty output its ASCII value cfif IsDefined FORM charVals cfif FORM charVals is not...

Page 396: ...tput cfoutput Evaluate ASin FORM sinNum Radians cfoutput br or br ASin cfoutput FORM SinNum cfoutput cfoutput Evaluate ASin FORM sinNum 180 Pi Degrees cfoutput cfelse if it is less than negative one o...

Page 397: ...ASin 397 br input type Text name sinNum size 25 p input type Submit name input type RESET form...

Page 398: ...180 To convert radians to degrees multiply radians by 180 Example h3 Atn Example h3 output its Atn value cfif IsDefined FORM AtnNum cfif IsNumeric FORM AtnNum Atn cfoutput FORM AtnNum cfoutput cfoutp...

Page 399: ...is obsolete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX This function is o...

Page 400: ...ion is obsolete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX This function...

Page 401: ...Or BitXor Parameters Usage Bit functions operate on 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitAnd Example h3 p Returns the bitwise AND of two long integers p BitAnd 5 255...

Page 402: ...n 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitMaskClear Example h3 p Returns number bitwise cleared with length bits beginning from start p BitMaskClear 255 4 4 cfoutput Bi...

Page 403: ...egers in the range 2147483648 2147483647 Example h3 BitMaskRead Example h3 p Returns integer created from em length em bits of em number em beginning with em start em p BitMaskRead 255 4 4 cfoutput Bi...

Page 404: ...d integers in the range 2147483648 2147483647 Example h3 BitMaskSet Example h3 p Returns number bitwise masked with length bits of mask beginning at start p BitMaskSet 255 255 4 4 cfoutput BitMaskSet...

Page 405: ...tion syntax BitNot number See also BitAnd BitOr BitXor Parameters Usage Bit functions operate on 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitNot Example h3 p Returns the bi...

Page 406: ...r2 See also BitAnd BitNot BitXor Parameters Usage Bit functions operate on 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitOr Example h3 p Returns the bitwise OR of two long in...

Page 407: ...e on 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitSHLN Example h3 p Returns the number bitwise shifted without rotation to the left by count bits p BitSHLN 1 1 cfoutput BitS...

Page 408: ...Usage Bit functions operate on 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitSHRN Example h3 p Returns a number bitwise shifted without rotation to the right by count bits p...

Page 409: ...t BitOr Parameters Usage Bit functions operate on 32 bit signed integers in the range 2147483648 2147483647 Example h3 BitXOr Example h3 p Returns the bitwise XOR of two long integers p BitXOr 5 255 c...

Page 410: ...is greater than a given number Category Mathematical functions Function syntax Ceiling number See also Int Fix Round Parameters Example h3 Ceiling Example h3 cfoutput p The ceiling of 3 4 is ceiling 3...

Page 411: ...e two character string Chr 13 Chr 10 returns a Windows newline Note For a complete list of the Unicode characters and their codes see www unicode org charts Example If the character string is not empt...

Page 412: ...tring Cjustify FORM justifyString 35 cfif html head title CJustify Example title head body h3 CJustify h3 p Enter a string it will be center justified within the sample field form action cjustify cfm...

Page 413: ...parison of two strings cfif IsDefined FORM string1 cfset comparison Compare FORM string1 FORM string2 switch on the variable to give various responses cfswitch expression comparison cfcase value 1 h3...

Page 414: ...414 Chapter 3 ColdFusion Functions p String 1 br input type Text name string1 p String 2 br input type Text name string2 p input type Submit value Compare these Strings name input type RESET form...

Page 415: ...CFSET comparison Comparenocase form string1 form string2 switch on the variable to give various responses CFSWITCH EXPRESSION comparison CFCASE value 1 H3 String 1 is less than String 2 H3 I The strin...

Page 416: ...416 Chapter 3 ColdFusion Functions P INPUT TYPE Submit VALUE Compare these Strings NAME INPUT TYPE RESET FORM...

Page 417: ...0000000001 Example h3 Cos Example h3 Calculate cosine if form has been submitted cfif IsDefined FORM cosNum Make sure input is a number cfif IsNumeric FORM cosNum Convert degrees to radians call the C...

Page 418: ...418 Chapter 3 ColdFusion Functions br br input type Submit name nbsp nbsp input type RESET form...

Page 419: ...2 13 0 li Formatted with CreateODBCDate CreateODBCDate yourDate li Formatted with CreateODBCDateTime CreateODBCDateTime yourDate ul p The same value can be formatted with DateFormat ul li Formatted wi...

Page 420: ...METHOD POST p Enter the year month and day as integers PRE Year CFINPUT TYPE Text NAME year VALUE 1998 VALIDATE integer REQUIRED Yes Month CFINPUT TYPE Text NAME month VALUE 6 VALIDATE integer REQUIRE...

Page 421: ...our form minute form second li Formatted with CreateODBCDate CreateODBCDate yourDate li Formatted with CreateODBCDateTime CreateODBCDateTime yourDate ul p The same value can be formatted with DateForm...

Page 422: ...Text NAME month VALUE 6 RANGE 1 12 MESSAGE Please enter a month 1 12 VALIDATE integer REQUIRED Yes Day CFINPUT TYPE Text NAME day VALUE 8 RANGE 1 31 MESSAGE Please enter a day of the month 1 31 VALID...

Page 423: ...Applications For CORBA object changed the Naming Service separator format for addresses from a dot to a forward slash For example if context NameService for a class use either of the following format...

Page 424: ...class context serverName See also ReleaseComObject cfobject Parameters Usage The following example creates the Windows Collaborative Data Objects CDO for NTS NewMail object to send mail You would use...

Page 425: ...to the tellTime component using the CreateObject function The CreateObject function references the component in another directory To invoke component methods you use function syntax For more informat...

Page 426: ...context in the naming service You must provide the object s attributes method names and method signatures This function supports user defined types structures arrays and sequences Example myobj Create...

Page 427: ...CreateObject 427 myobj CreateObject corba Macromedia Eng CF nameservice visibroker uses nameservice myobj CreateObject corba d temp tester ior nameservice uses nameservice and default configuration...

Page 428: ...init method with appropriate arguments to call an instance of the class For example cfset ret myObj init arg1 arg2 Calling a public method on the object without first calling the init method invokes...

Page 429: ...rvice object Function syntax CreateObject type urltowsdl Parameters Usage You can use the CreateObject function to create a web service Example newobject2 CreateObject webservice wsdlurl Parameter Des...

Page 430: ...ue generated with CreateDateTime cfset yourDate CreateDateTime form year form month form day form hour form minute form second cfoutput ul li Formatted with CreateDate CreateDate form year form month...

Page 431: ...t name day value 8 range 1 31 MESSAGE Please enter a day of the month 1 31 VALIDATE integer REQUIRED Yes Hour cfinput type text name hour value 16 range 0 23 MESSAGE You must enter an hour 0 23 VALIDA...

Page 432: ...hour form minute form second cfoutput ul li Formatted with CreateDate CreateDate form year form month form day li Formatted with CreateDateTime CreateDateTime form year form month form day form hour...

Page 433: ...me day value 8 range 1 31 MESSAGE Enter a day of the month 1 31 VALIDATE integer REQUIRED Yes Hour cfinput type text name hour value 16 range 0 23 MESSAGE You must enter an hour 0 23 VALIDATE integer...

Page 434: ...CreateTime form hour form minute form second cfoutput ul li Formatted with CreateODBCTime CreateODBCTime yourTime li Formatted with TimeFormat TimeFormat yourTime ul cfoutput cfif cfform action creat...

Page 435: ...cond cfoutput ul li Formatted with timeFormat TimeFormat yourTime li Formatted with timeFormat and hh mm ss TimeFormat yourTime hh mm ss ul cfoutput cfif CFFORM action createtime cfm METHOD post PRE H...

Page 436: ...TimeSpan function is used to define a period of time from the present backwards The cachedWithin attribute takes effect only if you enable query caching in the ColdFusion Administrator For more inform...

Page 437: ...axrows maxrows TR TD valign top bgcolor ffffed b GetParks CurrentRow b TD TD valign top font size 1 ParkName font TD TD valign top font size 1 Region font TD TD valign top font size 1 State font TD TR...

Page 438: ...a user defined function called CreateGUID which converts CFML UUIDs to UUID Microsoft GUID format available on the web at www cflib org Use this function to generate a persistent identifier in a dist...

Page 439: ...g you must enclose it in quotation marks Otherwise it is interpreted as a numeric representation of a date time object Example This example shows the use of DateAdd cfparam name value default 70 cfpar...

Page 440: ...hours cfcase cfcase value n minutes cfcase cfcase value s seconds cfcase cfdefaultcase years cfdefaultcase cfswitch are expired table tr td UserName td td Subject td td Posted td tr cfoutput query Get...

Page 441: ...ues cfif IsDefined FORM date1 cfif IsDate FORM date1 and IsDate FORM date2 cfset comparison DateCompare FORM date1 FORM date2 FORM precision switch on the variable to give various responses cfswitch e...

Page 442: ...h3 This is the default case h3 cfdefaultcase cfswitch cfelse h3 Enter two valid date values h3 cfif cfif form action datecompare cfm hr size 2 color 0000A0 p Date 1 br input type Text name date1 valu...

Page 443: ...ample h3 This shows conversion of current date time to UTC and back cfset curDate Now p cfoutput The current date and time curDate cfoutput p cfset utcDate DateConvert local2utc curDate cfoutput p The...

Page 444: ...6 range 1 12 message Enter a month 1 12 validate integer required Yes td tr tr td Day td td input type Text name day value 8 range 1 31 message Enter a day of the month 1 31 validate integer required...

Page 445: ...Usage The DateDiff function determines the number of complete datepart units between the two dates for example if the datepart parameter is m and the dates differ by 55 days the function returns 1 Enc...

Page 446: ...seconds cfcase cfdefaultcase years cfdefaultcase cfswitch dateparts between date1 and date2 cfif DateCompare form date1 form date2 is not 0 p The difference is cfoutput Abs DateDiff type form date2 f...

Page 447: ...What kind of unit to show difference select name type option value yyyy selected years option value q quarters option value m months option value y days of year option value d days option value w wee...

Page 448: ...f this function for example DateFormat CreateDate 2001 3 3 Parameter Description date Date time object in the range 100 AD 9999 AD mask Characters that show how ColdFusion displays a date d Day of the...

Page 449: ...th Oracle Formatting Date and Time Query Results on our website at www coldfusion com Support KnowledgeBase SearchForm cfm Example cfset todayDate Now body h3 DateFormat Example h3 p Today s date is c...

Page 450: ...interpreted as a numeric representation of a date time object Example This example shows information available from DatePart cfset todayDate Now h3 DatePart Example h3 p Today s date is cfoutput toda...

Page 451: ...ePart 451 li day DatePart d todayDate li weekday DatePart w todayDate li week DatePart ww todayDate li hour DatePart h todayDate li minute DatePart n todayDate li second DatePart s todayDate ul cfoutp...

Page 452: ...Now function as the date parameter of this function for example Day CreateDate 2001 3 3 Example h3 Day Example h3 cfif IsDefined FORM year p More information about your date cfset yourDate CreateDate...

Page 453: ...ow function as the date parameter of this function for example DayOfWeek CreateDate 2001 3 3 Example h3 DayOfWeek Example h3 cfif IsDefined FORM year More information about your date cfset yourDate Cr...

Page 454: ...cfif IsDefined FORM year More information about your date cfset yourDate CreateDate FORM year FORM month FORM day cfoutput p Your date DateFormat yourDate br It is DayofWeekAsString DayOfWeek yourDate...

Page 455: ...Now function as the date parameter of this function for example DayOfYear CreateDate 2001 3 3 Example h3 Day7OfYear Example h3 cfif IsDefined FORM year More information about your date cfset yourDate...

Page 456: ...as the date parameter of this function for example DaysInMonth CreateDate 2001 3 3 Example h3 DaysInMonth Example h3 cfif IsDefined FORM year More information about your date cfset yourDate CreateDate...

Page 457: ...Note You can pass the CreateDate function or the Now function as the date parameter of this function for example DaysInYear CreateDate 2001 3 3 Example h3 DaysInYear Example h3 cfif IsDefined FORM yea...

Page 458: ...ed Category Dynamic evaluation functions Function syntax DE string See also Evaluate IIf Parameters Usage Consider this example condition true expression false expression IIf 1 eq 2 DE Var1 DE Var2 Co...

Page 459: ...ry Evaluate the expression cfset myExpression Evaluate FORM myExpression Use DE to output the value of the variable unevaluated cfoutput I The value of the expression Evaluate DE FORM MyExpression is...

Page 460: ...s separator Category Display and formatting functions Function syntax DecimalFormat number See also DollarFormat NumberFormat Parameters Example h3 DecimalFormat Function h3 p Returns a number to two...

Page 461: ...yntax DecrementValue number See also IncrementValue Parameters Example h3 DecrementValue Example h3 p Returns the integer part of a number decremented by one p DecrementValue 0 cfoutput DecrementValue...

Page 462: ...ing cfset key FORM myKey cfset encrypted encrypt string key cfset decrypted decrypt encrypted key cfoutput h4 B The string B h4 string br h4 B The key B h4 key br h4 B Encrypted B h4 encrypted br h4 B...

Page 463: ...DeleteClientVariable Example h3 p This view only example deletes a client variable called User_ID if it exists in the list of client variables returned by GetClientVariablesList p This example require...

Page 464: ...ample h3 h3 Enter a directory to check for existence h2 form action directoryexists cfm method post input type text name yourDirectory br input type submit name submit form cfif IsDefined FORM yourDir...

Page 465: ...t NumberFormat Parameters Example This example shows the use of DollarFormat html head title DollarFormat Example title head body h3 DollarFormat Example h3 cfloop from 8 to 50 index counter cfset ful...

Page 466: ...structures and queries Note With this function you cannot duplicate a COM CORBA or JAVA object returned from the cfobject tag or the CreateObject function If an array element or structure field is a...

Page 467: ...of a string Try it by entering a string and a key to see the results cfif IsDefined FORM myString cfset string FORM myString cfset key FORM myKey cfset encrypted encrypt string key cfset decrypted dec...

Page 468: ...useful for forming one variable from multiple variables For example to reference a column of the query qNames with a variable var using an index value to traverse rows you could use the following cod...

Page 469: ...mber br FORM number raised to the E power exp FORM number cfif FORM number LTE 0 br You must enter a positive real number to see its natural logarithm cfelse br The natural logarithm of FORM number lo...

Page 470: ...s function can now accept an absolute or relative path in the relative_path attribute To resolve a path this function uses virtual mappings that are defined in the ColdFusion Administrator This functi...

Page 471: ...files in this directory use CFDIRECTORY to give the contents of the snippets directory order by name and size CFDIRECTORY DIRECTORY thisDirectory NAME myDirectory SORT name ASC size DESC Output the co...

Page 472: ...GetTemplatePath Parameters Example h3 FileExists Example h3 cfset thisPath ExpandPath cfset thisDirectory GetDirectoryFromPath thisPath cfoutput The current directory is GetDirectoryFromPath thisPath...

Page 473: ...ringToSearch The quick brown fox jumped over the lazy dog find the stringToSearch br find the stringToSearch 35 br find no such substring stringToSearch br br findnocase the stringToSearch br findnoca...

Page 474: ...d Replace Parameters Example cfset stringToSearch The quick brown fox jumped over the lazy dog find the stringToSearch br find the stringToSearch 35 br find no such substring stringToSearch br br find...

Page 475: ...ingToSearch The quick brown fox jumped over the lazy dog find the stringToSearch br find the stringToSearch 35 br find no such substring stringToSearch br br findnocase the stringToSearch br findnocas...

Page 476: ...OfMonth date See also Day DayOfWeek DayOfWeekAsString DayOfYear DaysInMonth DaysInYear Parameters Usage When passing a date time value as a string you must enclose it in quotation marks Otherwise it i...

Page 477: ...ons Function syntax Fix number See also Ceiling Int Round Parameters Example h3 Fix Example h3 p Fix returns the closest integer less than the number if the number is greater than or equal to 0 Fix re...

Page 478: ...e base specified by Radix p cfoutput br FormatBaseN 10 2 FormatBaseN 10 2 br FormatBaseN 1024 16 FormatBaseN 1024 16 br FormatBaseN 125 10 FormatBaseN 125 10 br FormatBaseN 10 75 2 FormatBaseN 10 75 2...

Page 479: ...Applications in Developing ColdFusion MX Applications History ColdFusion MX Added this function Usage This function works with cflogin authentication or web server authentication It checks for a logge...

Page 480: ...cenumber See also GetBaseTagList Parameters Example This example shows the use of GetBaseTagData function Typically used in custom tags cfif trim inCustomTag neq cfoutput Running in the context of a c...

Page 481: ...se cfdefaultcase cftry cfcatch This function displays the following tags only under the following conditions cfloop if it uses a query attribute cfoutput if at least one of its children is a complex e...

Page 482: ...eturns The absolute path of the application base page as a string Category Other functions System functions Function syntax GetBaseTemplatePath See also GetCurrentTemplatePath FileExists ExpandPath Ex...

Page 483: ...GetClientVariablesList Example h3 p This view only example deletes a client variable called User_ID if it exists in the list of client variables returned by GetClientVariablesList p This example requi...

Page 484: ...eExists ExpandPath Usage If the function call is made from a page included with a cfinclude tag this function returns the page path of an included page Contrast this with the GetBaseTemplatePath funct...

Page 485: ...eExists ExpandPath yourfile p Your file exists in this directory You entered the correct file name GetFileFromPath thisPath yourfile cfelse p Your file was not found in this directory br Here is a lis...

Page 486: ...486 Chapter 3 ColdFusion Functions input type Submit NAME form...

Page 487: ...e current page The default encoding if none has been explicitly set is UTF 8 For more information see www iana org assignments character sets Example This example sends the contents of two fields and...

Page 488: ...the exception object To get the current exception object you must call GetException on the Java object before other methods are invoked on it Example Create the Java object reference cfobject action c...

Page 489: ...is not cfset yourFile FORM yourFile cfif FileExists ExpandPath yourfile p Your file exists in this directory You entered the correct file name GetFileFromPath thisPath yourfile cfelse p Your file was...

Page 490: ...lable in ColdFusion Returns A structure of functions Category System functions Function syntax GetFunctionList Example This example shows the use of GetFunctionList cfset fList GetFunctionList cfoutpu...

Page 491: ...equestData cfoutput table cellpadding 2 cellspacing 2 tr td b HTTP Request item b td td b Value b td tr cfloop collection x headers item http_item tr td http_item td td StructFind x headers http_item...

Page 492: ...492 Chapter 3 ColdFusion Functions b http_content x content b cfoutput...

Page 493: ...ategory Date and time functions International functions Function syntax GetHttpTimeString date_time_object See also GetLocale GetTimeZoneInfo SetLocale Parameters Usage The time in the returned string...

Page 494: ...ng time Avoid using it in production applications This function uses Verity K2Server Release K2 2 0 Returns The number of collection metadata items stored in Verity collections Category Full text sear...

Page 495: ...rverDocCount History ColdFusion MX 6 1 Deprecated this function It might not work and it might cause an error in later releases ColdFusion MX Added this function Usage If a search generates a larger n...

Page 496: ...licitly set ColdFusion now determines whether the default locale of the ColdFusion server computer operating system is among the locale values it supports The default locale is stored in the user envi...

Page 497: ...d to read and write variables that are present during the life of the component Component metadata contains at least the following keys name the component name path an absolute path to the component e...

Page 498: ...498 Chapter 3 ColdFusion Functions Property metadata contains at least the following key name the property name Other property attributes are returned as additional keys...

Page 499: ...an integer value that is computed from the state of the server s internal queues Indicates the overall server load prev_req_time Returns the time in milliseconds that it took the server to process the...

Page 500: ...ReqTimedOut Number of HTTP requests that timed out while in the staging queue or during processing BytesIn Number of bytes in HTTP requests to ColdFusion MX BytesOut Number of bytes in HTTP responses...

Page 501: ...methods that can be useful in J2EE integration It includes the include and forward methods that provide the equivalent of the corresponding standard JSP tags You use these methods to call JSP pages an...

Page 502: ...32 ini Returns An initialization file as a struct whose format is as follows Each initialization file section name is a key in the struct Each list of entries in a section of an initialization file is...

Page 503: ...lization file Enter the full path of your initialization file and submit the form If the form was submitted it gets the initialization path and timeout value specified in the form cfif Isdefined Form...

Page 504: ...504 Chapter 3 ColdFusion Functions tr table form...

Page 505: ...ncluding a trailing slash as a string Category System functions Function syntax GetTempDirectory See also GetTempFile History ColdFusion MX Changed behavior on Windows this function now returns the te...

Page 506: ...System functions Function syntax GetTempFile dir prefix See also GetTempDirectory Parameters Example h3 GetTempFile Example h3 p The temporary directory for this ColdFusion Server is cfoutput GetTempD...

Page 507: ...ption 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...

Page 508: ...egments or other page processing elements The value of the counter has no meaning To generate useful timing values take the difference between the results of two GetTickCount calls Example Setup timin...

Page 509: ...zone east of UTC such as a zone in Germany utcHourOffset offset in hours of local time from UTC utcMinuteOffset offset in minutes beyond the hours offset For North America this is 0 For countries tha...

Page 510: ...wn red three 2 This function call requests element number 2 from the string using the delimiter The output is as follows red black tan Example B Consider the following code cfset mystring four chr 32...

Page 511: ...omitted so the function uses the space character as the string delimiter br cfoutput GetToken mystring 3 is GetToken mystring 3 cfoutput br The output of this code is as follows GetToken mystring 3 i...

Page 512: ...yourString set delimiter cfif FORM yourDelimiter is not cfset yourDelimiter FORM yourDelimiter cfelse cfset yourDelimiter cfif check whether number of elements in list is greater than or equal to the...

Page 513: ...exposing the password The developer can check the validity of the password with the following code cfif hash form password is not myQuery passwordHash cflocation url unauthenticated cfm cfif Example...

Page 514: ...e 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 Example This example shows the use of H...

Page 515: ...d Mid for example against the expanded string The only difference between this function and HTMLEditFormat is that HTMLEditFormat does not surround the text in an HTML pre tag Example This example sho...

Page 516: ...xpanded string The only difference between this function and HTMLCodeFormat is that HTMLCodeFormat surrounds the text in an HTML pre tag Example This example shows the effects of HTMLCodeFormat and HT...

Page 517: ...rameters Usage The IIf function is a shortcut for the following construct cfif condition cfset result Evaluate string_expression1 cfelse cfset result Evaluate string_expression2 cfif The expressions s...

Page 518: ...ple LocalVar is undefined however if you omit pound signs around LocalVar the code works properly cfoutput IIf IsDefined LocalVar LocalVar DE The variable is not defined cfoutput The output is The var...

Page 519: ...IIf 519 cfoutput b...

Page 520: ...syntax IncrementValue number See also DecrementValue Parameters Example h3 IncrementValue Example h3 p Returns the integer part of a number incremented by one p IncrementValue 0 cfoutput IncrementValu...

Page 521: ...seN 1024 16 FormatBaseN 1024 16 br FormatBaseN 125 10 FormatBaseN 125 10 br FormatBaseN 10 75 2 FormatBaseN 10 75 2 cfoutput h3 InputBaseN Example h3 p InputBaseN returns the number obtained by conver...

Page 522: ...ition GT Len MyString cfoutput p This string only has Len MyString characters therefore you cannot insert the substring FORM mySubString at position FORM insertPosition cfoutput cfif cfelse cfoutput p...

Page 523: ...functions Function syntax Int number See also Ceiling Fix Round Parameters Example h3 Int Example h3 p Int returns the closest integer smaller than a number p Int 11 7 cfoutput Int 11 7 cfoutput p In...

Page 524: ...rlier releases it returns False Changed behavior this function can be used on XML objects Parameters Usage This function evaluates a Java array object such as vector object as having one dimension Exa...

Page 525: ...solete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX This function is obsole...

Page 526: ...nction is obsolete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX This functi...

Page 527: ...ASCII table b br br cfoutput htmleditformat charData cfoutput br br Create a Base 64 representation of this string cfset data64 toBase64 charData Convert string to binary cfset binaryData toBinary da...

Page 528: ...h3 IsBoolean Example h3 cfif IsDefined FORM theTestValue cfif IsBoolean FORM theTestValue h3 The expression cfoutput DE FORM theTestValue cfoutput is Boolean h3 cfelse h3 The expression cfoutput DE FO...

Page 529: ...tions always precede IsCustomFunction with an IsDefined test as shown in the example Example h3 IsCustomFunction Example h3 cfscript function realUDF return 1 cfscript cfset X 1 Example that fails exi...

Page 530: ...530 Chapter 3 ColdFusion Functions IsCustomFunction myTestCFCobject testFunc myTestCFCobject testFunc is a function CFIF...

Page 531: ...hecks against U S date formats only For other date support see LSDateFormat A date time object falls in the range 100 AD 9999 AD Example h3 IsDate Example h3 cfif IsDefined FORM theTestValue cfif IsDa...

Page 532: ...Decision functions Function syntax IsDebugMode See also cfsetting Description If debugging output is enabled in ColdFusion Administrator and has not been overridden by setting the cfsetting tag showDe...

Page 533: ...ith dot notation for example mystruct key Parameters Usage When working with scopes that ColdFusion exposes as structures the StructKeyExists function can sometimes replace this function The following...

Page 534: ...534 Chapter 3 ColdFusion Functions input type Submit name form...

Page 535: ...es Verity K2Server Release K2 2 0 Returns True if K2Broker is in configured with ColdFusion False otherwise Category Decision functions Full text search functions Query functions Function syntax IsK2S...

Page 536: ...Verity and K2Server Administrator pages This function uses Verity K2Server Release K2 2 0 Returns True if the document count limit is exceeded False otherwise Category Decision functions Full text sea...

Page 537: ...on uses Verity K2Server Release K2 2 0 Returns True if the K2Server is available to perform a search False otherwise Category Decision functions Full text search functions Query functions Function syn...

Page 538: ...cfif IsDefined FORM theTestValue cfif IsLeapYear FORM theTestValue h3 The year value cfoutput DE FORM theTestValue cfoutput is a Leap Year h3 cfelse h3 The year value cfoutput DE FORM theTestValue cfo...

Page 539: ...3 IsNumeric Example h3 cfif IsDefined FORM theTestValue cfif IsNumeric FORM theTestValue h3 The string cfoutput DE FORM theTestValue cfoutput can be converted to a number h3 cfelse h3 The string cfout...

Page 540: ...s which are real numbers Example h3 IsNumericDate Example h3 cfif IsDefined form theTestValue test if the value represents a number or a pre formatted Date value cfif IsNumeric form theTestValue or Is...

Page 541: ...ion returns False for query and XML objects Example to use this example create a color cfc component as follows cfcomponent cffunction name myFunction access public returntype string Create a structur...

Page 542: ...542 Chapter 3 ColdFusion Functions cfif cfif...

Page 543: ...obsolete Use the newer security tools see Authentication functions on page 367 and Chapter 16 Securing Applications in Developing ColdFusion MX Applications History ColdFusion MX This function is obso...

Page 544: ...is run the value of GetEmployees is cfoutput GetEmployees cfoutput cfif IsSimpleValue GetEmployees p GetEmployees is currently a simple value cfif make a query on the snippets datasource cfquery name...

Page 545: ...y is run the value of GetEmployees is cfoutput GetEmployees cfoutput cfif IsSimpleValue GetEmployees p GetEmployees is currently a simple value cfif make a query on the snippets datasource cfquery nam...

Page 546: ...y StructNew StructClear and StructDelete It is an example of a custom tag used to add employees Employee information is passed through the employee structure the EMPINFO attribute In UNIX you must als...

Page 547: ...IsStruct 547 cfcase cfswitch...

Page 548: ...curing Applications in Developing ColdFusion MX Applications History ColdFusion MX Added this function Parameters Usage Role names are case sensitive To check if a user is in multiple roles specify th...

Page 549: ...error Parameters Usage This function processes a WDDX packet with a validating XML parser which uses the WDDX Document Type Definition DTD To prevent CFWDDX deserialization errors you can use this fu...

Page 550: ...550 Chapter 3 ColdFusion Functions IsWDDX returns IsWDDX packet br cfoutput...

Page 551: ...ue if the function argument is an XML document object False otherwise Category Decision functions XML functions Function syntax IsXmlDoc value See also IsXmlElem IsXmlRoot XmlChildPos XmlNew XmlParse...

Page 552: ...turns True if the function argument is an XML document object element False otherwise Category Decision functions XML functions Function syntax IsXmlElem value See also IsXmlDoc IsXmlRoot XmlChildPos...

Page 553: ...True if the function argument is the root object of an XML document object False otherwise Category Decision functions XML functions Function syntax IsXmlRoot value See also IsXmlDoc IsXmlElem XmlChil...

Page 554: ...e data type not because the method can take a variable number of arguments JavaCast cannot be used to cast between complex objects nor to cast to a super class Use this function s result only on calls...

Page 555: ...sion can treat this as a string or a real number cfset x 33 Perform an explicit cast to an int and call fooMethod br cfset myInt JavaCast int x cfoutput obj fooMethod myInt cfoutput br br Perform an e...

Page 556: ...you can put arbitrary strings safely into JavaScript Example This example shows the use of the JSStringFormat function h3 JSStringFormat h3 cfset stringValue An example string value with a tab chr 8 a...

Page 557: ...fined FORM sampleText cfif FORM sampleText is not p Your text cfoutput FORM sampleText cfoutput returned in lowercase is cfoutput LCase FORM sampleText cfoutput cfelse p Please enter some text cfif cf...

Page 558: ...removeChars cfoutput leftmost characters of this string because it is not long enough cfelse p Your original string cfoutput form myText cfoutput p Your changed string showing only the cfoutput form r...

Page 559: ...Left 559 option value 9 9 select input type Submit name Remove characters form...

Page 560: ...en calculating a length some string processing functions processed the ASCII 0 NUL character but did not process subsequent characters of the string Parameters Example h3 Len Example h3 cfif IsDefined...

Page 561: ...is 0 cfset myList MyValue cfelse cfset myList myList MyValue cfif The following table shows examples of ListAppend processing Example h3 ListAppend Example h3 First query to get some values for our l...

Page 562: ...nfo datasource cfsnippets SELECT PARKNAME CITY STATE FROM PARKS WHERE PARKNAME LIKE AL cfquery cfset temp ValueList GetParkInfo ParkName cfoutput p The original list temp cfoutput now append a park na...

Page 563: ...ERE PARKNAME LIKE BA CFQUERY CFSET temp ValueList GetParkInfo ParkName cfoutput p The original list p temp cfoutput Change the delimiters in the list CFSET temp2 ListChangeDelims Temp P cfoutput p Aft...

Page 564: ...nbsp nbsp Substring wo is in B element ListContains aList wo B of list cfoutput p ListFind cannot check for a substring within an element therefore in the code it does not find substring wo it returns...

Page 565: ...ListContains 565 cfoutput The string two is in b element ListFind aList two b of the list cfoutput...

Page 566: ...et some values for our list cfquery name GetParkInfo datasource cfsnippets SELECT PARKNAME CITY STATE FROM Parks WHERE PARKNAME LIKE form letter cfquery cfset tempList ValueList GetParkInfo City cfif...

Page 567: ...ome values for our list elements CFQUERY NAME GetParkInfo DATASOURCE cfsnippets SELECT PARKNAME CITY STATE FROM Parks WHERE PARKNAME LIKE CHI CFQUERY CFSET temp ValueList GetParkInfo ParkName CFSET de...

Page 568: ...568 Chapter 3 ColdFusion Functions p The changed list temp2 p I This list element br deleted_element br is no longer present at position three of the list I cfoutput...

Page 569: ...Leary p Pick a search type select name type option value ListFind selected Case Sensitive option value ListFindNoCase Case Insensitive select input type Submit name value Search Employee List form wai...

Page 570: ...at ListGetAt ValueList SearchEmpLastName Phone temp p This was the first employee found under this case sensitive last name search cfoutput cfif cfelse cfset temp ListFindNoCase myList form myString c...

Page 571: ...ch type select name type option value ListFind selected Case Sensitive option value ListFindNoCase Case Insensitive select input type Submit name value Search Employee List form wait to have a string...

Page 572: ...rchEmpLastName Phone temp p This was the first employee found under this case sensitive last name search cfoutput cfif cfelse cfset temp ListFindNoCase myList form myString cfif temp is 0 h3 An employ...

Page 573: ...tMessageUser Username p Before editing the list it is nbsp cfoutput ValueList GetMessageUser Username cfoutput p Users who posted more than once are listed more than once Show the first user in the li...

Page 574: ...e MyValue two hundred not two hundred and spaces within a list element are preserved ColdFusion ignores empty list elements thus the list a b c d has four elements Example h3 ListGetAt Example h3 Find...

Page 575: ...ListGetAt 575 cfloop From 1 To ListLen temp index Counter cfoutput li Username Counter ListGetAt temp Counter cfoutput cfloop ul...

Page 576: ...ts Example This example shows ListInsertAt cfquery name GetParkInfo datasource cfsnippets SELECT PARKNAME CITY STATE FROM PARKS WHERE PARKNAME LIKE DE cfquery cfset temp ValueList GetParkInfo ParkName...

Page 577: ...eserved ColdFusion ignores empty list elements thus the list a b c d has four elements Example h3 ListFirst ListLast and ListRest Example h3 Find a list of users who wrote messages cfquery name GetMes...

Page 578: ...578 Chapter 3 ColdFusion Functions p Users who posted more than once are listed more than once p The last user in the list is cfoutput ListLast temp cfoutput...

Page 579: ...essageUser Username loop through the list and show it with ListGetAt h3 This is a list of usernames who have posted messages cfoutput ListLen temp cfoutput users h3 ul cfloop From 1 TO ListLen temp IN...

Page 580: ...sion returns the contents of the value parameter To add an element to the beginning or end of a list Macromedia recommends that you do so with code such as the following rather than with the ListAppen...

Page 581: ...ListPrepend 581 cfset first_element ListFirst temp cfoutput p The original list temp cfoutput now insert an element at position 1 cfset temp2 ListPrepend Temp my Inserted Value...

Page 582: ...es datasource cfsnippets SELECT FirstName LastName FROM Employees cfquery h3 ListQualify Example h3 p This example uses ListQualify to put the full names of the employees in the query within quotation...

Page 583: ...ach full name cfset qualifiedList1 ListQualify myList CHAR output the array as a list cfoutput p The contents of the qualified list are as follows p p qualifiedList1 p cfoutput show the resulting alph...

Page 584: ...datasource cfsnippets SELECT Username Subject Posted FROM Messages cfquery cfset temp ValueList GetMessageUser Username p Before editing the list it is nbsp cfoutput ValueList GetMessageUser Username...

Page 585: ...if delimiters was omitted a comma ColdFusion ignores empty list elements thus the list a b c d has four elements Example h3 ListSetAt Example h3 Find a list of users who wrote messages cfquery name G...

Page 586: ...temp 2 cfset TempToo ListSetAt temp 2 I changed this subject ul cfloop From 1 To ListLen temptoo INDEX Counter cfoutput li Counter SUBJECT ListGetAt temptoo Counter cfoutput cfloop ul p Note that elem...

Page 587: ...ation ensures that an ascending and descending sort output elements in exactly reverse order For example in a textnocase desc sort of d a a b A the following occurs ColdFusion MX returns d b A a a Ear...

Page 588: ...ically since it contains negative and positive numbers and decimal numbers p cfset sortedNums2 ListSort 23 75 34 471 100 9745 Numeric ASC cfoutput sortedNums2 cfoutput p Here is a list to be sorted al...

Page 589: ...er a comma plus sign Example h3 ListToArray Example h3 Find a list of users who wrote messages cfquery name GetMessageUser datasource cfsnippets SELECT Username Subject Posted FROM Messages cfquery cf...

Page 590: ...luecount cfm p Select a department p select name departmentName option value Accounting Accounting OPTION option value Administration Administration OPTION option value Engineering Engineering OPTION...

Page 591: ...epartment ListValueCount myList FORM departmentName cfif numberInDepartment is 0 h3 There are no employees in cfoutput FORM departmentName cfoutput h3 cfelseIf numberInDepartment is 1 cfoutput p There...

Page 592: ...rm action listvaluecountnocase cfm p Select a department p select name departmentName option value Accounting Accounting OPTION option value Administration Administration OPTION option value Engineeri...

Page 593: ...rtment cfset numberInDepartment ListValueCountNoCase myList FORM departmentName cfif numberInDepartment is 0 h3 There are no employees in cfoutput FORM departmentName cfoutput h3 cfelseIf numberInDepa...

Page 594: ...Justify cfparam name jstring default cfif IsDefined FORM justifyString cfset jstring LJustify FORM justifyString 35 cfif html head title LJustify Example title head body h3 LJustify Function h3 p Ente...

Page 595: ...sitive real number to get its natural logarithm cfelse br The natural logarithm of FORM number log FORM number cfif cfif FORM number LTE 0 br Enter a positive real number to get its logarithm to base...

Page 596: ...e the natural logarithm of that number cfelse br The natural logarithm of FORM number log FORM number cfif cfif FORM number LTE 0 br You must enter a positive real number to see the logarithm of that...

Page 597: ...orms Parameters Usage This function uses Java standard locale formatting rules on all platforms Note With a Sun 1 3 1 compliant JVM use the LSEuroCurrencyFormat function to format euro currency values...

Page 598: ...ustrian 100 000 00 S 100 000 00 EUR100 000 00 ATS100 000 00 100 000 00 German Standard 100 000 00 100 000 00 DM EUR100 000 00 DEM100 000 00 100 000 00 German Swiss SFr 100 000 00 CHF100 000 00 100 000...

Page 599: ...ormat returns a currency value using the locale convention Default value is local loop through list of locales show currency values for 100 000 units cfloop LIST Server Coldfusion SupportedLocales ind...

Page 600: ...Parameter Description date A date time object in the range 100 AD 9999 AD mask Characters that show how ColdFusion displays the date d Day of month Digits no leading zero for single digit days dd Day...

Page 601: ...rmats the date part of a date time value using the locale convention loop through a list of locales show date values for Now cfloop list Server Coldfusion SupportedLocales index locale delimiters cfse...

Page 602: ...country of the current locale belongs to the Euro Zone whose members have converted to the euro the formatted output for the local type includes the Euro currency sign for the international type the o...

Page 603: ...an 100 000 00 EUR100 000 00 100 000 00 French Canadian 100 000 00 CAD100 000 00 100 000 00 French Standard 100 000 00 EUR100 000 00 100 000 00 French Swiss SFr 100 000 00 CHF100 000 00 100 000 00 Germ...

Page 604: ...y value using the locale convention Default value is local Loop through list of locales show currency values for 100 000 units cfloop list Server Coldfusion SupportedLocales index locale delimiters cf...

Page 605: ...at shows differences between earlier ColdFusion releases and ColdFusion MX in accepting input formats and displaying output see LSCurrencyFormat on page 597 Note If the locale belongs to a Euro zone c...

Page 606: ...606 Chapter 3 ColdFusion Functions p form action LSIsCurrency cfm p Select a locale for which you would like to check a currency value check the current locale for server cfset serverLocale GetLocale...

Page 607: ...for example LsIsDate 3 1 2002 in any other locale this function returns False Earlier releases returned True Changed behavior when using the SUN JRE 1 3 1 on an English UK locale this function return...

Page 608: ...608 Chapter 3 ColdFusion Functions check the current locale for server cfset serverLocale GetLocale...

Page 609: ...eleases This function uses Java standard locale formatting rules on all platforms Parameters Usage To set the default display format of date time number and currency values use the SetLocale function...

Page 610: ...ber or threw an error If no mask is specified ColdFusion MX truncates the decimal part as ColdFusion 5 does For example it truncates 1234 567 to 1235 Changed formatting behavior this function might re...

Page 611: ...ar right and far right The left and right positions are determined by the side of the decimal point on which the code character is shown For formats that do not have a fixed number of decimal places y...

Page 612: ...99999999999999999999999999 where the last decimal is 10E 14 the rounding factor can cause an incorrect result Example h3 LSNumberFormat Example h3 p LSNumberFormat returns a number value using the loc...

Page 613: ...equires that the local and international versions of currencies of countries in the Euro zone be formatted using the older country specific designations such as 100 000 00 DM or DEM100 000 00 for the...

Page 614: ...I B br Local LSCurrencyFormat 123456 78 local br Parsed local Currency LSParseCurrency LSCurrencyFormat 123456 local br International LSCurrencyFormat 123456 78999 international br Parsed Internation...

Page 615: ...er value time zone information differently than in earlier releases as described in the Usage section Parameters Usage This function can parse any date time or date time combination that conforms to J...

Page 616: ...t the time value Note This function does not accept POP dates which include a time zone offset value Example h3 LSParseDateTime Example returns a locale specific date time object h3 loop through a lis...

Page 617: ...to the euro if so the currency string parameter must be formatted in euros on all JVMs including Sun JVM 1 3 1 If the country is not in the Euro zone the string must follow the locale formatting rule...

Page 618: ...International currency formatting IntlCurrency br Parsed using LSParseEuroCurrency LSParseEuroCurrency IntlCurrency br cfset Currency LSEuroCurrencyFormat 123456 none Value with no currency formattin...

Page 619: ...umber and currency values use the SetLocale function Example h3 LSParseNumber Example h3 p LSParseNumber converts a locale specific string to a number Returns the number matching the value of string l...

Page 620: ...620 Chapter 3 ColdFusion Functions cfoutput cfloop...

Page 621: ...ertible to a time value A date time object is in the range 100 AD 9999 AD mask Masking characters that determine the format h Hours no leading zero for single digit hours 12 hour clock hh Hours leadin...

Page 622: ...onds value is passed to this function and the mask value is s the default output seconds format is one zero for example lstimeformat 6 39 h m s returns 6 39 0 If the mask value is ss it returns 6 39 0...

Page 623: ...se64 Parameters Example h3 LTrim Example h3 cfif IsDefined FORM myText cfoutput pre Your string FORM myText Your string LTrim FORM myText left trimmed pre cfoutput cfif form action ltrim cfm p Type in...

Page 624: ...Num1 and IsNumeric FORM myNum2 p The maximum of the two numbers is cfoutput Max FORM myNum1 FORM myNum2 cfoutput p The minimum of the two numbers is cfoutput Min FORM myNum1 FORM myNum2 cfoutput cfels...

Page 625: ...utput the cfoutput FORM removeChars cfoutput middle characters of this string because it is not long enough cfelse p Your original string cfoutput FORM myText cfoutput p Your changed string showing on...

Page 626: ...IsNumeric FORM myNum2 p The maximum of the two numbers is cfoutput Max FORM myNum1 FORM myNum2 cfoutput p The minimum of the two numbers is cfoutput Min FORM myNum1 FORM myNum2 cfoutput cfelse p Plea...

Page 627: ...sh Second 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 Example h3 Min...

Page 628: ...the date parameter of this function for example Month CreateDate 2001 3 3 Example h3 Month Example h3 cfif IsDefined FORM year More information about your date cfset yourDate CreateDate FORM year FOR...

Page 629: ...bout your date cfset yourDate CreateDate FORM year FORM month FORM day cfoutput p Your date DateFormat yourDate br It is DayofWeekAsString DayOfWeek yourDate day DayOfWeek yourDate in the week br This...

Page 630: ...OfMonth Returns A date time object the current date and time of the computer running the ColdFusion server Category Date and time functions Function syntax Now See also CreateDateTime DatePart Example...

Page 631: ...nds the decimal part as ColdFusion 5 does For example it rounds 34 567 to 35 Parameters The following table explains mask characters Parameter Description number A number mask A string or a variable t...

Page 632: ...formats The positioning can also show where to place the minus sign for negative numbers The positions for a symbol are far left near left near right and far right The left and right positions are det...

Page 633: ...e of 1 28 If you round off a double such as 1 99499999999999999999999999999 where the last decimal is 10E 14 the rounding factor can cause an incorrect result To set the default display format of date...

Page 634: ...elds Example h3 ParagraphFormat Example h3 p Enter text into this textarea and see it returned as HTML cfif IsDefined FORM myTextArea p Your text area formatted p cfoutput ParagraphFormat FORM myTextA...

Page 635: ...on 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 wo...

Page 636: ...and currency values use the SetLocale function Note This function does not accept POP dates Example h3 ParseDateTime Example h3 cfif IsDefined form theTestValue cfif IsDate form theTestValue h3 The ex...

Page 637: ...ScriptName method POST p Enter an expression and discover if it can be evaluated to a date value input type Text name TheTestValue value CFOUTPUT DateFormat Now TimeFormat Now CFOUTPUT input type Subm...

Page 638: ...79 Category Mathematical functions Function syntax Pi See also ASin Cos Sin Tan Example h3 Pi Example h3 By default ColdFusion displays only 11 significant digits Use NumberFormat to display all 15 Th...

Page 639: ...ble reference until runtime This prevents errors that result from the evaluation of a single quote or apostrophe data character for example Joe s Diner as a delimiter Example A Consider this code cfse...

Page 640: ...ancisco and San Diego using the SQL grammar IN to modify a WHERE clause rather than looping through the result set after the query is run cfset List Suisun San Francisco San Diego cfquery name GetCent...

Page 641: ...so DatePart Month 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 Exampl...

Page 642: ...as queries retrieved with the cfquery tag or queries created with the QueryNew function You cannot us the QueryAddColumn function on a cached query Useful for generating a query object from the array...

Page 643: ...1 cfset HealthFoodArray 1 Bean Curd cfset HealthFoodArray 2 Yogurt cfset HealthFoodArray 3 Tofu add a third column to the query cfset nColumnNumber3 QueryAddColumn myQuery HealthFood HealthFoodArray...

Page 644: ...query p The Query GetCourses has cfoutput GetCourses RecordCount cfoutput rows cfset CountVar 0 cfloop CONDITION CountVar LT 15 cfset temp QueryAddRow GetCourses cfset CountVar CountVar 1 cfset Temp Q...

Page 645: ...ddress phone make some rows in the query cfset newRow QueryAddRow MyQuery 2 set the cells in the query cfset temp QuerySetCell myQuery name Fred 1 cfset temp QuerySetCell myQuery address 9 Any Lane 1...

Page 646: ...Courses cfquery p The Query GetCourses has cfoutput GetCourses RecordCount cfoutput rows cfset CountVar 0 cfloop CONDITION CountVar LT 15 cfset temp QueryAddRow GetCourses cfset CountVar CountVar 1 c...

Page 647: ...get the department IDs in our list cfquery name GetDepartments datasource cfsnippets SELECT Dept_ID FROM Departments WHERE Dept_ID IN PreserveSingleQuotes List cfquery now select the courses for that...

Page 648: ...nge 0 1 Category Mathematical functions Function syntax Rand See also Randomize RandRange Usage To ensure greater randomness call the Randomize function before calling Rand Example h3 Rand Example h3...

Page 649: ...er it is not a random number Example h3 Randomize Example h3 p Call Randomize to seed the random number generator This helps to ensure the randomness of numbers generated by Rand cfif IsDefined FORM m...

Page 650: ...RandRange returns an integer between two specified integers cfif IsDefined FORM myInt p RandRange returned cfoutput RandRange FORM myInt FORM myInt2 cfoutput cfif cfform action randRange cfm p Enter...

Page 651: ...ows If the regular expression is found in the string the first element of the len and pos arrays contains the length and position respectively of the first match of the entire regular expression If th...

Page 652: ...rns the position and length of the first occurrence of a regular expression in a string starting from the specified position The position and length variables are stored in a structure To access posit...

Page 653: ...e position and length of the first instance of each parenthesized subexpression within is included in additional array elements p p For example lt CFSET st1 REFind alpha 1 testString 1 TRUE gt p cfset...

Page 654: ...is found in the string the first element of the len and pos arrays contains the length and position respectively of the first match of the entire regular expression If the regular expression contains...

Page 655: ...i returnssubexpression i parameter REFindNoCase returns the position and length of the first occurrence of a regular expression in a string starting from the specified position The position and lengt...

Page 656: ...n and length of the first instance of the whole expression The position and length of the first instance of each subexpression within will be included in additional array elements p p For example lt C...

Page 657: ...as a quit method that terminates the program call this method before you call the ReleaseComObject function This function can improve processing efficiency but is not required for an application to w...

Page 658: ...urns 0 if no characters are found cfif IsDefined FORM myString cfif FORM numChars FORM start GT Len FORM myString p Your string is only cfoutput Len FORM myString cfoutput characters long Please enter...

Page 659: ...3 p RepeatString returns a string created from I string I repeated a specified number of times ul li RepeatString 10 cfoutput RepeatString 10 cfoutput li RepeatString lt BR gt 3 cfoutput RepeatString...

Page 660: ...azy cow dog and cat All Example h3 Replace Example h3 p The Replace function returns I string I with I substring1 I replaced by I substring2 I in the specified scope This is a case sensitive search cf...

Page 661: ...string cfoutput FORM MyString cfoutput p You wanted to replace the substring cfoutput FORM MySubstring1 cfoutput with the substring cfoutput FORM MySubstring2 cfoutput p The result cfoutput Replaceli...

Page 662: ...662 Chapter 3 ColdFusion Functions replacelist stringtoreplace dog brown fox black cow black ferret white cfoutput...

Page 663: ...the specified scope The search replace is case insensitive cfif IsDefined FORM MyString p Your original string cfoutput FORM MyString cfoutput p You wanted to replace the substring cfoutput FORM MySu...

Page 664: ...ing scope See also REFind Replace ReplaceList REReplaceNoCase History ColdFusion MX Added supports for the following special codes in a replacement substring to control case conversion u uppercase the...

Page 665: ...p REReplace CABARET C B G ALL cfoutput REReplace CABARET C B G ALL cfoutput p REReplace CABARET A Z G ALL cfoutput REReplace CABARET A Z G ALL cfoutput p REReplace I love jellies jell y ies cookies c...

Page 666: ...usion 5 application you must insert a backslash before it for example change u to u Parameters Usage For details on using regular expressions see Chapter 7 Using Regular Expressions in Functions in De...

Page 667: ...ReplaceNoCase 667 cfoutput REReplaceNoCase I LOVE JELLIES jell y ies cookies cfoutput p REReplaceNoCase I LOVE JELLY jell y ies cookies cfoutput REReplaceNoCase I LOVE JELLY jell y ies cookies cfoutpu...

Page 668: ...as the following cfoutput reverse 6 2 equals reverse 6 2 cfoutput This code outputs the following reverse 6 2 equals 21 Example h3 Reverse Example h3 p Reverse returns your string with the positions...

Page 669: ...0 then err cfif Len FORM myText is not 0 cfif Len FORM myText LTE FORM RemoveChars p Your string cfoutput FORM myText cfoutput only has cfoutput Len FORM myText cfoutput characters You cannot output t...

Page 670: ...ult cfif IsDefined FORM justifyString cfset jstring rjustify FORM justifyString 35 cfif html head title RJustify Example title head body h3 RJustify Function h3 p Enter a string It will be right justi...

Page 671: ...Ceiling Fix Int Parameters Example h3 Round Example h3 p This function rounds a number to the closest integer ul li Round 7 49 cfoutput Round 7 49 cfoutput li Round 7 5 cfoutput Round 7 5 cfoutput li...

Page 672: ...im Parameters Example h3 RTrim Example h3 cfif IsDefined FORM myText cfoutput pre Your string FORM myText Your string RTrim FORM myText right trimmed pre cfoutput cfif form action Rtrim cfm method pos...

Page 673: ...rs Usage When passing a date time object as a string you must enclose it in quotation marks Otherwise it is interpreted as a number representation of a date time object Example This example shows the...

Page 674: ...r the character encoding of a URL is not in UTF 8 encoding For example Traditional Chinese characters are often in Big5 encoding Before using URL or Form variables call this function typically in the...

Page 675: ...ally use in the SetEncoding charset parameter and other ColdFusion attributes and parameters Java automatically converts standard IANA names to its internal names as needed Example This example sends...

Page 676: ...Java standard locale determination and formatting rules on all platforms Deprecated the Spanish Mexican locale option It might not work and it might cause an error in later releases Changed the Spanis...

Page 677: ...uage specified by the Content Language header ColdFusion ignores any SetLocale functions that follow a cfflush tag Because this function returns the previous locale setting you can save the original l...

Page 678: ...ation path and timeout value to the path and timeout value specified in the form cfif Isdefined Form Submit cfset IniPath FORM iniPath cfset Section boot loader cfset MyTimeout FORM MyTimeout cfset ti...

Page 679: ...Loader h4 p Timeout is set to cfoutput timeout cfoutput p p Default directory is cfoutput default cfoutput p cfif form action setprofilestring cfm hr size 2 color 0000A0 table cellspacing 2 cellpaddin...

Page 680: ...variables To do so put the dynamically named variable in quotation marks and pound signs for example cfset DynamicVar2 ABD cfset DynamicVar2 Test Value2 Also the following lines are equivalent cfset...

Page 681: ...SetVariable 681 p Your variable varName p The value of varName is varNameValue cfoutput cfif...

Page 682: ...Mathematical functions Function syntax Sgn number See also Abs Parameters Example h3 Sgn Example h3 p Sgn determines the sign of a number Returns 1 if number is positive 0 if number is 0 1 if number...

Page 683: ...000000000001 Example h3 Sin Example h3 Calculate sine if form has been submitted cfif IsDefined FORM sinNum Make sure input is a number cfif IsNumeric FORM sinNum Convert degrees to radians call the S...

Page 684: ...684 Chapter 3 ColdFusion Functions br br input type Submit name nbsp nbsp input type RESET form...

Page 685: ...t FORM myString cfoutput p Your set of characters was cfoutput FORM mySet cfoutput p Your string up until one of the characters in the set is cfoutput SpanExcluding FORM myString FORM mySet cfoutput c...

Page 686: ...myString cfoutput p Your set of characters was cfoutput FORM mySet cfoutput p Your string until the characters in the set have been found is cfoutput SpanIncluding FORM myString FORM mySet cfoutput cf...

Page 687: ...Parameters Usage The value in number must be greater than or equal to 0 Example h3 Sqr Example h3 p Returns the square root of a positive number p Sqr 2 cfoutput Sqr 2 cfoutput p Sqr Abs 144 cfoutput...

Page 688: ...pCR Example h3 p Function StripCR is useful for preformatted HTML display of data PRE entered in textarea fields cfif isdefined Form myTextArea pre cfoutput StripCR Form myTextArea cfoutput pre cfif u...

Page 689: ...ruct2 overwrites it A structure s keys are unordered Example html body Create a Name structure cfset nameCLK StructNew cfset nameCLK first Chris cfset nameCLK middle Lloyd cfset nameCLK last Gilson Cr...

Page 690: ...em cfoutput myItem br cfoutput cfloop Merge the Name struct into the top level person struct cfset bSuccess StructAppend personCLK addrCLK Display the contents of the person struct after the Append p...

Page 691: ...4 5 5 x and ColdFusion MX Example Shows StructClear function Calls cf_addemployee custom tag which uses the addemployee cfm file body h1 Add New Employees h1 Establish params for first time through c...

Page 692: ...692 Chapter 3 ColdFusion Functions Call the custom tag that adds employees cf_addemployee empinfo employee cfscript StructClear employee cfscript cfif...

Page 693: ...at the top level cfoutput cfset assignedCopy StructNew cfset assignedCopy string struct string cfset assignedCopy number struct number cfset assignedCopy array ArrayNew 2 cfset assignedCopy array 1 1...

Page 694: ...s string br Array value br s array 1 1 s array 1 1 br s array 1 2 s array 1 2 br cfoutput Copy this structure to a new structure br cfset copied StructCopy s cfscript Change the values of the origina...

Page 695: ...ed string br Array values br s nested array 1 1 s nested array 1 1 br s nested array 1 2 s nested array 1 2 br cfoutput Use StructCopy to copy this structure to a new structure br cfset copied StructC...

Page 696: ...pied nested array 1 2 copied nested array 1 2 br cfoutput hr b Duplicated structure values should remain unchanged b br cfoutput Simple values br duplicated nested number duplicated nested number br d...

Page 697: ...appropriate place in addemployee cfm cfswitch expression ThisTag ExecutionMode cfcase value start cfif StructIsEmpty attributes EMPINFO cfoutput Error No employee data was passed cfoutput cfexit metho...

Page 698: ...fault Mary cfparam name lastname default Sante cfparam name email default msante allaire com cfparam name phone default 777 777 7777 cfparam name department default Documentation cfif IsDefined FORM D...

Page 699: ...r employee br cfoutput cfif br br form method post action CGI Script_Name p Select the field to be deleted nbsp select name field option value firstname first name option value lastname last name opti...

Page 700: ...ed through the employee structure EMPINFO attribute In UNIX you must also add the Emp_ID cfswitch expression ThisTag ExecutionMode cfcase value start cfif StructIsEmpty attributes EMPINFO cfoutput Err...

Page 701: ...that includes one structure for each of the specified values it finds The fields of each of these structures are Value value held in the found key Path string that can be used to reach the found key O...

Page 702: ...Usage The fields of each structure in the returned array are Key name of the key in which the value was found Path string which could be used to reach the found key Owner parent object that contains t...

Page 703: ...path Parameters Usage You can inadvertently create invalid structures using this function For example if array notation is used to expand an existing array the specified new element is created regard...

Page 704: ...s cfoutput cfset test StructGet request myscope 1 test cfset test foo 2 cfoutput request myscope 1 test foo br cfoutput cfset test StructGet request myscope 1 test 2 cfset test foo 3 cfoutput request...

Page 705: ...for first time through cfparam name FORM firstname default cfparam name FORM lastname default cfparam name FORM email default cfparam name FORM phone default cfparam name FORM department default cfif...

Page 706: ...custom tag that adds employees CF_ADDEMPLOYEE EMPINFO employee cfif Hr form action structinsert cfm p First Name nbsp input name firstname type text hspace 30 maxlength 30 p Last Name nbsp input name...

Page 707: ...tion is passed through employee structure EMPINFO attribute In UNIX you must also add the Emp_ID cfswitch expression ThisTag ExecutionMode cfcase value start cfif StructIsEmpty attributes EMPINFO cfou...

Page 708: ...loyee structure with user entries on form cfset employee StructNew cfif Isdefined Form Submit cfif Form Submit is OK cfset employee firstname FORM firstname cfset employee lastname FORM lastname cfset...

Page 709: ...ength 20 td tr tr td Company td td input name company type text value hspace 30 maxlength 30 td tr tr td input type submit name submit value OK td td b After you submit the FORM scroll down to see the...

Page 710: ...ys are unordered Example This example shows the use of StructKeyExists p This file is similar to addemployee cfm which is called by StructNew StructClear and StructDelete To test copy the LT CFELSEif...

Page 711: ...yee structure with what the user entered in the form cfset employee StructNew cfif Isdefined Form Submit cfif Form Submit is OK cfset employee firstname FORM firstname cfset employee lastname FORM las...

Page 712: ...e text value hspace 30 maxlength 30 td tr tr td EMail td td input name email type text value hspace 30 maxlength 30 td tr tr td Phone td td input name phone type text value hspace 20 maxlength 20 td t...

Page 713: ...param name FORM department default cfif FORM firstname EQ p Please fill out the form cfelse cfoutput cfscript employee StructNew StructInsert employee firstname FORM firstname StructInsert employee la...

Page 714: ...s function does not sort or change the structure Example cfscript salaries StructNew employees StructNew departments StructNew for i 1 i lt 6 i i 1 salary 120000 i 10000 salaries employee i salary emp...

Page 715: ...laries numeric DESC br p list of employees based on the salary subfield search br 7 ArrayToList StructSort employees numeric DESC salary br 8 ArrayToList StructSort employees text ASC salary br p list...

Page 716: ...StructDelete To test this file copy the LT CFELSEIF GT statement to the appropriate place in addemployee cfm It is an example of a custom tag used to add employees Employee information is passed thro...

Page 717: ...less than 0 0000000000001 To test for an infinite value check whether the value is more than 1E15 Example h3 Tan Example h3 Calculate tangent if form has been submitted cfif IsDefined FORM tanNum Mak...

Page 718: ...718 Chapter 3 ColdFusion Functions br input type Text name tanNum size 15 br br input type Submit name nbsp nbsp input type RESET form...

Page 719: ...usion MX Changed the way extra characters are processed this function processes extra characters within the mask value differently than in earlier releases as follows ColdFusion 5 and earlier the func...

Page 720: ...todayDate cfoutput p Using Timeformat we can display the value in different ways cfoutput ul li TimeFormat todayDate li TimeFormat todayDate hh mm ss li TimeFormat todayDate hh mm sst li TimeFormat t...

Page 721: ...Usage Base64 provides 6 bit encoding of data The encoding process represents 24 bit groups of input bits as output strings of 4 encoded ASCII characters Binary objects and in some cases 8 bit charact...

Page 722: ...index data from 32 to 255 cfset ch chr data cfset charData charData ch cfloop p The following string is the concatenation of all characters 32 to 255 from the ASCII table br cfoutput charData cfoutput...

Page 723: ...le file Example h3 ToBinary Example h3 Initialize data cfset charData Create a string of ASCII characters 32 255 concatenate them cfloop index data from 32 to 255 cfset ch chr data cfset charData char...

Page 724: ...724 Chapter 3 ColdFusion Functions cfelse h3 Conversion error h3 cfif...

Page 725: ...tion cannot convert a value it throws an exception This function can convert an XML document object to a string representation Note You can use this function to reverse Base64 encoding of a string Con...

Page 726: ...32 to 255 from the ASCII table br cfoutput charData cfoutput p Create a Base64 representation of this string cfset data64 toBase64 charData p The following string is the Base64 representation of the s...

Page 727: ...ers Example h3 Trim Example h3 cfif IsDefined FORM myText cfoutput pre Your string FORM myText Your string Trim FORM myText trimmed on both sides pre cfoutput cfif form action trim cfm p Type in some...

Page 728: ...cfif IsDefined FORM sampleText cfif FORM sampleText is not p Your text cfoutput FORM sampleText cfoutput returned in uppercase is cfoutput UCase FORM sampleText cfoutput cfelse p Please enter some tex...

Page 729: ...ed the charset parameter Parameters 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...

Page 730: ...ASCII character codes cfscript Build string s for c 1 c lte 256 c c 1 s s chr c Encode string and display result enc URLEncodedFormat s WriteOutput Encoded string is enc br Decode and compare result...

Page 731: ...ded the charset parameter Parameters 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...

Page 732: ...ple was passed from the previous link its value is br b cfoutput url myExample cfoutput b cfif p This function returns a URL encoded string cfset s My url encoded string has special characters other s...

Page 733: ...nds only required information when it is required and it is easier to code Returns A URL if cookies are disabled for the browser client and session data are appended Category Other functions Function...

Page 734: ...TestValue 0 Val TestValue returns the value 0 not an error Example h3 Val Example h3 cfif IsDefined FORM theTestValue cfif Val FORM theTestValue is not 0 h3 The string cfoutput DE FORM theTestValue c...

Page 735: ...3 use the contents of a query to create another dynamically cfquery name GetDepartments datasource cfsnippets SELECT Dept_ID FROM Departments WHERE Dept_ID IN BIOL cfquery cfquery name GetCourseList d...

Page 736: ...k Example h3 cfif IsDefined FORM year More information about your date cfset yourDate CreateDate FORM year FORM month FORM day cfoutput p Your date DateFormat yourDate br It is DayOfWeekAsString DayOf...

Page 737: ...ne on Windows If you specify the strip parameter all existing line breaks are removed so any paragraph formatting is lost Use this function to limit the length of text lines such as text to be include...

Page 738: ...the current SQL statement or mail text Do not use WriteOutput within cfquery and cfmail Although you can call this function anywhere within a page it is most useful inside a cfscript block Example cf...

Page 739: ...XmlChildPos XmlFormat XmlNew XmlParse XmlSearch XmlTransform History ColdFusion MX Added this function Parameters Usage The returned index can be used in the ArrayInsertAt and ArrayDeleteAt functions...

Page 740: ...information on this example see Chapter 31 Using XML and WDDX in Developing ColdFusion MX Applications cfset testVar True cfscript MyDoc XmlNew MyDoc xmlRoot XmlElemNew MyDoc MyRoot if testVar IS TRU...

Page 741: ...Added this function Parameters Usage The characters that this function escapes include the following Greater than symbol Less than symbol Single quotation mark Double quotation mark Ampersand symbol...

Page 742: ...yee name 1 and mydoc employee NAME 1 refer to the same element If caseSensitive yes these names refer to two distinct elements The following example creates and displays a ColdFusion document object F...

Page 743: ...XmlNew 743 cfscript cfdump var MyDoc...

Page 744: ...resented by a string variable use the XmlParse tag directly on the variable For example if your application uses cfhttp action get to get the XML document use the following code to create the XML docu...

Page 745: ...Usage XPath is specified by the World Wide Web Consortium For detailed information on XPath see the W3C website at www w3 org TR xpath Example The following example extracts the elements named last w...

Page 746: ...Chapter 31 Using XML and WDDX in Developing ColdFusion MX Applications Returns A string an XML document after the XSLT is applied Category Conversion functions Extensibility functions XML functions Fu...

Page 747: ...e information about your date cfset yourDate CreateDate FORM year FORM month FORM day cfoutput p Your date DateFormat yourDate br It is DayOfWeekAsString DayOfWeek yourDate day DayOfWeek yourDate in t...

Page 748: ...x YesNoFormat value See also IsBinary IsNumeric Parameters Example h3 YesNoFormat Example h3 p The YesNoFormat function returns non zero values as Yes zero values as No cfoutput ul li YesNoFormat 1 Ye...

Page 749: ...on C CFX Reference This chapter describes the CFXAPI classes and members Contents C class overview 750 Deprecated class members 750 CCFXException class 751 CCFXQuery class 753 CCFXRequest class 757 CC...

Page 750: ...CCFXRequest AddQuery CCFXRequest AttributeExists CCFXRequest CreateStringSet CCFXRequest Debug CCFXRequest GetAttribute CCFXRequest GetAttributeList CCFXRequest GetCustomData CCFXRequest GetQuery CCFX...

Page 751: ...eption and CCFXRequest ReThrowException Class members CCFXException GetError Description Provides basic user output for exceptions that occur during processing CCFXException GetDiagnostics Description...

Page 752: ...ceptions re raise them catch CCFXException e This is how you would pull the error information LPCTSTR strError e GetError LPCTSTR strDiagnostic e GetDiagnostics pRequest ReThrowException e Catch ALL o...

Page 753: ...w iCity St Paul pQuery SetData iRow iState MN pQuery SetData iRow iZip 55105 virtual int AddRow CCFXQuery AddRow adds a row to a query virtual CCFXStringSet GetColumns CCFXQuery GetColumns retrieves a...

Page 754: ...olumns int nNumColumns pColumns GetCount Print the list of columns to the user pRequest Write Columns in query for int i 1 i nNumColumns i pRequest Write pColumns GetString i pRequest Write CCFXQuery...

Page 755: ...XQuery GetName void Description Returns the name of a query Example The following example retrieves the name of a query and writes it back to the user CCFXQuery pQuery pRequest GetQuery pRequest Write...

Page 756: ...r call to SetData Parameters 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 Min...

Page 757: ...R lpszSettingName CCFXRequest GetSetting This member is deprecated It might not work and might cause an error in later releases virtual void Write LPCSTR lpszOutput CCFXRequest Write writes text outpu...

Page 758: ...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 CreateStringSet int iFirstName pColumns AddStr...

Page 759: ...NATION parameter in order for this tag to work correctly CCFXRequest CreateStringSet Syntax CCFXStringSet CCFXRequest CreateStringSet void Description Allocates and returns an instance Always use this...

Page 760: ...fo CCFXRequest GetAttribute Syntax LPCSTR CCFXRequest GetAttribute LPCSTR lpszName Description Retrieves the value of the passed attribute Returns an empty string if the attribute does not exist To te...

Page 761: ...st GetAttributeList int nNumAttribs pAttribs GetCount for int i 1 i nNumAttribs i lpszName pAttribs GetString i lpszValue pRequest GetAttribute lpszName pRequest Write lpszName pRequest Write pRequest...

Page 762: ...is completed 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 Thro...

Page 763: ...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...

Page 764: ...formed by the custom tag BOOL bMessageSent attempt to send the message if bMessageSent TRUE pRequest SetVariable MessageSent Yes else pRequest SetVariable MessageSent No CCFXRequest ThrowException Syn...

Page 765: ...the buffer with data and writes the output back to the user CHAR buffOutput 1024 wsprintf buffOutput The destination is s pRequest GetAttribute DESTINATION pRequest Write buffOutput CCFXRequest Write...

Page 766: ...eStringSet int iRed pSet AddString Red int iGreen pSet AddString Green int iBlue pSet AddString Blue CCFXStringSet GetCount Syntax int CCFXStringSet GetCount void Description Gets the number of string...

Page 767: ...ensitive Returns If the string is found its index within the string set is returned If it is not found the constant CFX_STRING_NOT_FOUND is returned Parameters Example The following example demonstrat...

Page 768: ...ollowing example demonstrates GetString with CCFXStringSet GetCount to iterate over a string set and write the contents of a list back to the user int nNumItems pStringSet GetCount for int i 1 i nNumI...

Page 769: ...hapter describes the Java interfaces available for building ColdFusion custom CFXs in Java Contents Overview class libraries 770 CustomTag interface 770 Query interface 772 Request interface 777 Respo...

Page 770: ...FX_MyCustomTag Other attributes can be passed to the Java CFX tag Their values are available using the Request object passed to the processRequest method Methods processRequest Description Processes a...

Page 771: ...est request Response response Throws Exception If an unexpected error occurs while processing the request Parameters Parameter Description request Parameters attributes query and so on for this reques...

Page 772: ...columns City State and Zip Define column indexes 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 5...

Page 773: ...il query getColumnIndex EMAIL Iterate over the query and output list of addresses int nRows query getRowCount for int iRow 1 iRow nRows iRow response write query getData iRow iEMail BR getColumns Desc...

Page 774: ...quested data element Category Query interface Syntax public String getData int iRow int iCol Throws IndexOutOfBoundsException If an invalid index is passed to the method See also setData addRow Parame...

Page 775: ...ublic int getRowCount 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 nu...

Page 776: ...xes 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 setDa...

Page 777: ...tag if not it throws an exception if request attributeExists DESTINATION throw new Exception Returns Syntax Description boolean attributeExists String name Checks whether the attribute was passed to...

Page 778: ...attribute is present and if so it writes a brief debug message if request debug response writeDebug debug info getAttribute Description Retrieves the value of a passed attribute Returns an empty strin...

Page 779: ...trieves the list of attributes then iterates over the list writing each attribute and its value back to the user String attribs request getAttributeList int nNumAttribs attribs length for int i 0 i nN...

Page 780: ...g the cfquery tag The query attribute is optional and should be used only by tags that process an existing dataset Returns the Query that was passed to the tag If no query was passed returns null Cate...

Page 781: ...share a registry key for storing settings To avoid name conflicts preface the names of settings with the name of your custom tag class For example the code below retrieves the value of a setting name...

Page 782: ...n If the name parameter is not a valid CFML variable name See also addRow setData Parameters Example The following example adds a query named People to the calling template The query has two columns F...

Page 783: ...variable is created Category Response interface Syntax public void setVariable String name String value Throws IllegalArgumentException If the name parameter is not a valid CFML variable name Paramete...

Page 784: ...text output into the debug stream This text is displayed to the end user only if the tag contains the debug attribute check for this attribute using the Request debug member function Category Respons...

Page 785: ...ith attributes and a query public DebugRequest Hashtable attributes Query query initialize a debug request with attributes a query and settings public DebugRequest Hashtable attributes Query query Has...

Page 786: ...786 Chapter 5 ColdFusion Java CFX Reference...

Page 787: ...vaScript Objects This chapter provides information about JavaScript objects and functions used to WDDX in a ColdFusion application Contents JavaScript object overview 788 WddxSerializer object 789 Wdd...

Page 788: ...nstalled in the webroot cfide scripts directory To use these objects you must put a JavaScript tag before the code that refers to the objects for example script type text javascript src CFIDE scripts...

Page 789: ...erialize a WddxRecordset instance It copies serialized data to a form field for display function serializeData data formField wddxSerializer new WddxSerializer wddxPacket wddxSerializer serialize data...

Page 790: ...s Usage This is an internal function you do not typically call it Example This example is from the WddxSerializer serializeValue function Some generic object treat it as a structure this write struct...

Page 791: ...wddxPacket this write wddxPacket version 1 0 header data bSuccess this serializeValue rootObj this write data wddxPacket if bSuccess return this wddxPacket else return null write Description Appends d...

Page 792: ...nternal function you do not typically call it Example This example is from the WddxSerializer serializeValue function else if typeof obj number Number value this write number obj number else if typeof...

Page 793: ...cripts wddx js script script Use WDDX to move from CFML data to JS cfwddx action cfml2js input q topLevelVariable qj Dump the record set document write qj dump true script addColumn Description Adds a...

Page 794: ...alue is a previously defined variable rs setField 0 NewColumn newValue addRows Description Adds rows to all columns in a WddxRecordset instance Syntax object addRows n Parameters Return value None Usa...

Page 795: ...ct getField row col Parameters Return value Returns the value in the specified row column position Usage Call this function to access a value in a WDDX record set Example This example calls the getFie...

Page 796: ...t function function dumpWddxRecordset r Get row count nRows r getRowCount for row 0 row nRows row setField Description Sets the element in the specified row column position Syntax object setField row...

Page 797: ...xSerialize serializer Parameters Return value Returns a Boolean True if serialization was successful or False if an error occurs Usage This is an internal function you do not typically call it Example...

Page 798: ...798 Chapter 6 WDDX JavaScript Objects...

Page 799: ...799 CHAPTER 7 ColdFusion ActionScript Functions This chapter explains the syntax and usage of the two server side ActionScript functions CF query and CF http Contents CF query 800 CF http 801...

Page 800: ...CF query function using positional arguments CF query datasource sql CF query datasource sql maxrows CF query datasource sql username password CF query datasource sql username password maxrows Note Do...

Page 801: ...arks return result Example function declaration using named arguments function basicQuery result CF query datasource cust_data sql SELECT from tblParks return result Example of the CF query function u...

Page 802: ...sername Optional When required by a server a username password Optional When required by a server a password resolveurl Optional For Get and Post methods Yes or No Default is No For GET and POST opera...

Page 803: ...ion returns data as a set of object properties as described in the following table path Optional The path to the directory in which to store files When using the path argument the file argument is req...

Page 804: ...Path file foo txt Header Raw response header For example macromedia com returns the following header HTTP 1 1 200 OK Date Mon 04 Mar 2002 17 27 44 GMT Server Apache 1 3 22 Unix mod_perl 1 26 Set Cooki...

Page 805: ...uments function postWithParams Set up the array of Post parameters These are just like cfhttpparam tags params new Array params 1 name arg2 type URL value value2 url http localhost 8100 Invoke with th...

Page 806: ...806 Chapter 7 ColdFusion ActionScript Functions...

Reviews: