background image

552

Chapter 3:  ColdFusion Functions

  <cfset yourUTC = DateConvert("local2utc", yourDate)>

<p><cfoutput>Your date and time value, converted to Coordinated Universal 
Time

 

(UTC): #yourUTC#.</cfoutput></p>
<p><cfoutput>Your UTC date and time, converted back to local date and time:

 

#DateConvert("utc2local", yourUTC)#.

 

</cfoutput></p>

<cfelse>

Type the date and time, and press Enter to see the conversion.

</cfif>
<Hr size = "2" color = "#0000A0">
<form action = "dateconvert.cfm">
<p>Enter year, month and day in integer format for date value to view:
<table cellspacing = "2" cellpadding = "2" border = "0">
<tr>
  <td>Year</td>
  <td><input type = "Text" name = "year" value = "1998" 

 

validate = "integer" required = "Yes"></td></tr>

<tr>
  <td>Month</td>
  <td><input type = "Text" name = "month" value = "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 = "Yes"></td></tr>

<tr>
  <td>Hour</td>
  <td><input type = "Text" name = "hour" value = "16" 

 

range = "0,23" 

 

message = "You must enter an hour (0-23)" 

 

validate = "integer" required = "Yes"></td></tr>

<tr>
  <td>Minute</td>
  <td><input type = "Text" name = "minute" value = "12" 

 

range = "0,59" 

 

message = "You must enter a minute value (0-59)" 

 

validate = "integer" required = "Yes"></td></tr>

<tr>
  <td>Second</td>
  <td><input type = "Text" name = "second" value = "0" 

 

range = "0,59" 

 

message = "You must enter a value for seconds (0-59)" 

 

validate = "integer" required = "Yes"></td></tr>

<tr>
  <td><input type = "Submit" name = "submit" value = "Submit"></td>
  <td><input type = "RESET"></td></tr>
</table>

Summary of Contents for COLFUSION MX 7 - INSTALLING AND USING COLDFUSION MX

Page 1: ...COLDFUSION MX7 CFML Reference...

Page 2: ...uide then you do so at your own risk Macromedia provides these links only as a convenience and the inclusion of the link does not imply that Macromedia endorses or accepts any responsibility for the c...

Page 3: ...936 Styles for cfformgroup with horizontal or vertical type atributes 936 Styles for box style cfformgroup elements 937 Styles for cfformgroup with accordion type attribute 938 Styles for cfformgroup...

Page 4: ...eference 1055 C class overview 1055 Deprecated class methods 1056 CCFXException class 1056 CCFXQuery class 1058 CCFXRequest class 1062 CCFXStringSet class 1072 CHAPTER 8 ColdFusion Java CFX Reference...

Page 5: ...s how 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...

Page 6: ...ne 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 7: ...can be used safely in some situations you can prevent errors by avoiding them entirely Any name starting with cf However when you call a CFML custom tag directly you prefix the custom tag page name wi...

Page 8: ...ds that you cannot use as variable names in queries to their databases For a detailed list see your DBMS documentation ABSOLUTE ACTION ADD ALL ALLOCATE ALTER AND ANY ARE AS ASC ASSERTION AT AUTHORIZAT...

Page 9: ...ECT INTERVAL INTO IS ISOLATION JOIN KEY LANGUAGE LAST LEADING LEFT LEVEL LIKE LOCAL LOWER MATCH MAX MIN MINUTE MODULE MONTH NAMES NATIONAL NATURAL NCHAR NEXT NO NOT NULL NULLIF NUMERIC OCTET_LENGTH OF...

Page 10: ...Client variables The following client variables are reserved Client CFID Client CFToken Client HitCount Client LastVisit Client TimeCreated Client URLToken Server variables Use the Server prefix to re...

Page 11: ...st Request variables store data in a structure that can be passed to nested tags such as custom tags and processed once To provide information to nested tags set a Request variable as follows CFSET Re...

Page 12: ...Type CFCATCH Message CFCATCH Detail CFCATCH ErrNumber CFCATCH NativeErrorCode CFCATCH SQLState CFCATCH LockName CFCATCH LockOperation CFCATCH MissingFileName CFCATCH TagContext CFCATCH ErrorCode CFCAT...

Page 13: ...Time Error Browser Error GeneratedContent Error RemoteAddress Error HTTPReferer Error Template Error QueryString The following error variables are available if type validation Error ValidationHeader E...

Page 14: ...verFileExt CFFILE ServerFileName CFFILE TimeCreated CFFILE TimeLastModified CFFTP error variables When you use the cfftp stoponerror attribute these variables are populated CFFTP Succeeded CFFTP Error...

Page 15: ...e ColumnList CFPOP variables The cfpop tag returns the following result columns depending on the action attribute value and the use of other attributes such as attachmentpath where queryname is the na...

Page 16: ...value searchname URL searchname Key searchname Title searchname Score searchname Custom1 and Custom2 searchname Summary searchname RecordCount searchname CurrentRow searchname RecordsSearched searchna...

Page 17: ...erver API or CGI to communicate with the ColdFusion server Environment variables contain data about the transaction between the browser and the server such as the IP Address browser type and authentic...

Page 18: ...is path The extra information is sent as PATH_INFO PATH_TRANSLATED Translated version of PATH_INFO after any virtual to physical mapping SCRIPT_NAME Virtual path to the script that is executing used f...

Page 19: ...sponse to the server having sent the LAST_MODIFIED HTTP header It can be used to take advantage of browser side caching CGI client certificate variable Description CERT_SUBJECT Client specific informa...

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

Page 21: ...owing table briefly describes CFML tags CFML tag Category Description cfabort Flow control tags Stops the processing of a ColdFusion page at the tag location cfapplet Forms tags Embeds Java applets in...

Page 22: ...rol tags Receives control if there is no matching cfcase tag value cfdirectory File management tags Performs typical directory handling tasks from within a ColdFusion application cfdocument Data outpu...

Page 23: ...text and HTML to HEAD section of page cfhttp Internet Protocol tags Performs GET and POST to upload file or post form cookie query or CGI variable directly to server cfhttpparam Internet Protocol tag...

Page 24: ...e cfNTauthenticate Security tags Authenticates user information against an NT domain cfobject Extensibility tags Creates COM component CORBA Java and web service objects cfobjectcache Database manipul...

Page 25: ...ags 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 ColdFusion set...

Page 26: ...28 Other tags 29 Application framework tags cftree Forms tags Creates tree control element used in cfform cftreeitem Forms tags Populates a tree control element in a form used with cftree cftry Excep...

Page 27: ...entitem cfoutput cfchartdata cfdocumentsection cfprocessingdirective cfchartseries cfflush cfreport cfcol cfheader cfreportparam cfcontent cflog cfsilent cfdocument cfoutput cftable cfdump cftimer cft...

Page 28: ...ation cfelseif cfloop cfapplet cfgrid cfselect cfcalendar cfgridcolumn cfslider cfform cfgridrow cftextarea cfformgroup cfgridupdate cftree cfformitem cfinput cftreeitem cfftp cfldap cfmailpart cfhttp...

Page 29: ...g Attribute or value Added in this ColdFusion release cfapplication scriptProtect ColdFusion MX 7 loginStorage ColdFusion MX 6 1 cfargument xml value of type attribute ColdFusion MX 7 All ColdFusion M...

Page 30: ...esult attribute for upload action ColdFusion MX 7 fixnewline attribute for action append and action write cfform name and action attributes are optional ColdFusion MX 7 accessible format height width...

Page 31: ...pdate Refresh Delete Purge actions New values of the language attribute cfinput height and width attributes all except checkbox and radiobutton ColdFusion MX 7 bind attribute text and password label a...

Page 32: ...attribute ColdFusion MX 6 1 cfmailpart All ColdFusion MX 6 1 cfNTauthenticate All ColdFusion MX 7 cfobject All ColdFusion MX cfobjectcache All ColdFusion MX cfparam min max pattern attributes ColdFusi...

Page 33: ...oldFusion MX 7 enabled group height label onKeyUp onKeyDown onMouseUp onMouseDown onChange onClick queryPosition tooltip visible and width attributes cfsetting requestTimeOut attribute ColdFusion MX c...

Page 34: ...through attribute ColdFusion MX 7 enableCAB attribute ColdFusion MX cfftp agentname attribute ColdFusion MX cfgraph All ColdFusion MX cfgraphdata All ColdFusion MX cfgridupdate connectString dbName db...

Page 35: ...ut All ColdFusion MX 7 cfupdate connectString dbName dbServer dbtype provider providerDSN attributes ColdFusion MX Tag Attribute or value Obsolete as of this ColdFusion release cfauthenticate All Cold...

Page 36: ...reached and ColdFusion returns the page contents up to the line that contains the cfabort tag When you use this tag with the showError attribute but do not define an error page using cferror page proc...

Page 37: ...value cfloop from 1 to 4 index Counter on the second time through the loop cfabort cfif Counter is 2 Take out the cferror line to see cfabort error processed by CF error page cferror type request tem...

Page 38: ...r_nonJava_browser param_1 applet_parameter_name param_2 applet_parameter_name param_n applet_parameter_name See also cfform cfformgroup cfformitem cfgrid cfinput cfobject cfselect cfservlet cfslider c...

Page 39: ...the ColdFusion Administrator and click Applets link under extensions 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 cffor...

Page 40: ...CFC Reference on page 945 Chapter 13 Designing and Optimizing a ColdFusion Application and Chapter 37 Integrating J2EE and Java Elements in CFML Applications in ColdFusion MX Developer s Guide History...

Page 41: ...omputer in a cookie Scalable If client disables cookies in the browser client variables do not work setClientCookies Optional yes yes enables client cookies no ColdFusion does not automatically send C...

Page 42: ...application to send malicious code back to a user s browser In these attacks user input for example from form fields or from URL variables sets a CF variable which is destined for user output The subm...

Page 43: ...CrossSiteScriptPatterns variable Locking server application and session variables When you set or update variables in the server application and session scopes use the cflock tag with the scope attri...

Page 44: ...s variable keeps track of total number of turtlenecks sold cflock scope Application timeout 30 type Exclusive cfset application number application number session numPurchased cflock cfif cfoutput E Tu...

Page 45: ...ment 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 hexadecimal number 0 9A F numeri...

Page 46: ...datasource cfdocexamples SELECT Descript FROM Courses WHERE Number Course_Number cfquery Specify the variable that the function returns cfreturn Description Descript cffunction required Optional no No...

Page 47: ...me in the dataCollection attribute The structure is appended to an array whose name is thistag collectionName Within the custom tag code the attributes passed to the tag by using the attributeCollecti...

Page 48: ...This tag is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX this tag is obsole...

Page 49: ...DER by course_number cfquery p This example uses CFLOOP to cycle through a query to find a value In our example a list of values corresponding to courses in the Snippets datasource When the conditions...

Page 50: ...50 Chapter 2 ColdFusion Tags cfelse br Searching cfif cfloop cfif...

Page 51: ...rectory and timeout 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 52: ...n 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 action...

Page 53: ...ting a cached file cfcache uses cfsetting showDebugOutput no The cfcache tag evaluates each unique URL including URL parameters as a distinct page for caching purposes For example the output of http s...

Page 54: ...tionscript to invoke See also cfform cfgrid cfinput cfselect cfslider cftextarea cftree About Flash form styles in Chapter 29 Creating Forms in Macromedia Flash in ColdFusion MX Developer s Guide Hist...

Page 55: ...acters Any other character put the character in the specified location For more information on masking see Masking input data in the cfinput reference page firstDayOfWeek Optional 0 Integer in the ran...

Page 56: ...e in a month respectively Use the Page Up and Page Down keys to reach the previous and next month respectively Note The cfcalendar tag is not supported in XML format forms Example This example produce...

Page 57: ...75 height 350 cfcalendar name selectedDate selectedDate Form selectdate startRange Form startdate endRange Form enddate mask mmm dd yyyy dayNames SU MO TU WE TH FR SA monthNames JAN FEB MAR APR MAY JU...

Page 58: ...ching values with the delimiter character which is the comma by default For example the following line matches red blue or green cfcase value red blue green You can use the delimiter attribute to spec...

Page 59: ...e 10 cfset grade A cfcase cfcase value 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...

Page 60: ...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 unexp...

Page 61: ...hing exception type starting with the most specific the entire string and ending with the least specific For example you could define a type as follows cfthrow type MyApp BusinessRuleException Invalid...

Page 62: ...resenting one level of the active tag context at the time of the exception cfcatch NativeErrorCode Applies to type database Native error code associated with exception Database drivers typically provi...

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

Page 64: ...uired COM Allaire ColdFusion HTTPPreconditionFailed COM Allaire ColdFusion HTTPProxyAuthenticationRequired COM Allaire ColdFusion HTTPRequestURITooLarge COM Allaire ColdFusion HTTPResetContent COM All...

Page 65: ...cfcatch 65 p Caught an exception type CFCATCH TYPE p p The contents of the tag stack are p cfdump var cfcatch tagcontext cfoutput cfcatch cftry...

Page 66: ...old yes or no fontItalic yes or no fontSize integer font size foregroundColor Hex value or Web color format flash or jpg or png gridlines integer number of lines labelFormat number currency percent da...

Page 67: ...rt border around labels and around the legend Hexadecimal value or supported named color see the name list in Usage For a hexadecimal value use the form xxxxxx or xxxxxxxx where x 0 9 or A F use two n...

Page 68: ...xis including axis positive integer labelFormat Optional number Format for y axis labels number currency percent date markerSize Optional Automatic Size of data point marker in pixels integer name Opt...

Page 69: ...a points in line curve and scatter graphs yes no showXGridlines Optional no Whether to display x axis gridlines yes no showYGridlines Optional yes Whether to display y axis gridlines yes no sortXAxis...

Page 70: ...the label of the selected item If none the value is an empty string SERIESLABEL the label of the selected series If none the value is an empty string For example somepage cfm item ITEMLABEL series SE...

Page 71: ...render a double byte character set you must select this value If this value is selected the fontBold and fontItalic attributes have no effect The following table lists W3C HTML 4 named color value or...

Page 72: ...docexamples database and generates a bar chart showing average salary by department The body of the cfchartseries tag includes one cfchartdata tag to include data that is not available from the query...

Page 73: ...Bar graph from Query of Queries cfchart format flash xaxistitle Department yaxistitle Salary Average cfchartseries type bar query DataTable itemcolumn Dept_Name valuecolumn avgSal cfchartdata item Fac...

Page 74: ...tment The body of the cfchartseries tag loops over a cfchartdata tag to include data available from the query Get the raw data from the database cfquery name GetSalaries datasource cfdocexamples SELEC...

Page 75: ...1000 cfset DataTable avgSal i Round DataTable avgSal i 1000 1000 cfloop h1 Employee Salary Analysis h1 Bar graph from Query of Queries cfchart format flash xaxistitle Department yaxistitle Salary Aver...

Page 76: ...aise shade light query queryName seriesColor Hex value or Web color seriesLabel Label Text type type valueColumn queryColumn dataLabelStyle style cfchartseries See also cfchart cfchartdata Chapter 31...

Page 77: ...al rectangle Sets the icon that marks a data point for two dimensional line curve and scatter graphs rectangle triangle diamond circle letter mcross snow rcross paintStyle Optional plain Sets the pain...

Page 78: ...ECT Departmt Dept_Name Employee Dept_ID Employee Salary FROM Departmt Employee WHERE Departmt Dept_ID Employee Dept_ID cfquery type Required Sets the chart display style bar line pyramid area horizont...

Page 79: ...GetSalaries GROUP BY Dept_Name cfquery Reformat the generated numbers to show only thousands cfloop index i from 1 to DataTable RecordCount cfset DataTable sumSal i Round DataTable sumSal i 1000 1000...

Page 80: ...able tags To display the cfcol header text you must specify the cfcol header and the cftable colHeader attribute If you specify either attribute without the other the header does not display No error...

Page 81: ...l Example h3 Uses the HTMLTable attribute to display cftable as an HTML table rather than PRE formatted information cftable query GetEmployees startRow 1 colSpacing 3 HTMLTable colheaders Each cfcol t...

Page 82: ...ction Added CATEGORIES SIZE DOCCOUNT and LASTMODIFIED to list of variables returned by the list action Marked as obsolete the MAPPED ONLINE and REGISTERED variables returned by the list action ColdFus...

Page 83: ...tered by ColdFusion map creates a map to a collection If the action is create and the collection already exists Coldfusion also creates a map to the collection optimize optimizes the structure and con...

Page 84: ...equired Required language Optional Optional name Required Required categories CATEGORIES blue 10 green 3 magenta 3 purple 2 CATEGORYTREES a 10 a b 10 a b c 10 a b c subdir 3 Column Contents CATEGORIES...

Page 85: ...collections that are registered with the Verity server use code such as the following cfcollection action list name myCollections cfoutput query myCollections name br cfoutput To add content to a col...

Page 86: ...cfelse cfset collpath opt coldfusionmx7 verity collections cfif Process form input and do the requested cfcollection operation cfif IsDefined form CollectionName AND IsDefined form CollectionAction c...

Page 87: ...CollectionAction option value Create Create this collection option value Optimize Optimize this collection option value Repair Repair this collection option value Delete Delete this collection select...

Page 88: ...on page Within a URL that calls a CFC file and passes a method name as a URL parameter Within the cfscript tag As a web service From Flash code Category Extensibility tags Syntax cfcomponent extends a...

Page 89: ...a cfoutput tag Variable names surrounded by number signs are automatically replaced with their values no Constructor code is processed as if it were within a cfsilent tag If you do not specify this at...

Page 90: ...only when style document bindingname Optional Specifies the binding attribute of the port element in the WSDL If you don t specify this attribute ColdFusion MX derives the value from the CFC class na...

Page 91: ...empQuery datasource cfdocexamples SELECT FIRSTNAME LASTNAME EMAIL FROM tblEmployees cfquery cfreturn empQuery cffunction cffunction name getDept cfquery name deptQuery datasource cfdocexamples SELECT...

Page 92: ...he contents of a file or of a variable that contains binary data as the page output To restrict this tag use the Sandbox Security feature of the ColdFusion MX Administrator For more information see th...

Page 93: ...iso 8859 1 windows 1252 us ascii shift_jis iso 2022 jp euc jp euc kr big5 euc cn utf 16 For example type text html type text html charset ISO 8859 1 deleteFile Optional no Applies only if you specify...

Page 94: ...ts of the file specified by the cfcontent tag using the filename specified by the filename value If the user selects to open the file most browsers open the file in the related application not the bro...

Page 95: ...t see www iana org assignments media types Example CFCONTENT Example 1 This example shows the use of cfcontent to return the contents of the CF Documentation page dynamically to the browser You might...

Page 96: ...EXAMPLE 5 This example causes the browser to treat the HTML table as Excel data Excel interprets the table format Because Excel can include executable code the browser prompts the user whether to sav...

Page 97: ...d Name of cookie variable ColdFusion converts cookie names to all uppercase Cookie names set using this tag can include any printable ASCII characters except commas semicolons or white space character...

Page 98: ...ie set in the preceding code use the following line cfoutput cookie person name cfoutput secure Optional If browser does not support Secure Sockets Layer SSL security the cookie is not sent To use the...

Page 99: ...u match the string aol com in a visitor s e mail address cfloop query GetAolUser cfif FindNoCase aol com Email 1 is not 0 cfcookie name LastAOLVisitor value Email expires NOW cfif cfloop If the timeVi...

Page 100: ...h any of the values specified by the cfcase tags in the cfswitch tag body The contents of the cfdefaultcase tag body can include HTML and text and CFML tags functions variables and expressions You can...

Page 101: ...cfdefaultcase 101 cfdefaultcase cfswitch cfoutput Your grade is grade cfoutput...

Page 102: ...also cffile History ColdFusion MX 7 Added the recurse attribute named recursive in Alpha 1 and directory result set column ColdFusion MX Changed behavior for action list On Windows cfdirectory action...

Page 103: ...returned names for example cfm One filter can be applied mode Optional Used with action create Permissions Applies only to UNIX and Linux Octal values of chmod command Assigned to owner group and oth...

Page 104: ...llowing result columns in standard CFML expressions preceding the result column name with the query name mydirectory name mydirectory directory mydirectory size mydirectory type mydirectory dateLastMo...

Page 105: ...ory Check that the directory exists and that files are not in the directory to avoid getting ColdFusion error messages cfset currentDirectory GetDirectoryFromPath GetTemplatePath otherNewDir Check to...

Page 106: ...hat contains entries for the directories only cfdirectory directory C temp name dirQuery action LIST Get an array of directory names cfset dirsArray arraynew 1 cfset i 1 cfloop query dirQuery cfif dir...

Page 107: ...marginright number unit in or cm encryption 128 bit or 40 bit or none ownerpassword password userpassword password permissions permission list fontembed yes or no backgroundvisible yes or no scale per...

Page 108: ...in centimeters include the unit cm attribute pagewidth Optional Specifies the page width in inches default or centimeters This attribute is only valid if pagetype custom To specify page width in centi...

Page 109: ...permissions AllowPrinting AllowModifyContents AllowCopy AllowModifyAnnotations AllowFillIn AllowScreenReaders AllowAssembly AllowDegradedPrinting Separate multiple permissions with a comma fontembed...

Page 110: ...count Note The cfdocument scope variables are reserved for page number rendering Do not use them in ColdFusion expressions For example the following code does not work cfif cfdocument currentpagenumbe...

Page 111: ...on History ColdFusion MX 7 Added this tag Attributes Usage Use the cfdocumentitem tag to control the formatting of a PDF or FlashPaper report This tag must be wrapped inside a cfdocument cfdocument pa...

Page 112: ...document it applies to the rest of the document If the tag is at the end of the document it has no affect With cfdocumentsection tags The cfdocumentitem attribute applies only to the section and over...

Page 113: ...tributes Attribute Req Opt Default Description margintop Optional Specifies the top margin in inches default or centimeters To specify the top margin in centimeters include the unit cm attribute in th...

Page 114: ...ry SELECT Emp_ID firstname lastname e dept_id salary d dept_name FROM employee e departmt d WHERE e dept_id d dept_id ORDER BY d dept_name cfquery cfdocument format PDF cfoutput query empSalary group...

Page 115: ...cfdocumentsection 115 cfdocumentsection cfoutput cfdocument...

Page 116: ...tory ColdFusion MX 7 Added the top attribute ColdFusion MX 6 1 Added the ability to dump COM objects it displays the methods and Get and Put properties typeinfo information for the object Attributes A...

Page 117: ...splay a construct use code such as the following in which myDoc is a variable of type XmlDocument cfif IsXmlDoc mydoc is yes cfdump var mydoc cfif The tag output is color coded according to data type...

Page 118: ...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 119: ...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 120: ...recated the monitor option of the exception attribute It might not work and might cause an error in later releases Attributes Attribute Req Opt Default Description type Required Type of error that the...

Page 121: ...specify and code you can use on the pages that handle these error type mailTo Optional An e mail address This attribute is available on the error page as the variable error mailto ColdFusion does not...

Page 122: ...ns as in Error InvalidFields You must specify the validation error handler in the Application cfc or Application cfm file Handles hidden form field or onSubmit format validation errors only Page type...

Page 123: ...ontact 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 Yo...

Page 124: ...is relative to the ColdFusion temporary directory Attributes Attribute Req Opt Default Description name Required Absolute path of the application to execute On Windows you must specify an extension fo...

Page 125: ...outputfile or variable attribute is specified output is displayed on the page from which it was called If not an absolute path starting a with a drive letter and a colon or a forward or backward slas...

Page 126: ...age it executes in the same way as cfabort The cfexit tag can help simplify error checking and validation logic in custom tags The cfexit tag function depends on its location and execution mode Attrib...

Page 127: ...efined the tag adds them and returns the result to the calling page in the variable result If either or both of the expected attribute variables is not present an error message is generated and cfexit...

Page 128: ...and Administering ColdFusion MX Category File management tags Syntax The tag syntax depends on the action attribute value See the following sections See also cfdirectory History ColdFusion MX 7 Added...

Page 129: ...ttribute options read write append and move they support a new attribute charset The archive value of the attributes attribute is obsolete and has no effect Example This shows how to write read update...

Page 130: ...it read from it or delete it p cfif If reading from a form let that information display in textarea textarea name the_text cols 40 rows 5 cfif readText is not cfoutput readText cfoutput cfif textarea...

Page 131: ...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 132: ...attributes readOnly all other attributes are overwritten readOnly hidden normal charset Optional JVM default file character set The character encoding in which the file contents is encoded The followi...

Page 133: ...s returned by the GetTempDirectory function destination Required Pathname of a directory or file on web server where the file will be copied If you specify a filename without a directory path ColdFusi...

Page 134: ...134 Chapter 2 ColdFusion Tags Example This example copies the keymemo doc file to the c files backup directory cffile action copy source c files upload keymemo doc destination c files backup...

Page 135: ...file 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 the file...

Page 136: ...urce Required 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...

Page 137: ...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 normal charset...

Page 138: ...ntended for use with large files such as logs because this can bring down the server Syntax cffile action read file full_path_name variable var_name charset charset_option See also cfdirectory History...

Page 139: ...is Cp1252 and the files has characters encoded in the Hex 8x or 9x range you must specify charset windows 1252 attribute even though this is the default encoding Otherwise some characters in the Hex8x...

Page 140: ...r site Example The following example reads the binary file somewhere jpg writes it to a different folder as somewhereB jpg and then displays the new file cffile action readBinary file C inetpub wwwroo...

Page 141: ...te 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 GetTempDirectory function destination Re...

Page 142: ...ut when renamed it becomes normal not hidden or read only cffile action rename source c files memo readonlymemo doc destination c files memo normalmemo doc attributes normal Unix Example cffile action...

Page 143: ...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 144: ...th of any other request content The following file upload status parameters are available after an upload mode Optional Applies only to UNIX and Linux Permissions Octal values of chmod command Assigne...

Page 145: ...on the client system without an extension contentSubType MIME content subtype of the saved file contentType MIME content type of the saved file dateLastAccessed Date and time the uploaded file was las...

Page 146: ...ype of file 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 relat...

Page 147: ...comma delimited list of attributes to set on the file If omitted the file s attributes are maintained Each value must be specified explicitly For example if you specify attributes readOnly all other...

Page 148: ...eldname destination tmp program exe mode 777 This example uses the fixnewline attribute to changes embedded line ending characters in xmlString which is derived from xmlData to operating system specif...

Page 149: ...ctions on a page anywhere after the cfflush tag can cause errors or unexpected results cfcontent cfcookie cfform cfheader cfhtmlhead cflocation and SetLocale These tags and functions normally modify t...

Page 150: ...at truly fit your personality So relax for a minute or so while we do the hard work for you p H2 We are sure you will agree it was worth the short wait H2 cfflush cfflush interval 10 Delay Loop to mak...

Page 151: ...ash and XML only width pixels or percent height pixels or percent The following attributes are supported in Flash only onError ActionScript code wMode window or transparent or opaque accessible yes or...

Page 152: ...ll supported HTML attributes in the XML Attribute Applies to Req Opt Default Description name HTML Flash XML Opt CFForm_n A name for the form In HTML format if you omit this attribute and specify an i...

Page 153: ...L Specfies whether to apply an XSL skin and display the resulting HTML to the client Can be any of the following ColdFusion MX skin name applies the specified skin XSL file name applies the skin locat...

Page 154: ...ider cftextinput overrides the value attribute value cfselect controls that are populated from queries Overrides the selected attribute See cfselect cftree controls overrides the cftreeitem expand att...

Page 155: ...le JRE plug in for Internet Explorer used for cfgrid cfslider and cftree Java applet controls Default CFIDE classes cf j2re win cab archive applets in HTML and XML Opt See Description URL of downloada...

Page 156: ...relative to other displayable content that occupies the same space on an HTML page window the Flash form is the topmost layer on the page and obscures anything that would share the space such as drop...

Page 157: ...you follow a Flash form with additional output specify the height and width values If attribute value text must include quotation marks escape them by doubling them Using the onError attribute in Fla...

Page 158: ...of Radio Button Test h3 cfif Form testVal1 Your radio button answer was yes cfelse Your radio button answer was no cfif cfif h3 Results of Checkbox Test h3 cfif IsDefined Form chkTest2 Your checkbox a...

Page 159: ...L format form It uses the default xsl transform that is supplied with ColdFusion to generate the HTML output for display cfform name testXForm format XML skin basic Use cfformgroup to put the first an...

Page 160: ...p type repeater query query object startrow row number maxrows integer ColdFusion forms controls cfformgroup See also cfapplet cfcalendar cfform cfformitem cfgrid cfinput cfselect cfslider cftextarea...

Page 161: ...type vertical inside this formgroup to align its child tags vertically Flash Must be one of the following repeater dynamically creates an instance of the cfformgroup s child tag or tags for each row...

Page 162: ...ting accordion Define each pleat using a cfformgroup type page tag tabnavigator places the children in a tabbed dialog box Define each tab using a cfformgroup type page tag page places the children ta...

Page 163: ...specifies the first page control defined in the group width Optional Flash and XML Width of the group container in pixels If you omit this attribute Flash automatically sizes the container width Igno...

Page 164: ...oldFusion MX Developer s Guide Example For a simple example of an XML form that uses a single cfformgroup tag see cfform The following example shows how to use the cfformgroup tag to arrange elements...

Page 165: ...tabs b br Submit the form and see what ColdFusion gets in the Forms scope b br a href http www macromedia com target _blank font color 0000FF u This link displays the Macromedia home page in a new br...

Page 166: ...e vbox cfformitem type text height 20 Fruits cfformitem cfformgroup type tile width 200 label Tile box Flash requires unique names for all controls cfinput type Checkbox name chk1 Label Apples value A...

Page 167: ...ls visible Yes or No enabled Yes or No tooltip Tip text bind bind expression text cfformitem See also cfapplet cfform cfformgroup cfgrid cfinput cfselect cfslider cftextarea cftree Adding text images...

Page 168: ...hrule places a horizontal rule on the form This tag must not have any children vrule places a vertical rule on the form This tag must not have any children XML html puts the CFML tag s body text in a...

Page 169: ...t this attribute Flash automatically sizes the width In ColdFusion XSL skins use the style attribute instead height Optional Flash Height of the item in pixels If you omit this attribute Flash automat...

Page 170: ...file and directory operations ColdFusion MX Deprecated the agentname attribute It might not work and might cause an error in later releases Usage Use this tag to move files between a ColdFusion server...

Page 171: ...terminates an FTP connection username Required 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 se...

Page 172: ...r so close a connection as soon as possible If you do not assign the connection name to Session or Application variable the connection remains open for the current page only and you do not have to clo...

Page 173: ...OnError Yes p Did it succeed cfoutput cfftp succeeded cfoutput p List the files in a directory cfftp action LISTDIR stopOnError Yes name ListFiles directory connection my_query cfoutput query ListFile...

Page 174: ...File filename item directory or file existing file or directory name new file or directory name proxyServer proxy server passive yes or no result result_name See also cfhttp cfldap cfmail cfpop Attrib...

Page 175: ...rform an operation localFile Required if action getFile or putFile Name of the file on the local file system remoteFile Required if action getFile putFile or existsFile Name of the file on the FTP ser...

Page 176: ...le exists For more information see ColdFusion MX Developer s Guide Caution Object file and directory names are case sensitive Action cfftp ReturnValue variable The results of an action determine the v...

Page 177: ...eader b Name b text name cfcol header b Path b text path cfcol header b URL b text url cfcol header b Length b text length cfcol header b LastModified b text DateFormat lastmodified cfcol header b IsD...

Page 178: ...er 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 information are...

Page 179: ...the XML value to the returntype attribute ColdFusion MX Added this tag Category Extensibility tags Syntax cffunction name methodName returnType dataType roles securityRoles access methodAccess descrip...

Page 180: ...xxxxxxxxxxxxxxxx where each x is a character representing a hexadecimal number 0 9A F variableName a string formatted according to ColdFusion variable naming conventions void does not return a value x...

Page 181: ...lly or remotely executing page or component method or a remote client through a URL Flash or a web service To publish the function as a web service this option is required description Optional Supplie...

Page 182: ...ariable name format that is the function must return a string that starts with a letter underscore or Unicode currency symbol and consist of letters numbers and underscores _ periods and Unicode curre...

Page 183: ...hat you specify in the tag Arial is not supported it is mapped to Dialog Itemlabelfont Sets item label text font If the Valuelabelfont Itemlabelfont and Legendfont values differ ColdFusion uses the la...

Page 184: ...alues before the URL is accessed value selected row column value or an empty string itemlabel selected item column value or an empty string serieslabel selected series row value or an empty string jav...

Page 185: ...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 186: ...mn_font fontSize size italic yes or no bold yes or no textColor web color gridLines yes or no rowHeight pixels colHeaders yes or no colHeaderFont font_name colHeaderFontSize size colHeaderItalic yes o...

Page 187: ...deleteButton text sortAscendingButton text sortDescendingButton text zero or more cfgridcolumn and cfgridrow tags cfgrid See also cfapplet cfcalendar cfgridcolumn cfgridrow cfgridupdate cfform cfformg...

Page 188: ...he grid sizes automatically width Optional All 300 applet only Width of the control in pixels If you omit the attribute in Flash format the grid sizes automatically query Optional All Name of the quer...

Page 189: ...Size of column header text in points colHeaderItalic Optional All no yes displays column headers in italics no colHeaderBold Optional All no yes displays column headers in bold no colHeaderTextColor O...

Page 190: ...the values specified in the cfgridcolumn width attributes vSpace Optional applet Vertical space above and below the control in pixels hSpace Optional applet Horizontal space to the left and right of...

Page 191: ...are passed to the function which must return True if validation succeeds False otherwise onError Optional applet A JavaScript function to execute if validation fails gridDataAlign Optional applet Left...

Page 192: ...dy ColdFusion generates a grid with the following A column for each column in the query A default header for each column created by replacing hyphen or underscore characters in the table column name w...

Page 193: ...ta available in the action page as ColdFusion variables in the Form scope with the naming convention form GridName ColumnName Each SelectMode returns these form variable s SelectMode single form GridN...

Page 194: ...ColName cfset Array_Orig form GridName original ColName cfset Array_Action form GridName RowStatus Action cfif NOT IsArray Array_New b The form variable is not an array b br cfelse cfset size ArrayLe...

Page 195: ...selectMode Row selection is a comma delimited list of column values in the clicked row beginning with the value of the first cell in the row If selectMode Column selection is a comma delimited list o...

Page 196: ...bgColor web color or expression dataAlign position The following attribute applies to Flash format only mask format mask The following attribute applies to applet format only href URL hrefKey column_n...

Page 197: ...dFusion MX passes all attributes to the XML The supplied XSLT skins do not handle or display XML format grids but do display applet and Flash format grids Attribute Req Opt Formats Default Description...

Page 198: ...ition to paths to image files in the column values cd computer document element folder floppy fixed remote You can specify the following attribute in Flash format it does not work in applet grids curr...

Page 199: ...ement text in column as a hexadecimal number or text name To enter a hexadecimal value use the form xxxxxx where x 0 9 or A F use two number signs or none Any color in hexadecimal format Black Red Blu...

Page 200: ...s in mask attribute href Optional Applet URL or query column name that contains a URL to hyperlink each grid column with hrefKey Optional Applet The query column to use for the value appended to the h...

Page 201: ...display in the drop down list Delimited strings and or numeric range s valuesDelimiter Optional Applet comma Delimiter in values and valuesDisplay attributes Character Meaning _ Underscore Digit place...

Page 202: ...ed as numeric in one or two digits If the number of pattern letters is two the format is interpreted as numeric in two digits If the number of pattern letters is three the format is interpreted as sho...

Page 203: ...ption information for courses i The cfform tag must surround a cfgrid control cfform action CGI SCRIPT_NAME cfgrid name FirstGrid width 500 query GetCourses colheaderbold Yes font Tahoma rowHeaders No...

Page 204: ...mber header Course Select No width 65 cfgridcolumn name CorName header Name width 125 cfgridcolumn name CorLevel header Level width 85 cfgridcolumn name CorDesc header Description width 125 cfgrid br...

Page 205: ...t two lists each with the data for a grid column cfset cities Rome Athens Canberra Brasilia Paris cfset countries Italy Greece Australia Brazil France cfform name cities cfgrid name GeoGrid autowidth...

Page 206: ...cfapplet 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 207: ...CorLevel CorDesc FROM CourseList ORDER by Dept_ID ASC CorNumber ASC cfquery h3 cfgrid Example h3 I Try adding a course to the database and then deleting it i cfform cfgrid name FirstGrid width 450 qu...

Page 208: ...name 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 Attr...

Page 209: ...nerates 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 GetHttpTimeString Now statusCode Requ...

Page 210: ...xml_resource_feed html for more information on this feed Set the URL address cfset urlAddress http www macromedia com devnet resources macromedia_resources rdf Use the CFHTTP tag to get the file cont...

Page 211: ...d 211 strong Description strong item description xmlText br strong Applies to these products strong br cfloop index i from 1 to arrayLen item subject step 1 item subject i xmltext br cfloop br cfoutpu...

Page 212: ...tipart yes or no path path file filename name queryname columns query_columns firstrowasheaders yes or no delimiter character textQualifier character result result_name cfhttpparam tags optional for s...

Page 213: ...ibutes control the HTTP transaction and can be used for all HTTP methods Attribute Req Opt Default Description url Req Uses the http protocol Address of the resource on the server which will handle th...

Page 214: ...nformation about the communication options available for the server or the specified URL This method enables the ColdFusion application to determine the options and requirements associated with a URL...

Page 215: ...se body do not work yes resolves URLs in the response body to absolute URLs including the port number so that links in a retrieved page remain functional Applies to these HTML tags img src a href form...

Page 216: ...and the timeout attribute value this ensures that the request times out before or at the same time as the page If the URL does not specify a timeout ColdFusion uses the lesser of the Administrator tim...

Page 217: ...as multipart form data with a Content Type of multipart form data By default ColdFusion sends cfhttp requests that contain only formField data with a Content Type of application x www form urlencoded...

Page 218: ...lace the column names retrieved by the request with your own names If a duplicate column heading is encountered in either this attribute or in the column names from the response ColdFusion appends an...

Page 219: ...h data and return results including CGI executables or even other ColdFusion pages Using the PUT method to upload files to a server that does not accept FTP requests This tag can and for PUT and POST...

Page 220: ...TP server fails contains details about the failure For instance Unknown host my co com otherwise the empty string Macromedia recommends that you check this variable for an error condition before check...

Page 221: ...n MX Administrator timeout and the URL timeout to take effect you must enable the timeout in the ColdFusion MX Administrator Server Settings page For more information see Configuring and Administering...

Page 222: ...xmlroot xmlChildren cfset numresources ArrayLen resources cfloop index i from 1 to numresources cfset item resources i cfoutput strong a href item url xmltext item title xmltext strong a br strong Aut...

Page 223: ...m 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 History C...

Page 224: ...URL encodes the Form field by default cookie specifies a cookie to send as an HTTP header ColdFusion URL encodes the cookie name Required Optional and ignored for Body and XML types Variable name for...

Page 225: ...oldFusion page the Form scope of the receiving page contains an entry with the name you specified in the cfhttpparam tag name attribute as the key The value of this variable is the path to a temporary...

Page 226: ...ed to page cfoutput cfhttp fileContent cfoutput This is the cfhttpparamexample cfm page that receives and processes the Post request Its response body is the generated HTML output h3 Output the passed...

Page 227: ...tag When testing the return value of a function that returns a Boolean you do not have to define the True condition explicitly This example uses the IsArray function cfif IsArray myarray If successfu...

Page 228: ...ther centers are listed in italics cfoutput query getCenters cfif 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...

Page 229: ...tag is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX This tag is obsolete It...

Page 230: ...tart with the current page location or a directory specified in the Administrator ColdFusion mappings page A directory in which custom ColdFusion tags are stored In this case all the cfm pages in this...

Page 231: ...tag from a JAR file use the following syntax cfoutput mytags helloTag message mymessage cfoutput The cfimport tag must be on the page that uses the imported tags For example if you use a cfimport tag...

Page 232: ...te URL or file system path for the file to include You can only use paths relative to the directory of the including page or a directory that is registered in the ColdFusion MX Administrator Mappings...

Page 233: ...e Example This example shows the use of cfinclude to paste CFML or HTML code into another page dynamically h4 This example includes the dochome htm page from the CFDOCS directory The images do not dis...

Page 234: ...ative Verity indexing tool such as Vspider or MKVDK These options however limit you to indexing a collection of files in a directory path For more information on creating indexing and searching a Veri...

Page 235: ...as specified by the key attribute purge deletes all of the documents in a collection Causes the collection to be taken offline preventing searches refresh deletes all of the documents in a collection...

Page 236: ...index categoryTree Optional A string value that specifies a hierarchical category or category tree for searching It is a series of categories separated by forward slashes You can specify only one cate...

Page 237: ...e The key attribute is the name of a column in the query that contains a full filename including path Path The key attribute is the name of a column in the query that contains a directory pathname The...

Page 238: ...itle br context mySearch context br url mySearch url br cfoutput cfdump var info EXAMPLE 2 Index a path type path cfindex collection CodeColl action refresh type path key C inetpub wwwroot vw_files ne...

Page 239: ...docexamples SELECT FROM COURSES cfquery Update the collection with the above query results key is Course_ID in the Courses table body specifies the columns to be indexed for searching custom1 specifie...

Page 240: ...ct_File body Emp_ID FirstName LastName Contract_File h2 Indexing Complete h2 cfsearch name mySearch collection CodeColl criteria vacation contextpassages 1 maxrows 100 cfoutput key mySearch key br tit...

Page 241: ...eletes keys in the CodeColl collection for html files in the specified directory but not in subdirectories cfindex collection CodeColl action delete type path key C CFusionMX7 wwwroot vw_files newspap...

Page 242: ...onError script name size integer value initial value bind bind expression checked disabled true or false or no attribute value src image URL onKeyUp JavaScript or ActionScript onKeyDown JavaScript or...

Page 243: ...heir value matches the posted value for the control In earlier releases if the posted value did not match any of the cfinput check boxes or radio buttons for the control the checked attribute was used...

Page 244: ...th type text Mask characters and the corresponding valid input characters are A A Za z X A Za z0 9 9 0 9 Any character All other characters insert the literal character Flash only For tags with type d...

Page 245: ...syntax see Chapter 27 Building Dynamic Forms with cfform Tags in ColdFusion MX Developer s Guide onValidate Optional HTML and XML only Custom JavaScript function to validate user input The form objec...

Page 246: ...aScript HTML XML or ActionScript Flash to run when the user releases a mouse button in the control onChange Optional All JavaScript HTML XML or ActionScript Flash to run when the control changes due t...

Page 247: ...de Validation The following sections describe how to do validation in cfinput tags Validation methods ColdFusion provides four methods of validation of cfinput text and password fields You can specify...

Page 248: ...ields in ColdFusion MX Developer s Guide validation types You can use the following values in the validate attribute to specify input validation for all validation methods Most attributes apply only t...

Page 249: ...text field In Flash format the mask can also control the format of the date chosen using the datefield input control In text fields ColdFusion automatically inserts any literal mask characters such a...

Page 250: ...ttribute lets you populate form fields using the contents of other form fields To specify text from another field in a cftextarea bind attribute use the following format sourceTagName text For example...

Page 251: ...t name MyZip message Enter zip code formatted xxxxx or xxxxx xxxx validate zipcode required yes font size 1 color red Required font Range validation p Range Validation enter an integer from 1 to 5 br...

Page 252: ...es Attribute Req Opt Default Description dataSource Required Data source contains table tableName Required Table in which to insert form fields ORACLE drivers must be uppercase Sybase driver case sens...

Page 253: ...existing state of the database cfquery name GetComments dataSource cfdocexamples SELECT CommentID EMail FromUser Subject CommtType MessText Posted Processed FROM Comments cfquery html head head h3 cf...

Page 254: ...form for input form action cfinsert cfm method post pre Email input type Text name email From input type Text name fromUser Subject input type Text name subject Message textarea name MessText COLS 40...

Page 255: ...ute per parameter As a structure in the argumentCollection attribute Category Extensibility tags Syntax Syntax 1 This syntax invokes a method of a component cfinvoke component component name or refere...

Page 256: ...component method method name returnVariable variable name argumentCollection argument collection OR Syntax 4B This syntax invokes a web service This syntax shows instantiation with the cfobject tag Th...

Page 257: ...associative array of arguments to pass to the method username Optional Overrides username specified in Administrator Web Services password Optional Overrides password specified in Administrator Web S...

Page 258: ...tive and corresponds to the port element s name attribute under the service element Specify this attribute if the web service contains multiple ports input_params Input parameters For each named input...

Page 259: ...on params cfinvokeargument name a value 3 cfinvoke Note The following cfinvoke tag attribute names are reserved they cannot be used for argument names component method argumentCollection and result Ex...

Page 260: ...emp cfoutput For more information on web services see Chapter 36 Using Web Services in ColdFusion MX Developer s Guide Example5 This example uses Syntax 4A Separate instantiation and method invocation...

Page 261: ...example you can use conditional processing to determine the argument name or you can use a cfif tag to determine whether to execute the cfinvokeargument tag If you are invoking a web service you can...

Page 262: ...value mot cfinvokeargument name symbol value macr cfinvoke cfoutput res cfoutput Example2 cfinvoke webservice http www xmethods net sd 2001 BabelFishService wsdl method BabelFish returnVariable varNam...

Page 263: ...yes or no referral number_of_allowed_hops secure multi_field_security_string separator separator_character delimiter delimiter_character See also cfftp cfhttp cfmail cfmailparam cfpop Chapter 23 Mana...

Page 264: ...equires attributes attribute modify modifies LDAP entries except distinguished name dn attribute on LDAP server Requires dn See modifyType attribute modifyDN modifies distinguished name attribute for...

Page 265: ...sort desc descending z to a case sensitive sort You can enter a combination of sort types for example sortControl nocase asc dn Required if action Add Modify ModifyDN or delete Distinguished name for...

Page 266: ...separator Optional comma Delimiter to separate attribute values of multi value attributes Used by query add and modify actions and by cfldap to output multi value attributes For example if dollar sig...

Page 267: ...more public LDAP servers see a href http www emailman com http www emailman com a p p Enter a name and search the public LDAP resource An asterisk before or after the name acts as a wildcard p If for...

Page 268: ...pter 2 ColdFusion Tags tr cfoutput table center cfif cfif form action cgi script_name method POST p Enter a name to search in the database p input type Text name name input type Submit value Search na...

Page 269: ...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 to a CF p...

Page 270: ...is Read only Allows multiple requests to access CFML constructs within the tag body concurrently Use a read only lock only when shared data is read and not modified If another request has an exclusive...

Page 271: ...Otherwise behavior depends on throwOnTimeout attribute value If you set timout 0 the timeout is determined by the Timeout Requests after x setting in the ColdFusion MX Administrator Settings page if...

Page 272: ...an block request threads for long periods and radically decrease throughput To prevent this always use the minimum timeout value Another cause of blocked request threads is inconsistent nesting of cfl...

Page 273: ...uide Article 20370 ColdFusion Locking Best Practices on the Macromedia website at www macromedia com support service Example This example shows how cflock can guarantee consistency of data updates to...

Page 274: ...ock scope Session timeout 30 type Exclusive cfparam name session size Default form size cfparam name session color Default form color cflock Lock the code that updates the Application scope number of...

Page 275: ...d Select a size td td select type Text name size option XXsmall option Xsmall option small option medium option large option Xlarge select td tr tr td Press Submit when you are finished making your se...

Page 276: ...g 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 application specific me...

Page 277: ...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 278: ...on MX Developer s Guide History ColdFusion MX 6 1 Changed behavior the cflogin variable exists when ColdFusion receives a request with NTLM or Digest CFHTTP Negotiated header authentication informatio...

Page 279: ...d A request that uses NTLM or Digest authentication In this case the username and password are hashed using a one way algorithm in the Authorization header ColdFusion gets the username from the web se...

Page 280: ...280 Chapter 2 ColdFusion Tags cfif qSecurity recordcount gt 0 cfloginuser name cflogin name password cflogin password roles trim qSecurity Roles cfif...

Page 281: ...sion expires or the user is logged out by the cflogout tag ColdFusion MX Added this tag Attributes Usage Used inside the cflogin tag to identify the authenticated user to ColdFusion After you call thi...

Page 282: ...See also cflogin cfloginuser Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX 6 1 Changed behavior if the Session scope is enabled a login remains in effect un...

Page 283: ...floop conditional loop on page 286 cfloop looping over a date or time range on page 287 cfloop looping over a query on page 288 cfloop looping over a list or file on page 290 cfloop looping over a COM...

Page 284: ...1 2 1 9 but not 2 This is a programming language problem regarding the internal representation of floating point numbers Note The to value is evaluated once when the cfloop tag is encountered Any cha...

Page 285: ...1 cfloop The output of this 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 th...

Page 286: ...execute cfexit cfif cflocation cfswitch cfthrow cftry cfloop and cfbreak in Chapter 2 Elements of CFML in ColdFusion MX Developer s Guide Attributes Example The following example increments CountVar f...

Page 287: ...ys stepping by 7 days at a time and displaying the date cfset startDate Now cfset endDate Now 30 cfloop from startDate to endDate index i step CreateTimeSpan 7 0 0 0 cfoutput dateformat i mm dd yyyy b...

Page 288: ...e MessageRecords dataSource cfdocexamples SELECT FROM Messages cfquery cfloop query MessageRecords cfoutput Message_ID cfoutput br cfloop The cfloop tag also iterates over a record set with dynamic st...

Page 289: ...he pages that are returned by a query of a list of page names into one document using the cfinclude tag cfquery name GetTemplate dataSource Library maxRows 5 SELECT TemplateName FROM Templates cfquery...

Page 290: ...ist John Paul George Ringo cfoutput ListElement cfoutput br cfloop You can put more than one character in the delimiters attribute in any order For example this loop processes commas colons and slashe...

Page 291: ...cfloop looping over a list or file 291 To loop over each line of a file use the tag this way cfloop list theFile index curLine delimiters chr 10 chr 13 cfloop...

Page 292: ...n the cfoutput section the name property of the file2 item is referenced for display For more information see Chapter 38 Integrating COM and CORBA Objects in CFML Applications in ColdFusion MX Develop...

Page 293: ...cfloop looping over a COM collection or structure 293 tr td person td td StructFind Departments person td tr cfloop table cfoutput...

Page 294: ...ery_row maxrows max_msgs server serverspecs port port_id mailerid headerid timeout seconds spoolenable yes or no debug yes or no Optional Mail message body and or cfhttpparam tags cfmail See also cfma...

Page 295: ...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 296: ...al Path of file to attach to message Attached file is MIME encoded ColdFusion attempts to determine the MIME type of the file use the cfmailparam tag to send an attachment and specify the MIME type qu...

Page 297: ...mailer application timeout Optional Number of seconds to wait before timing out connection to SMTP server A value here overrides the Administrator spoolEnable Optional Specifies whether to spool mail...

Page 298: ...nal servers For each server you can optionally specify a username password and port These values override the corresponding attributes if any The server attribute has the following format user passwor...

Page 299: ...ype Text name MailFrom SUBJECT input type Text name Subject hr MESSAGE BODY textarea name body cols 40 rows 5 wrap virtual textarea pre Establish required fields input type hidden name MailTo_required...

Page 300: ...mailpart cfftp cfhttp cfldap cfpop Using the cfmailparam tag in Chapter 39 Sending and Receiving E Mail in ColdFusion MX Developer s Guide History ColdFusion MX 6 x Added the Disposition and ContentID...

Page 301: ...bject See Important Attachments and Reply cfmailparam name Importance value High Please review the new logo Tell us what you think cfmailparam file c work readme txt type text plain cfmailparam file c...

Page 302: ...age in the body of an HTML message p cfmail type HTML to form mailto from form mailFrom subject Sample inline image cfmailparam file C Inetpub wwwroot web gif disposition inline contentID image1 P The...

Page 303: ...art cfmail History ColdFusion MX 6 1 Added this tag See also cfmail cfmailparam cfpop cfftp cfhttp cfldap cfcontent Wrap E mail in Chapter 17 Developing Globalized Applications in ColdFusion MX Develo...

Page 304: ...Mail Message 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...

Page 305: ...ue that is within the attributeCollection parameter Earlier releases did not process this consistently Attributes Attribute Req Opt Default Description template Required unless name attribute is used...

Page 306: ...nd tag to cfmodule ColdFusion calls your custom tag as if it had both a start and an end tag For more information see Handling end tags of Chapter 11 Creating and Using Custom CFML Tags in ColdFusion...

Page 307: ...2 color 0000A0 P Here is another way to invoke the custom tag using the NAME attribute P cfoutput HTMLCodeFormat CFMODULE NAME myTag X 3 attributeCollection attrCollection1 Y 4 cfoutput P The result...

Page 308: ...nothing on UNIX and Linux systems You typically use this tag inside a cflogin tag to authenticate the user for a cfloginuser tag as shown in the example Attribute Req Opt Default Description name Requ...

Page 309: ...ticated and contains a logout link A login form page that is displayed if the user is not logged in The Application cfm page which contains all the login authentication and logout processing code For...

Page 310: ...s are available cfif NOT IsDefined cflogin Show a login form that posts back to the page whose request initiated the login and do not process the rest of this page cfinclude template loginform cfm cfa...

Page 311: ...cfNTauthenticate 311 Please Try again H2 cfif cfoutput cfinclude template loginform cfm cfabort cfif cfif cflogin...

Page 312: ...cfargument cfcomponent cffunction cfinvoke cfinvokeargument cfproperty cfreturn Using Java objects in Chapter 37 Integrating J2EE and Java Elements in CFML Applications in ColdFusion MX Developer s Gu...

Page 313: ...pport COM objects Syntax cfobject type com action action class program_ID name text context context server server_name See also ReleaseComObject cfcollection cfexecute COM in Chapter 17 Developing Glo...

Page 314: ...ms 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 Loopin...

Page 315: ...rches first for a file with a name that matches the specified component name but is all lowercase If it does not find the file it looks for a filename that matches the component name exactly with the...

Page 316: ...nameservice ColdFusion uses naming service to access server This option is valid only with the InitialContext of a VisiBroker Orb class Required If context ior absolute path of file that contains stri...

Page 317: ...h CORBA objects you must provide the name of the file that contains a string formatted version of the IOR or the object s naming context in the naming service and the object s attributes method names...

Page 318: ...Fusion using the cfobject tag To access Java methods and fields do the following steps 1 Call the cfobject tag to load the class See the example code 2 Use the init method with appropriate arguments t...

Page 319: ...ion create type java class myclass name myobj Example of an EJB The cfobject tag creates the Weblogic Environment object which is used to get InitialContext The context object is used to look up the E...

Page 320: ...s Guide Attributes Usage Instantiates a proxy 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...

Page 321: ...ry 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 Required cl...

Page 322: ...oldFusion variable or function call For example the following code displays the text Hello World cfset myVar Hello World cfoutput myVar cfoutput Attribute Req Opt Default Description query Optional Na...

Page 323: ...le to show today s date you could write DateFormat Now If you enclosed that expression in cfoutput the result would be cfoutput DateFormat Now cfoutput p In addition cfoutput may be used to show the r...

Page 324: ...t_id d dept_id ORDER BY d dept_name cfquery Outer cfoutput cfoutput query empSalary group dept_id h2 dept_name h2 table width 95 border 2 cellspacing 2 cellpadding 2 tr th Employee th th Salary th tr...

Page 325: ...lue max value min value pattern regular expression See also cfcookie cfregistry cfsavecontent cfschedule cfset Validating data with the IsValid function and the cfparam tag in Chapter 28 Validating Da...

Page 326: ...XXXXXXXXXXXX where X is a hexadecimal number integer an integer query a query object range a numeric range specified by the min and max attributes regex or regular_expression matches input against pat...

Page 327: ...ot check whether the parameter value corresponds to an existing ColdFusion variable Tip To improve performance avoid using the cfparam tag in ColdFusion functions including in CFC methods Instead plac...

Page 328: ...and tempVar is not h3 The value of tempVar has changed the new value is cfoutput tempVar cfoutput h3 cfif p form action cfparam cfm method post Type in a new value for tempVar and hit submit br input...

Page 329: ...usion MX 6 1 Added support for multipart mail messages with Text and HTML parts Changed the attachment name separator the TAB character is now the separator between attachment names in the attachments...

Page 330: ...mma delimited list of UIDs to get or delete Invalid UIDs are ignored attachment Path Optional If action getAll specifies a directory in which to save any attachments If the directory does not exist Co...

Page 331: ...ptional No Yes generate unique filenames for files attached to an e mail message to avoid naming conflicts when files are saved No debug Optional No Yes sends debugging output to standard output By de...

Page 332: ...te these temporary files when you have processed them To create a ColdFusion date time object from the date time string that is extracted from a mail message in the queryname date column use the follo...

Page 333: ...IsDefined form server Make sure server username are not empty cfif form server is not and form username is not cfpop server form popserver username form username password form pwd action getHeaderOnly...

Page 334: ...fprocessingdirective pageencoding page encoding literal string or cfprocessingdirective suppressWhiteSpace yes or no pageEncoding page encoding literal string CFML tags cfprocessingdirective See also...

Page 335: ...o on the tag has no effect on the included pages Attribute Req Opt Default Description suppressWhiteSpace Optional Boolean whether to suppress white space characters within the cfprocessingdirective b...

Page 336: ...OM ColdFusion generates an error The following rules apply to the suppressWhiteSpace attribute You can specify the suppresswhitespace attribute value as a constant or a variable To use a variable defi...

Page 337: ...ow ignored for all drivers ColdFusion 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 Attribu...

Page 338: ...rted parameter types CF_SQL_BIGINT CF_SQL_BIT CF_SQL_BLOB CF_SQL_CHAR CF_SQL_CLOB CF_SQL_DATE CF_SQL_DECIMAL CF_SQL_DOUBLE CF_SQL_FLOAT CF_SQL_IDSTAMP CF_SQL_INTEGER CF_SQL_LONGVARCHAR CF_SQL_MONEY CF...

Page 339: ...created compiled and bound in the RDBMS environment CREATE OR REPLACE PACKAGE Foo_Data AS TYPE EmpTyp IS REF CURSOR RETURN Emp ROWTYPE TYPE DeptTyp IS REF CURSOR RETURN Dept ROWTYPE PROCEDURE refcurp...

Page 340: ...lt set b br hr cftable query rs1 colHeaders HTMLTable border 1 cfcol header EMPNO text EMPNO cfcol header EMPLOYEE name text ENAME cfcol header JOB text JOB cfcol header SALARY text SAL cfcol header D...

Page 341: ...the scope of the cfstoredproc tag If you specify a result set twice the second occurrence overwrites the first CFML supports Oracle 8 and 9 Reference Cursor type which passes a parameter by reference...

Page 342: ...ype OUT CFSQLType CF_SQL_DATE variable FOO dbVarName param2 Close the cfstoredproc tag cfstoredproc cfoutput The output param value foo br cfoutput h3 The Results Information h3 cfoutput query RS1 nam...

Page 343: ...t to inheritance rules Category Extensibility tags Syntax cfproperty name name type type required boolean default default value displayname descriptive name hint extended description See also cfargume...

Page 344: ...UUID of the form xxxxxxxx xxxx xxxx xxxxxxxxxxxxxxxx where each x is a character representing a hexadecimal number 0 9A F variableName a string formatted according to ColdFusion variable naming conve...

Page 345: ...property name Number type numeric cfproperty name Street type string cfproperty name City type string cfproperty name State type string cfproperty name Country type string cfcomponent This component r...

Page 346: ...name username password password maxRows number blockFactor blocksize timeout seconds cachedAfter date cachedWithin timespan Either of the following debug yes or no or debug result result_name cfquery...

Page 347: ...specify either dbtype or dataSource dbtype Optional Use this value to specify the results of a query as input You must specify either dbtype or dataSource username Optional Overrides username in data...

Page 348: ...uery data is used CreateTimeSpan defines a period from the present back Takes effect only if query caching is enabled in the Administrator To use cached data the current query must use the same SQL st...

Page 349: ...e escaped The escape character is the bracket for example SELECT count FROM MYTABLE For a list of reserved keywords in ColdFusion MX see Escaping reserved keywords in Chapter 22 Using Query of Queries...

Page 350: ...ntRow 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 cfoutput If the total number of records is less than or equal...

Page 351: ...curity Bulletin ASB99 04 Multiple SQL Statements in Dynamic Queries at www macromedia com devnet security security_zone asb99 04 html and Chapter 20 Accessing and Retrieving Data in ColdFusion MX Deve...

Page 352: ...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_TIMESTAMP CF_SQL_TINYINT CF_SQL_VARCHAR maxLength Optional Length of string...

Page 353: ...or these types a data value can be converted to a numeric value CF_SQL_SMALLINT CF_SQL_INTEGER CF_SQL_REAL CF_SQL_FLOAT CF_SQL_DOUBLE CF_SQL_TINYINT CF_SQL_MONEY CF_SQL_MONEY4 CF_SQL_DECIMAL CF_SQL_NU...

Page 354: ...nchar char nchar char nchar unique identifier CF_SQL_INTEGER INTEGER Integer integer serial int CF_SQL_LONGVARBINARY LONGVARBINARY Long Varchar for Bit Data byte long raw image CF_SQL_LONGVARCHAR LON...

Page 355: ...attribute p cfset LastName Peterson DELETE employees WHERE LastName Peterson Note that for string input you must specify the MAXLENGTH attribute for validation cfquery name getFirst datasource cfdocex...

Page 356: ...tion attribute value See the following sections cfregistry action getAll on page 357 cfregistry action get on page 359 cfregistry action set on page 360 cfregistry action delete on page 361 See also c...

Page 357: ...nary registry values For binary values the type variable contains UNSUPPORTED and value is blank Example This example uses cfregistry with the getAll action cfregistry action getAll branch HKEY_LOCAL_...

Page 358: ...istry action getAll h1 cftable query RegQuery colHeaders HTMLTable border Yes cfcol header b Entry b width 35 text RegQuery Entry cfcol header b Type b width 10 text RegQuery type cfcol header b Value...

Page 359: ...te an entry Example This example uses cfregistry with the get action cfregistry action get branch HKEY_LOCAL_MACHINE Software Microsoft Java VM entry ClassPath type String variable RegValue h1 cfregis...

Page 360: ...y value data Normally you pass in a filename instead of setting one here cfset FileName dummy cfm cfregistry action set branch HKEY_LOCAL_MACHINE Software cflangref entry LastCFM01 type String value F...

Page 361: ...tes values and subkeys defined beneath it Example cfregistry action delete branch HKEY_LOCAL_MACHINE Software cflangref tempkey entry LastCFM01 h1 cfregistry action delete h1 Attribute Req Opt Default...

Page 362: ...report template report definition filename format PDF or FlashPaper or excel name cf variable filename output filename query query variable overwrite yes or no encryption 128 bit or 40 bit or none own...

Page 363: ...port Builder Opt The name of the ColdFusion variable that will hold the report output You cannot specify both name and filename filename Report Builder Opt The filename to contain the report You canno...

Page 364: ...Maximum time in seconds in which a connection must be made to a Crystal Reports file report Crystal Reports Requir ed Report path Store Crystal Reports files in the same directories as ColdFusion page...

Page 365: ...me FirstName Title City Region Country FROM Employees ORDER BY Country City cfquery CFREPORT format PDF template FifthReport cfr query northwindemployees Example 2 This view only example shows the use...

Page 366: ...ust include an input parameter that matches the name attribute You can use cfreportparam to pass data to a report definition as an alternative to the cfreport query attribute Example cfquery name cour...

Page 367: ...cfreportparam 367 cfreport format PDF template FourthReport cfr query coursedept overwrite yes cfreportparam NAME ReportTime VALUE DateFormat Now TimeFormat Now cfreport...

Page 368: ...ception and the code is designed to handle only CFX exceptions the handler raises the exceptions again with details intact so that a higher level handler can process the error information If you used...

Page 369: ...equivalent to a return statement within a cfscript tag It accepts one return variable argument To return more than one value populate a structure with name value pairs and return the structure with th...

Page 370: ...370 Chapter 2 ColdFusion Tags cffunction cffunction name getDept cfquery name deptQuery datasource ExampleApps SELECT FROM tblDepartments cfquery cfreturn deptQuery cffunction cfcomponent...

Page 371: ...ion MX Developer s Guide Attributes Usage 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 repor...

Page 372: ...populate the page Category Variable manipulation tags Syntax cfschedule action update task taskname operation HTTPRequest file filename path path_to_file startDate date startTime time url URL port por...

Page 373: ...d if publish Yes Path to the directory in which to put the published file startDate Required if action update Date on which to first run the scheduled task startTime Required if action update Time at...

Page 374: ...he 29th or 30th of the month the job will run 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 t...

Page 375: ...375 operation HTTPRequest url http 127 0 0 1 playpen history cfm startDate 8 7 03 startTime 12 25 PM interval 3600 resolveURL Yes publish Yes file sample html path c inetpub wwwroot playpen requestTi...

Page 376: ...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 377: ...nction The following example shows how to invoke a component object with the cfscript tag using ordered arguments cfscript quote CreateObject component nasdaq quote Invocation using ordered arguments...

Page 378: ...01 BabelFishService wsdl xlatstring ws BabelFish en_es Hello world friend writeoutput xlatstring cfscript For more information see Chapter 36 Using Web Services in ColdFusion MX Developer s Guide Exam...

Page 379: ...cfcollection tag In the ColdFusion MX Administrator A collection can be indexed in the following ways In ColdFusion with the cfindex tag In the ColdFusion MX Administrator which calls the cfindex tag...

Page 380: ...t each collection it automatically detects whether a collection is internal or external This tag supports absolute also known as fully qualified collection pathnames and mapped collection names Change...

Page 381: ...riteria simple STEM and MANY operators are implicitly used explicit operators must be invoked explicitly Also known as Bool_Plus internet for documents that are mostly WYSIWIG what you see is what you...

Page 382: ...sages sentences Verity returns in the context summary that is the context column of the results The default i s 0 which disables context summary contextBytes Optional 300 The maximum number of bytes V...

Page 383: ...tag used to populate the collection including PDF and Office document titles If a title is not extracted from the document the tag uses the cfindex title attribute value for each row score Relevancy...

Page 384: ...ee Chapter 25 Using Verity Search Expressions in ColdFusion MX Developer s Guide Example 1 TYPE SIMPLE cfsearch name name collection snippets syntax snippets criteria example maxrows 100 p cfoutput Se...

Page 385: ...it startrow 1 maxrows 100 cfoutput query snippets url url br key key br title title br score score br custom1 custom1 br custom2 custom2 br summary summary br recordcount recordcount br currentrow cur...

Page 386: ...386 Chapter 2 ColdFusion Tags currentrow book currentrow br columnlist book columnlist br recordssearched book recordssearched br cfoutput cfdump var book...

Page 387: ...r ActionScript onMouseUp JavaScript or ActionScript onMouseDown JavaScript or ActionScript onChange JavaScript or ActionScript onClick JavaScript or ActionScript visible Yes or No enabled Yes or No to...

Page 388: ...ame syntax and contents as used in Macromedia Flex for the corresponding Flash element size Optional All 1 Number of entries to display at one time The default 1 displays a drop down list Any other va...

Page 389: ...aScript HTML XML or ActionScript Flash to run when the user releases a keyboard key in the control onKeyDown Optional All JavaScript HTML XML or ActionScript Flash ActionScript to run when the user pr...

Page 390: ...option generates an HTML optgroup tag for each entry in the group column Close each HTML option tag in the cfselect tag body with a option end tag If you do not do so and you specify queryPosition be...

Page 391: ...ame as Name FROM GetAllEmployees WHERE Emp_ID in form employeeid cfquery Display the names and e mail addresses from the query cfoutput query GetSelectedEmployees firstName lastName br Email email br...

Page 392: ...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 393: ...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 394: ...s not return a value or you do not need to use the value returned by the function For example the following line is a valid ColdFusion cfset tag for deleting the MyVariable variable from the Applicati...

Page 395: ...the beginning of the cffunction tag body before any other ColdFusion tags The following example shows how to use the new keyword cffunction name myFunct cfset var myVar This is a test cfreturn myVar...

Page 396: ...t URLEncodedFormat hey you get off of my cloud cfoutput click here A to display a message p cfif IsDefined url test is True cfoutput b I url test i b cfoutput cfelse h3 The variable url test has not b...

Page 397: ...ribute is obsolete It does not work and causes an error in releases later than ColdFusion 5 Changed exception handling the structured exception manager searches for the best fit cfcatch handler In ear...

Page 398: ...utOnly No statements have been processed the first enableCFoutputOnly Yes statement blocks output If the debugging service is enabled and showDebugOutput Yes the IsDebugMode function returns Yes other...

Page 399: ...r cfhtmlhead cfinclude cfsetting Chapter 9 Writing and Calling User Defined Functions in ColdFusion MX Developer s Guide Usage This tag requires an end tag Example h3 cfsilent h3 cfsilent cfset a 100...

Page 400: ...r vSpace integer hSpace integer align alignment lookAndFeel motif or windows or metal vertical yes or no bgColor color textColor color font font_name fontSize integer italic yes or no bold yes or no n...

Page 401: ...idate Optional Custom JavaScript function to validate user input in this case a change to the default slider value Specify only the function name message Optional Message text to appear if validation...

Page 402: ...er label For a hexadecimal value use the form bgColor xxxxxx where x 0 9 or A F use two number signs or none Any color in hexadecimal format black red blue magenta cyan orange darkgray pink gray white...

Page 403: ...how to use cfslider within cfform h3 cfslider Example h3 p cfslider used within a cfform can provide functionality to Java enabled browsers p Try moving the slider back and forth to see the real time...

Page 404: ...Fusion MX Developer s Guide History ColdFusion MX 7 Added the result attribute ColdFusion MX Deprecated the connectString dbName dbServer dbtype provider and providerDSN attributes They do not work an...

Page 405: ...e same time to avoid overwriting the results of one call with another If you set the result attribute to myResult for example you would access ExecutionTime as myResult ExecutionTime Otherwise you wou...

Page 406: ...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 cfoutput cfou...

Page 407: ...an put the cfdefaultcase tag at any position within a cfswitch statement it is not required to be the last item Attributes Usage This tag requires an end tag All code within this tag must be within a...

Page 408: ...a cfloop construct p Each time the case is fulfilled the specific information is printed if the case is not fulfilled the default case is output p cfoutput query GetEmployees cfswitch expression Trim...

Page 409: ...of_lines HTMLTable border colHeaders startRow row_number cftable See also cfcol cfcontent cflog cfoutput cfprocessingdirective cftable Retrieving data in Chapter 20 Accessing and Retrieving Data in Co...

Page 410: ...SELECT Emp_ID FirstName 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 fo...

Page 411: ...cftable 411 cftable body html...

Page 412: ...ActionScript onMouseUp JavaScript or ActionScript onMouseDown JavaScript or ActionScript onChange JavaScript or ActionScript onClick JavaScript or ActionScript visible Yes or No enabled Yes or No tool...

Page 413: ...the format For details see the Usage section of the cfinput tag reference validateAt Optional HTML and XML onSubmit How to do the validation one or more of the following onSubmit onServer onBlur For...

Page 414: ...ue to display in text control You can specify an initial value as an attribute or in the tag body but not in both places If you specify the value as an attribute you must put the closing cftextarea ta...

Page 415: ...uide Flash form data binding The bind attribute lets you populate form fields using the contents of other form fields To specify text from another field in a cftextarea bind attribute use the followin...

Page 416: ...re on a single line to ensure that only the desired text displays but the line is split in this example for formatting purposes h3 cftextarea Example h3 cfparam name text2 default cfif isdefined form...

Page 417: ...ed in XML format forms In its place you should use a cfinput or cftextarea tag and use a cascading style sheet CSS to specify the text style characteristics History ColdFusion MX 7 This tag is depreca...

Page 418: ...try onError Chapter 14 Handling Errors in ColdFusion MX Developer s Guide History ColdFusion MX Changed thrown exceptions this tag can throw ColdFusion component method exceptions Attributes Attribute...

Page 419: ...name obj If your exception class 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 sp...

Page 420: ...t cfcatch cftry Example2 The following example shows how to throw an exception from a component method cfcomponent cffunction name getEmp cfargument name lastName required yes cfquery name empQuery da...

Page 421: ...long it takes for a block of code to execute You can nest cftimer tags This tag is useful for debugging CFML code during application development In production you can leave cftimer tags in your code a...

Page 422: ...lect from CourseList cfquery table border 1 width 100 cfoutput query coursequery tr td Course_ID td td CorName td td CorLevel td tr cfoutput table cftimer hr br type comment cftimer label Query and CF...

Page 423: ...r 423 from Departments cfquery p Scroll down to CFTimer Times heading to see timing information p table border 1 width 100 cfoutput query deptquery tr td Dept_ID td td Dept_Name td tr cfoutput table c...

Page 424: ...Trace 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 cferr...

Page 425: ...8 5187 ms 10 C CFusionMX7 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 object...

Page 426: ...Attributes Attribute Req Opt Default Description action Optional begin begin the start of the block of code to execute commit commits a pending transaction rollback rolls back a pending transaction is...

Page 427: ...the cftransaction action rollback tag within the block In these examples the slash is alternate syntax that is the equivalent of an end tag Within a transaction block you can write queries to more tha...

Page 428: ...s or metal font font fontSize size italic yes or 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 style...

Page 429: ...ribute For details of the structure contents see object format xml generates an XML representation of the tree In XML format forms includes the generated XML in the form In HTML format forms puts the...

Page 430: ...et object windows motif renders the slider in Motif style windows renders the slider in Windows style metal renders the slider in Java Swing style If the platform does not support a style option the t...

Page 431: ...ifying whether to show the control Space that would be occupied by an invisible control is blank tooltip Optional Flash Flash format only Text to display when the mouse pointer hovers over the control...

Page 432: ...pulates this tag s options continues to display after the user submits the form The cfform preserveData attribute is set to Yes The cfform action attribute posts to the same page as the form itself th...

Page 433: ...th highlightHref lookAndFeel appendKey delimiter hScroll name bold fontWeight italic vscroll border Field Value children This item s child items an array of item structures display Tree item label as...

Page 434: ...uery name GetEmployees dataSource cfdocexamples SELECT Emp_ID FirstName LastName EMail Phone Department FROM Employees GROUP BY Department Emp_ID FirstName LastName EMail Phone cfquery html body h3 cf...

Page 435: ...d and contact info children cftreeitem value Emp_ID display Employee ID Emp_ID parent LastName FirstName img remote Each node must be unique value so use Emp_ID om value cftreeitem value Emp_ID _Conta...

Page 436: ...The supplied XSLT skins do not handle or display XML format trees but do display applet and Flash format trees Attribute Req Opt Format Default Description value Required All Value passed when cfform...

Page 437: ...r the img attribute href Optional All URL to link to if the user clicks the tree item If you use a query attribute the href attribute can specify a query column that contains URLs If href is not a que...

Page 438: ...name ColdFusion links back to the same page and displays the selected employee s ID Query the datasource to get employee information Group the output by Department All fields are required in Group By...

Page 439: ...ees expand yes This cfoutput tag loops over the records for the department The cfoutput tag does not need any attributes cfoutput Create an item for each employee in the department Do not expand child...

Page 440: ...re equivalent to the cftry and cfcatch tags Usage Within a cftry block put the code that might throw an exception followed by one ore more cfcatch tags that catch and process exceptions This tag requi...

Page 441: ...cftry 441 cfset sCurrent CFCATCH TAGCONTEXT i br i sCurrent ID sCurrent LINE sCurrent COLUMN sCurrent TEMPLATE cfloop cfoutput cfcatch cftry...

Page 442: ...providerDSN attributes They do not work and might cause an error in releases later than ColdFusion 5 Attributes Attribute Req Opt Default Description dataSource Required Name of the data source that c...

Page 443: ...emp_id url id cfquery This code displays the row to edit for update cfoutput query phoneQuery form action cfupdate cfm method post phoneQuery firstName phoneQuery lastName input name phone type text...

Page 444: ...es or no validate yes or no See also cfcollection cfdump cfexecute cfindex cfobject cfreport cfsearch ToScript Chapter 35 Using XML and WDDX in ColdFusion MX Developer s Guide History ColdFusion MX Ch...

Page 445: ...y Create a simple query cfquery name q dataSource cfdocexamples select Message_Id Thread_id Username from messages cfquery The recordset data is p cfoutput query q topLevelVariable Required if action...

Page 446: ...action cfml2wddx input q output wddxText Display WDDX XML packet Resulting WDDX packet is xmp cfoutput wddxText cfoutput xmp Deserialize to a variable named wddxResult Deserializing WDDX packet p cfwd...

Page 447: ...f your XML object is case sensitive you cannot use dot notation to reference an element or attribute name Use the name in associative array bracket notation or a reference that does not use the case s...

Page 448: ...var cfoutput mynewvar cfoutput cfprocessingdirective The cfprocessingdirective tag prevents ColdFusion from putting white space characters in front of the XML declaration Example This following exampl...

Page 449: ...ions and manipulate data The following table lists CFML functions Abs GetFunctionList Max ACos GetGatewayHelper Mid AddSOAPRequestHeader GetHttpRequestData Min AddSOAPResponseHeader GetHttpTimeString...

Page 450: ...List BitMaskRead Int ReplaceNoCase BitMaskSet IsArray REReplace BitNot IsBinary REReplaceNoCase BitOr IsBoolean Reverse BitSHLN IsCustomFunction Right BitSHRN IsDate RJustify BitXor IsDebugMode Round...

Page 451: ...stFindNoCase StructUpdate DecimalFormat ListFirst Tan DecrementValue ListGetAt TimeFormat Decrypt ListInsertAt ToBase64 DeleteClientVariable ListLast ToBinary DirectoryExists ListLen ToScript DollarFo...

Page 452: ...454 Mathematical functions 455 Other functions 455 Query functions 455 String functions 455 Structure functions 456 System functions 456 XML functions 457 Array functions GetBaseTagList LSIsNumeric X...

Page 453: ...IsLeapYear Quarter CreateODBCTime DayOfWeekAsString IsNumericDate Second CreateTime DayOfYear LSDateFormat TimeFormat CreateTimeSpan DaysInMonth LSIsDate Week DateAdd DaysInYear LSParseDateTime Year D...

Page 454: ...mat LSParseNumber YesNoFormat GetLocaleDisplayName LSIsCurrency LSTimeFormat DE Evaluate IIf SetVariable CreateObject ReleaseComObject ToScript GetGatewayHelper SendGatewayMessage GetK2ServerDocCount...

Page 455: ...ims ListLen Find ListContains ListPrepend Abs BitNot FormatBaseN Randomize ACos BitOr IncrementValue RandRange ArrayAvg BitSHLN InputBaseN Round ArraySum BitSHRN Int Sgn ASin BitXor Log Sin Atn Ceilin...

Page 456: ...aphFormat StripCR Compare LCase ParseDateTime ToBase64 CompareNoCase Left REFind ToBinary DayOfWeekAsString Len REFindNoCase ToString Decrypt LJustify RemoveChars Trim Encrypt ListValueCount RepeatStr...

Page 457: ...OAPRequest IsXmlRoot XmlGetNodeType AddSOAPResponseHeader IsXML IsWDDX XmlNew GetSOAPRequest IsXmlAttribute ToString XmlParse GetSOAPRequestHeader IsXmlDoc XmlChildPos XmlSearch GetSOAPResponse IsXmlE...

Page 458: ...serInRole All ColdFusion MX IsValid All ColdFusion MX 7 IsXML All ColdFusion MX 7 IsXmlAttribute All ColdFusion MX 7 IsXmlDoc All ColdFusion MX IsXmlElem All ColdFusion MX IsXmlNode All ColdFusion MX...

Page 459: ...All ColdFusion MX XmlParse All ColdFusion MX XmlParse validator parameter ColdFusion MX 7 XmlSearch All ColdFusion MX XmlTransform All ColdFusion MX XmlTransform parameters parameter ColdFusion MX 7...

Page 460: ...Do not use them in ColdFusion applications They do not work in releases later than ColdFusion 5 Function Parameter or value Obsolete as of this ColdFusion release AuthenticatedContext All ColdFusion...

Page 461: ...tegory 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 cfoutput Abs 1 Abs 3 Abs 4 Abs 3...

Page 462: ...mple h3 output 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...

Page 463: ...pace and name parameters If you require a namespace define it within the XML itself Example There are two parts to this example The first part is the web service CFC that this function as well as the...

Page 464: ...APRequestHeader ws ignoredNameSpace ignoredName doc Invoke the web service operation ret ws echo_me argument Get the first header as an object string and as XML header getSOAPResponseHeader ws http ww...

Page 465: ...e function It throws an error if it is invoked in a context that is not a web service request If you pass XML in the value parameter ColdFusion ignores the namespace and name parameters If you require...

Page 466: ...e username cfset xmlusername getSOAPRequestHeader http mynamespace username TRUE cfset return return br as XML xmlusername Get the second header as a string and as XML cfset password getSOAPRequestHea...

Page 467: ...name GetEmployeeNames datasource cfdocexamples 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 Valu...

Page 468: ...contains a comma delimited list of the names of the fields on the form Example This example shows the use of ArrayAvg The following lines of code keep track of the form fields that can be dynamically...

Page 469: ...mber LoopItem td cfoutput tr cfloop table input type submit name submit value get the average form create an array cfif IsDefined FORM submit cfset myNumberArray ArrayNew 1 cfset Count 1 cfloop index...

Page 470: ...sed on XML objects Parameters Example h3 ArrayClear 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 content...

Page 471: ...Guide History ColdFusion MX Changed behavior this function can be used on XML objects Changed thrown exceptions this function can throw the InvalidArrayIndexException error Parameters Throws If this f...

Page 472: ...y 3 1 nbsp nbsp DaysArray 3 2 br cfoutput cfoutput We delete this element of the array br ArrayDeleteAt DaysArray 2 br cfoutput the formerly third element Wednesday is second element p This is what th...

Page 473: ...exceptions this function can throw the InvalidArrayIndexException error Parameters Usage To apply the ArrayInsert function to a multidimensional array you must specify all but the last index in the a...

Page 474: ...DaysArray 3 Thursday add an element before position 3 p Add an element before position 3 cfoutput ArrayInsertAt DaysArray 3 Wednesday cfoutput p Now output the array as a list cfoutput ArrayToList Da...

Page 475: ...can be used on XML objects Parameters Example 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 t...

Page 476: ...en Example h3 cfquery name GetEmployeeNames datasource cfdocexamples SELECT FirstName LastName FROM Employees cfquery create an array cfset myArray ArrayNew 1 set element one to show where we are cfse...

Page 477: ...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 largest nu...

Page 478: ...two elements 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...

Page 479: ...s 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 MyNewArray 6 Anot...

Page 480: ...tName 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 query Append names successively before last element l...

Page 481: ...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 cfdocexamples SELECT FRO...

Page 482: ...Changed behavior this function can be used on XML objects Parameters Example h3 ArraySet Example h3 Make an array cfset MyNewArray ArrayNew 1 ArrayToList does not function properly if the Array has no...

Page 483: ...ts are returned in a textnocase descending sort this function might return elements in a different sort order than in earlier releases If sort_type textnocase and sort_order desc ColdFusion MX process...

Page 484: ...habetically cfset isSuccessful ArraySort myArray textnocase desc sort_type numeric sorts numbers text sorts text alphabetically taking case into account also known as case sensitive All letters of one...

Page 485: ...e 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 to add the...

Page 486: ...1 position2 See also Functions for XML object management in Chapter 35 Using XML and WDDX in ColdFusion MX Developer s Guide Parameters Example h3 ArraySwap Example h3 cfset month ArrayNew 1 cfset mon...

Page 487: ...oop query GetEmployeeNames cfset temp ArrayAppend myArray FirstName LastName cfloop show the resulting array as a list cfset myList ArrayToList myArray sort that array descending alphabetically cfset...

Page 488: ...up to a 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...

Page 489: ...inNum cfif FORM SinNum LESS THAN OR EQUAL TO 1 cfif FORM SinNum GREATER THAN OR EQUAL TO 1 ASin cfoutput FORM SinNum cfoutput cfoutput ASin FORM sinNum Radians cfoutput br or br ASin cfoutput FORM Sin...

Page 490: ...sine of the angle to calculate in degrees and radians The value must be between 1 and 1 inclusive h4 cfif cfif form action evaltest cfm method post p Enter a number to get its arcsine in Radians and...

Page 491: ...ans 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 is cfoutput Atn FORM AtnNu...

Page 492: ...function is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX This function is o...

Page 493: ...n is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX This function is obsolete...

Page 494: ...media recommends that you use the BinaryDecode function not the ToBinary base64data function to convert Base64 encoded data to binary data in all new applications See the following pages for additiona...

Page 495: ...inary data cfscript binencode BinaryEncode binimage Form binEncoding bindecode BinaryDecode binencode Form binEncoding cfscript Write the converted results to a file cffile action write file C temp he...

Page 496: ...nary format use the BinaryDecode function Macromedia recommends that you use the BinaryEncode function and not the ToBase64 binarydata function to convert binary data to Base64 data in all new applica...

Page 497: ...ert the read data to binary encoding and back to binary data cfscript binencode BinaryEncode binimage Form binEncoding bindecode BinaryDecode binencode Form binEncoding cfscript Write the converted re...

Page 498: ...o BitNot BitOr 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...

Page 499: ...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 BitMaskClea...

Page 500: ...igned integers 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 cf...

Page 501: ...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 255 255 4...

Page 502: ...nctions Function 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 Re...

Page 503: ...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 integers p Bit...

Page 504: ...tions operate 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 c...

Page 505: ...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 BitSHRN 1...

Page 506: ...BitAnd BitNot 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 Bi...

Page 507: ...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 4 p The ce...

Page 508: ...ect In releases of ColdFusion through ColdFusion MX 6 1 you had to use the ToBase64 function to convert the string to Base64 and then use the ToBinary function to convert strings to binary data Parame...

Page 509: ...charencode CharsetEncode chardecode Form charEncoding cfscript Display the input values and results cfoutput h3 Parameter Settings h3 p b The string b br Form myString p p b The character encoding b...

Page 510: ...hapter 3 ColdFusion Functions textArea name myString cols 40 rows 5 WRAP VIRTUAL The following four characters are not in all character encodings textArea br br input type Submit value convert my data...

Page 511: ...mmends that you use this function and not the ToString function to convert binary data to strings in all new applications Parameter Description binaryobject A variable containing binary data to decode...

Page 512: ...Encoding charencode CharsetEncode chardecode Form charEncoding cfscript Display the input values and results cfoutput h3 Parameter Settings h3 p b The string b br Form myString p p b The character enc...

Page 513: ...CharsetEncode 513 textArea name myString cols 40 rows 5 WRAP VIRTUAL The following four characters are not in all character encodings textArea br br input type Submit value convert my data form...

Page 514: ...hr 13 returns a carriage return character The 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...

Page 515: ...Chr 515 maxlength 5 p input type Submit name input type RESET cfform...

Page 516: ...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 517: ...function performs a I case sensitive I comparison of two strings cfif IsDefined FORM string1 cfset comparison Compare FORM string1 FORM string2 switch on the variable to give various responses cfswitc...

Page 518: ...the default case h3 CFDEFAULTCASE cfswitch cfif form action compare cfm method post p String 1 br input type Text name string1 p String 2 br input type Text name string2 p input type Submit value Com...

Page 519: ...CompareNoCase Example H3 P This function performs a I case insensitive I comparison of two strings CFIF IsDefined form string1 CFSET comparison Comparenocase form string1 form string2 switch on the v...

Page 520: ...unctions CFSWITCH CFIF FORM ACTION comparenocase cfm METHOD POST 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 N...

Page 521: ...0 To test for a 0 value check whether the value is less than 0 0000000000001 Example h3 Cos Example h3 Calculate cosine if form has been submitted cfif IsDefined FORM cosNum Make sure input is a numb...

Page 522: ...ColdFusion Functions cfif cfif form action CGI script_name method post Enter an angle in degrees to get its cosine br input type Text name cosNum size 15 br br input type Submit name nbsp nbsp input t...

Page 523: ...value generated with CreateDate CFSET yourDate CreateDate form year form month form day cfoutput ul li Formatted with CreateDate CreateDate form year form month form day li Formatted with CreateDateT...

Page 524: ...at CreateODBCDate yourDate mmmm d yyyy li Formatted with CreateODBCDateTime and DateFormat DateFormat CreateODBCDateTime yourDate d m yy ul cfoutput CFIF CFFORM ACTION createdate cfm METHOD POST p Ent...

Page 525: ...month form day form 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...

Page 526: ...ar month and day in integer format for a date to view PRE Year CFINPUT TYPE Text NAME year VALUE 1998 VALIDATE integer REQUIRED Yes Month CFINPUT TYPE Text NAME month VALUE 6 RANGE 1 12 MESSAGE Please...

Page 527: ...hod in the CFC file For more information see ColdFusion MX Developer s Guide For CORBA object changed the Naming Service separator format for addresses from a dot to a forward slash For example if con...

Page 528: ...ity Note On UNIX this function does not support COM objects Returns A COM object Function syntax CreateObject type class context serverName See also ReleaseComObject cfobject Chapter 38 Integrating CO...

Page 529: ...ject 529 Usage The following example creates the Windows Collaborative Data Objects CDO for NTS NewMail object to send mail You would use this code within a cfscript tag Mailer CreateObject COM CDONTS...

Page 530: ...ly with the identical character casing In the following example the CFScript statements assign the tellTimeCFC variable to the tellTime component using the CreateObject function The CreateObject funct...

Page 531: ...formats Macromedia Eng CF Macromedia current Eng current CF Parameter Description type Type of object to create com corba java component webservice context IOR ColdFusion uses IOR to access CORBA ser...

Page 532: ...ct s naming 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...

Page 533: ...hod 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 a static...

Page 534: ...2001 TemperatureService wsdl xlatstring ws getTemp zipcode 55987 writeoutput The temperature at 55987 is xlatstring cfscript Parameter Description type Type of object to create com corba java componen...

Page 535: ...value use the attributes validate integer and range 1 12 Example h3 CreateODBCDate Example h3 CFIF IsDefined form year p Your date value generated with CreateDateTime cfset yourDate CreateDateTime for...

Page 536: ...quired yes Month cfinput type 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...

Page 537: ...ateTime Example h3 cfif IsDefined form year Your date value generated using CreateDateTime cfset yourDate CreateDateTime form year form month form day form hour form minute form second cfoutput ul li...

Page 538: ...NAME month VALUE 6 RANGE 1 12 MESSAGE Enter a month 1 12 VALIDATE integer REQUIRED Yes Day cfinput type text name day value 8 range 1 31 MESSAGE Enter a day of the month 1 31 VALIDATE integer REQUIRED...

Page 539: ...ime value created with CreateTime cfset yourTime CreateTime form hour form minute form second cfoutput ul li Formatted with CreateODBCTime CreateODBCTime yourTime li Formatted with TimeFormat TimeForm...

Page 540: ...IsDefined FORM hour Your time value presented using CreateTime time function cfset yourTime CreateTime FORM hour FORM minute FORM second cfoutput ul li Formatted with timeFormat TimeFormat yourTime li...

Page 541: ...CreateTime 541 MESSAGE You must enter a value for seconds 0 59 VALIDATE integer REQUIRED Yes PRE p input type submit name input type reset cfform...

Page 542: ...ibute of cfquery and the original query date falls within the time span you define cached query data is used In this case the CreateTimeSpan function is used to define a period of time from the presen...

Page 543: ...you are displaying cfoutput query GetParks StartRow StartRow maxrows 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 s...

Page 544: ...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 distr...

Page 545: ...g a date time object as a string you must enclose it in quotation marks Otherwise it is interpreted as a numeric representation of a date time object Example This example shows the use of DateAdd cfpa...

Page 546: ...ers cfcase cfcase value m months cfcase cfcase value y days of year cfcase cfcase value w weekdays cfcase cfcase value ww weeks cfcase cfcase value h hours cfcase cfcase value n minutes cfcase cfcase...

Page 547: ...7 option value yyyy years option value m selected months option value d days option value ww weeks option value h hours option value n minutes option value s seconds select input type Submit value Sub...

Page 548: ...h3 p The DateCompare function compares two date time values cfif IsDefined FORM date1 cfif IsDate FORM date1 and IsDate FORM date2 cfset comparison DateCompare FORM date1 FORM date2 FORM precision swi...

Page 549: ...date2 cfoutput Date 2 h3 I The dates are not equal I cfcase cfdefaultcase h3 This is the default case h3 cfdefaultcase cfswitch cfelse h3 Enter two valid date values h3 cfif cfif form action datecompa...

Page 550: ...550 Chapter 3 ColdFusion Functions option select p input type Submit value Compare these dates name input type reset form...

Page 551: ...on for example DateConvert CreateDate 2001 3 3 Example h3 DateConvert Example h3 This shows conversion of current date time to UTC and back cfset curDate Now p cfoutput The current date and time curDa...

Page 552: ...r required Yes td tr tr td Month td td input type Text name month value 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 ran...

Page 553: ...ses Changed the w and ww masks they determine the number of full weeks between the two dates Parameters Usage The DateDiff function determines the number of complete datepart units between the two dat...

Page 554: ...se value y days cfcase cfcase value d days cfcase cfcase value w weekdays cfcase cfcase value ww weeks cfcase cfcase value h hours cfcase cfcase value n minutes cfcase cfcase value s seconds cfcase cf...

Page 555: ...UT Date 2 input type Text name date2 value CFOUTPUT DateFormat Now CFOUTPUT What kind of unit to show difference select name type option value yyyy selected years option value q quarters option value...

Page 556: ...D 9999 AD mask Characters that show how ColdFusion displays a date d Day of the month as digits no leading zero for single digit days dd Day of the month as digits leading zero for single digit days d...

Page 557: ...les see TechNote 22183 ColdFusion Server 5 and 4 5 x with Oracle Formatting Date and Time Query Results on the Macromedia website at www coldfusion com Support KnowledgeBase SearchForm cfm Note The Da...

Page 558: ...as a string you must enclose it in quotation marks Otherwise it is interpreted as a numeric representation of a date time object Example This example shows information available from DatePart cfset to...

Page 559: ...todayDate li month DatePart m todayDate li day of year DatePart y todayDate li day DatePart d todayDate li weekday DatePart w todayDate li week DatePart ww todayDate li hour DatePart h todayDate li m...

Page 560: ...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 561: ...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 562: ...the DayOfWeekAsString function It is the action page for a form that submits year month and day fields h3 DayOfWeekAsString Example h3 cfif IsDefined FORM year More information about your date cfset y...

Page 563: ...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 564: ...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 565: ...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 566: ...atically evaluates its second and third parameters as expressions You can use the DE function to prevent the function from evaluating a string parameter that is to be output as a variable and should n...

Page 567: ...and surrounds it in quotation marks 5 The IIF function returns the string Green including the quotation marks 6 The cfset tag gets the expression result Green and sets the value of the myresult varia...

Page 568: ...Error B Try a simple expression such as 2 2 h3 cfoutput Display the diagnostic message from ColdFusion p cfcatch message cfoutput cfcatch cftry cfif h3 Enter any valid ColdFusion expression h3 cfform...

Page 569: ...parator 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 deci...

Page 570: ...nction syntax 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 Decrem...

Page 571: ...the following algorithms CFMX_COMPAT the algorithm used in ColdFusion MX and prior releases This algorithm is the least secure option default AES the Advanced Encryption Standard specified by the Nati...

Page 572: ...g if the form has been submitted cfif IsDefined Form myString cfscript GenerateSecretKey does not generate key for the CFMX_COMPAT algorithm so use the key from the form if Form myAlgorithm EQ CFMX_CO...

Page 573: ...tion option DESEDE option select br br b Input your key b used for CFMX_COMPAT encryption only br input type Text name myKey value MyKey br br b Enter string to encrypt b br textArea name myString col...

Page 574: ...e h3 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 re...

Page 575: ...3 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 yourDirectory...

Page 576: ...ting functions Function syntax DollarFormat number See also DecimalFormat NumberFormat Parameters Example This example shows the use of DollarFormat h3 DollarFormat Example h3 cfloop from 8 to 50 inde...

Page 577: ...structures and queries Note The Duplicate function throws an exception if you attempt to duplicate a CFC Note With this function you cannot duplicate a COM CORBA or JAVA object returned from the cfobj...

Page 578: ...use to decrypt the string ColdFusion MX installs a cryptography library with the following algorithms CFMX_COMPAT the algorithm used in ColdFusion MX and prior releases This algorithm is the least sec...

Page 579: ...than the other available algorithms Example The following example encrypts and decrypts a text string It lets you specify the encryption algorithm and encoding technique It also has a field for a key...

Page 580: ...br select size 1 name myAlgorithm option selected CFMX_COMPAT option option AES option option DES option option DESEDE option select br br b Input your key b used for CFMX_COMPAT encryption only br in...

Page 581: ...ion is 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 followi...

Page 582: ...number FORM number 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...

Page 583: ...Changed behavior for the relative_path parameter this function can now accept an absolute or relative path in the relative_path parameter To resolve a path this function uses virtual mappings that ar...

Page 584: ...Your file was not found in this directory br Here is a list of the other files in this directory use CFDIRECTORY to give the contents of the snippets directory order by name and size CFDIRECTORY DIRE...

Page 585: ...MX in the Server Configuration as a Windows service by default it runs under the local system account which does not have sufficient privileges to access remote systems You can change this however on...

Page 586: ...tput 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 findnocase the stringToSearc...

Page 587: ...rns 33 as the first position found because the is lowercase The FindNoCase function returns 1 as the first postion because the case is ignored cfset stringToSearch The quick brown fox jumped over the...

Page 588: ...e 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 findnocase the stringToSearch b...

Page 589: ...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 is inter...

Page 590: ...matical functions 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 equ...

Page 591: ...ecified 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 cfoutput...

Page 592: ...Sun Java 1 4 2 runtime that includes the Sun JCE default security provider This provider includes the algorithms listed in the Parameters section The JCE framework includes facilities for using other...

Page 593: ...generate a secret key else theKey generateSecretKey Form myAlgorithm Encrypt the string encrypted encrypt Form myString theKey Form myAlgorithm Form myEncoding Decrypt it decrypted decrypt encrypted t...

Page 594: ...ed for CFMX_COMPAT encryption only br input type Text name myKey value foobar br br b Enter string to encrypt b br textArea name myString cols 40 rows 5 WRAP VIRTUAL This string will be encrypted you...

Page 595: ...Applications in ColdFusion MX Developer s Guide History ColdFusion MX Added this function Usage This function works with cflogin authentication or web server authentication It checks for a logged in u...

Page 596: ...hapter 11 Creating and Using Custom CFML Tags in ColdFusion MX Developer s Guide Parameters Example This example shows the use of GetBaseTagData function Typically used in custom tags cfif trim inCust...

Page 597: ...he ancestor tag list cfif cfelseif cfelse cfswitch cfcase cfdefaultcase cftry cfcatch This function displays the following tags only under the following conditions cfloop if it uses a query attribute...

Page 598: ...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 599: ...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 600: ...ext GetRequest GetContextPath On J2EE configurations it returns the path from the Web root to the J2EE context root of the ColdFusion MX J2EE application On server configurations it returns the empty...

Page 601: ...sts 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 function...

Page 602: ...h cfif IsDefined FORM yourFile cfif FORM yourFile is not cfset yourFile FORM yourFile cfif FileExists ExpandPath yourfile p Your file exists in this directory You entered the correct file name GetFile...

Page 603: ...mPath 603 cfoutput form action getdirectoryfrompath cfm METHOD post H3 Enter the name of a file in this directory I FONT SIZE 1 try expandpath cfm FONT I H3 input type Text NAME yourFile input type Su...

Page 604: ...ds of a form that was submitted to the 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...

Page 605: ...GetEncoding 605 WriteOutput The encoding is theEncoding cfscript cfif...

Page 606: ...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 607: ...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 608: ...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 609: ...at implements the GatewayHelper class For example an instant messaging event gateway might make buddy list management functions available in a GatewayHelper object An event gateway listener CFC can ge...

Page 610: ...ludes an addBuddy method that takes a single String parameter you could use the following code to get the GatewayHelper object and add a buddy to the buddies list h3 GetGatewayHelper Example h3 cfscri...

Page 611: ...on cfset x GetHttpRequestData 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...

Page 612: ...612 Chapter 3 ColdFusion Functions tr td server_protocol td td x protocol td tr table b http_content x content b cfoutput...

Page 613: ...only used in Internet protocols including HTTP Category Date and time functions International functions Function syntax GetHttpTimeString date_time_object See also GetLocale GetTimeZoneInfo SetLocale...

Page 614: ...erity collections Category Full text search functions Query functions Function syntax GetK2ServerDocCount See also GetK2ServerDocCountLimit History ColdFusion MX 6 1 Deprecated this function It might...

Page 615: ...ion syntax GetK2ServerDocCountLimit See also GetK2ServerDocCount History ColdFusion MX 6 1 Deprecated this function It might not work and it might cause an error in later releases ColdFusion MX Added...

Page 616: ...ame function which returns portugu s Brasil and catal Espanya This function determines whether a locale value is set for ColdFusion MX The value is set with the SetLocale function If the ColdFusion MX...

Page 617: ...e to the submitted value and save the old ColdFusion locale name cfset oldlocale SetLocale form mylocale Get the current locale It should have changed New locale GetLocale br cfif Self submitting form...

Page 618: ...n the current locale and in other locales It lets you select a locale from all supported locales changes the ColdFusion MX locale to the selected locales and displays the old and new locale names html...

Page 619: ...name in current locale GetLocaleDisplayName oldlocale br Old locale s display name in en_US GetLocaleDisplayName oldlocale en_US br cfif Self submitting form to select the new locale cfform h3 Please...

Page 620: ...story ColdFusion MX 7 Added support for getting query object metadata ColdFusion MX Added this function Parameters Usage This function provides information about application data and lets applications...

Page 621: ...r Custom Tag Paths page output Value of the cfcomponent tag output attribute if any path Absolute path to the component properties Array of structures containing metadata specified by the component s...

Page 622: ...data getMetaData componentutils cfscript h4 Metadata for the CFC component utilities h4 cfdump var utilmetadata use GetMetadata to get the names and data types of the fields in the cfdocexamples Emplo...

Page 623: ...CT FROM Employees cfquery cfset employeemeta getMetaData getemployees h4 The Employees table has the following columns h4 cfloop index i from 1 to arrayLen employeemeta cfoutput employeemeta i name em...

Page 624: ...is otherwise displayed in the Windows PerfMonitor simple_load Returns an integer value that is computed from the state of the server s internal queues Indicates the overall server load prev_req_time R...

Page 625: ...r you can set the maximum number of requests that run concurrently ReqTimedOut Number of HTTP requests that timed out while in the staging queue or during processing BytesIn Number of bytes in HTTP re...

Page 626: ...e equivalent of the corresponding standard JSP tags You use these methods to call JSP pages and servlets For example you use the following code in CFScript to include the JSP page hello jsp and pass i...

Page 627: ...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 a val...

Page 628: ...et the value of timeout in an initialization 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 specif...

Page 629: ...GetProfileString 629 tr td input type Submit name Submit value Submit td td td tr table form...

Page 630: ...ion error Unable to use getSOAPRequest not processing a web service request If you call this function from within a web service CFC you can omit the webservice argument The function executes against t...

Page 631: ...SOAPRequest is called from the client here whereas often it would be called from within the web service CFC cfscript ws CreateObject webservice http localhost soapheaders headerservice cfc WSDL ws ech...

Page 632: ...er as a string If you specify True for the asXML parameter ColdFusion retrieves the header as raw XML This function throws an error if it is invoked in a context that is not a web service request Use...

Page 633: ...et password getSOAPRequestHeader http mynamespace password cfset return return The service saw password password cfset xmlpassword getSOAPRequestHeader http mynamespace password TRUE cfset return retu...

Page 634: ...makes a request to execute the echo_me function of the headerservice cfc web service Following the request the example calls the GetSOAPResponse function to get the SOAP response and then calls cfdum...

Page 635: ...i type attribute is not available ColdFusion attempts to retrieve the header as a string If you specify True for the asXML parameter ColdFusion retrieves the header as raw XML Used within CFML code by...

Page 636: ...ord XmlAttributes xsi type xsd string addSOAPRequestHeader ws ignoredNameSpace ignoredName doc Invoke the web service operation ret ws echo_me argument Get the first header as an object string and as...

Page 637: ...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 638: ...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 639: ...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 640: ...L code segments 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 Set...

Page 641: ...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 642: ...tan red pink brown 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 myst...

Page 643: ...thirteen and four In the following call against mystring no spaces are specified in delimiters it is omitted so the function uses the space character as the string delimiter br cfoutput GetToken myst...

Page 644: ...This substring is five nine zero Example h3 GetToken Example h3 cfif IsDefined FORM yourString set delimiter cfif FORM yourDelimiter is not cfset yourDelimiter FORM yourDelimiter cfelse cfset yourDeli...

Page 645: ...used in ColdFusion MX and prior releases SHA Generates a 28 character string using the Secure Hash Standard SHA 1 algorithm specified by Nation Institute of Standards and Technology NIST FIPS 180 2 S...

Page 646: ...sm for generating identical hash values on systems with different default encodings ColdFusion uses a default encoding of UTF 8 unless you modify the defaultCharset entry in the neo runtime xml file E...

Page 647: ...rm for entering ID and password form action CGI SCRIPT_NAME method post b User ID b input type text name UserID br b Password b input type text name password br br input type Submit value Encrypt my S...

Page 648: ...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 649: ...at string version See also HTMLEditFormat Parameters Usage This function converts the following characters to HTML character entities This function typically increases the length of a string This can...

Page 650: ...then View it using your browser s the View Source command cfset testString This is a test this is another This text is in angle brackets Previous line was blank cfoutput h3 The text without processin...

Page 651: ...lp protect ColdFusion pages that return user provided data to the client browser from cross site scripting attacks However the scriptprotect attribute of the cfapplication tag or the equivalent This s...

Page 652: ...of HTMLCodeFormat and HTMLEditFormat View it in your browser then View it using your browser s the View Source command cfset testString This is a test this is another This text is in angle brackets P...

Page 653: ...eters 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 stri...

Page 654: ...t throw an error In the following example LocalVar is undefined however if you omit number signs around LocalVar the code works properly cfoutput IIf IsDefined LocalVar LocalVar DE The variable is not...

Page 655: ...IIf 655 cfoutput IIf Hour Now GTE 12 DE It is afternoon or evening DE It is morning cfoutput b...

Page 656: ...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 657: ...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 658: ...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 659: ...ns An integer as a string Category Mathematical 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 nu...

Page 660: ...s True In earlier releases it returns False Changed behavior this function can be used on XML objects Parameters Usage Use this function to determine whether a value is an array or query column This f...

Page 661: ...is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX This function is obsolete It...

Page 662: ...is function is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX This function is...

Page 663: ...32 to 255 from the 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 bina...

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

Page 665: ...oolean 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 FORM the...

Page 666: ...rst instantiate the component Note To prevent undefined variable exceptions always precede IsCustomFunction with an IsDefined test as shown in the example Example h3 IsCustomFunction Example h3 cfscri...

Page 667: ...Example using a CFC defined in TestCFC cfc cfobject component TestCFC name myTestCFCobject CFIF IsDefined myTestCFCobject testFunc AND IsCustomFunction myTestCFCobject testFunc myTestCFCobject testFun...

Page 668: ...This function checks 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 theTes...

Page 669: ...unctions 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 showDebugOutput...

Page 670: ...r this function can process only the following constructs A simple variable A named variable with dot notation A named structure with dot notation for example mystruct key Parameters Usage When workin...

Page 671: ...ime through this template the variable form myString has not yet been defined so we do not try to evaluate it cfif form action CGI Script_Name method POST input type Text name MyString value My sample...

Page 672: ...sion functions Full text search functions Query functions Function syntax IsK2ServerABroker See also GetK2ServerDocCountLimit IsK2ServerDocCountExceeded IsK2ServerOnline History ColdFusion MX 6 1 Depr...

Page 673: ...sion functions Full text search functions Query functions Function syntax IsK2ServerDocCountExceeded See also GetK2ServerDocCountLimit IsK2ServerABroker History ColdFusion MX 6 1 Deprecated this funct...

Page 674: ...s available to perform a search False otherwise Category Decision functions Full text search functions Query functions Function syntax IsK2ServerOnline See also IsK2ServerABroker History ColdFusion MX...

Page 675: ...ined 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 cfoutput is n...

Page 676: ...ters Example h3 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 Th...

Page 677: ...s valid date string formats to date time objects which are real numbers Example h3 IsNumericDate Example h3 cfif IsDefined form theTestValue test if the value represents a number or a pre formatted Da...

Page 678: ...678 Chapter 3 ColdFusion Functions p input type Text name TheTestValue value CFOUTPUT Now CFOUTPUT input type Submit value Is it a Date name form...

Page 679: ...tory ColdFusion MX Added this function Parameters Usage This function returns False for query and XML objects Example to use this example create a color cfc component as follows cfcomponent cffunction...

Page 680: ...680 Chapter 3 ColdFusion Functions returnVariable myColor cfinvoke cfif IsDefined myColor Output the returned variable The value of myColor cfoutput myColor cfoutput p cfif cfif...

Page 681: ...n is obsolete Use the newer security tools see Conversion functions on page 453 and Chapter 16 Securing Applications in ColdFusion MX Developer s Guide History ColdFusion MX This function is obsolete...

Page 682: ...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 683: ...he query 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 cfqu...

Page 684: ...ce that illustrates the operation of the IsSOAPRequest function and also provides a web service that illustrates the operation of other ColdFusion SOAP functions Save the following code as headerservi...

Page 685: ...n br as XML xmlpassword Add a header as a string cfset addSOAPResponseHeader http www tomj org myns returnheader AUTHORIZED VALUE false Add a second header using a CFML XML value cfset doc XmlNew cfse...

Page 686: ...le shows the use of IsStruct p This file is similar to addemployee cfm which is called by StructNew StructClear and StructDelete It is an example of a custom tag used to add employees Employee informa...

Page 687: ...IsStruct 687 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...

Page 688: ...curing Applications in ColdFusion MX Developer s Guide History ColdFusion MX Added this function Parameters Usage Role names are case sensitive To check if a user is in multiple roles specify them in...

Page 689: ...cision functions Function syntax IsValid type value isValid range value min max isValid regex or regular_expression value pattern See also cfparam cfform IsBoolean IsDate IsNumeric IsSimpleValue Valid...

Page 690: ...ue equivalent to the IsNumeric function guid a Universally Unique Identifier of the form XXXXXXXX XXXX XXXX XXXX XXXXXXXXXXXX where X is a hexadecimal number integer an integer query a query object eq...

Page 691: ...il form emailAddr and isValid telephone form phoneNo cfoutput Application code to update the database goes here h3 The email address and phone number for user Form UserID have been added h3 cfoutput c...

Page 692: ...ot a WDDX packet ColdFusion returns False In earlier releases ColdFusion threw an error Parameters Usage This function processes a WDDX packet with a validating XML parser which uses the WDDX Document...

Page 693: ...IsWDDX 693 struct data wddxPacket hr xmp cfoutput packet xmp IsWDDX returns IsWDDX packet br cfoutput...

Page 694: ...is well formed XML that is it conforms to all XML syntax and structuring rules The string does not have to be a complete XML document The function does not validate against a Document Type Definition...

Page 695: ...s to see if they are well formed XML cfoutput xmlString1 contains the following text br br HTMLCodeFormat xmlstring1 Is it well formed XML text IsXML xmlString1 br br hr xmlString2 contains the follow...

Page 696: ...turned by the XmlSearch function is an XML attribute The DOM and therefore ColdFusion MX treats XML attributes as properties of an element and does not directly expose them as DOM nodes For this reaso...

Page 697: ...his example there is only one entry cfset lastnames XmlSearch xmlobject lastname Test objects to see if they are attributes cfoutput h3 Are the following XML Attribute nodes h3 The order element id at...

Page 698: ...tion Parameters Example The following example creates an XML Document object and a Java object and tests whether they are XML document objects Create an XML document object cfxml variable xmlobject or...

Page 699: ...eters Example The following example tests whether an XML document object the document root and an element are elements Create an XML document object cfxml variable xmlobject order id 4323251 customer...

Page 700: ...ollowing components of an XML document object The document object Elements in the object XmlNode objects in an element s XmlNodes array It also returns True for XML node objects returned by the XmlSea...

Page 701: ...see if they are XML nodes cfoutput h3 Are the following XML nodes h3 xmlobject IsXmlNode xmlobject br The items element xmlobject order items IsXmlNode xmlobject order items br The order element id a...

Page 702: ...Example The following example tests whether an XML document object its root element and a child element are XML root elements Create an XML document object cfxml variable xmlobject xml version 1 0 enc...

Page 703: ...st only when a method is overloaded because its arguments can take more than one data type not because the method can take a variable number of arguments JavaCast cannot be used to cast between comple...

Page 704: ...c String fooMethod String arg return Argument was a String public String fooMethod int arg return Argument was an Integer Within ColdFusion you use the following code cfobject action create type java...

Page 705: ...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 newline...

Page 706: ...RM sampleText is not cfoutput p Your text b FORM sampleText b returned in lowercase is b LCase FORM sampleText b p cfoutput cfelse p b i Please enter some text i b p cfif cfif p Enter your text Press...

Page 707: ...eChars leftmost characters of this string because it is not long enough p cfoutput cfelse cfoutput p Your original string strong Form myText strong p p Your changed string showing only the strong Form...

Page 708: ...r 3 ColdFusion Functions select name RemoveChars option value 1 1 option value 3 selected 3 option value 5 5 option value 7 7 option value 9 9 select input type Submit name Submit value Remove charact...

Page 709: ...ASCII 0 NUL character but did not process subsequent characters of the string Parameters Example h3 Len Example h3 cfif IsDefined Form MyText If len returns 0 zero then show error message cfif Len FO...

Page 710: ...values for our list elements cfquery name GetParkInfo datasource cfdocexamples SELECT PARKNAME CITY STATE FROM PARKS WHERE PARKNAME LIKE AL cfquery cfset temp ValueList GetParkInfo ParkName Parameter...

Page 711: ...ListAppend 711 cfoutput p The original list temp cfoutput now append a park name to the list cfset temp2 ListAppend Temp ANOTHER PARK...

Page 712: ...s SELECT PARKNAME CITY STATE FROM Parks WHERE PARKNAME LIKE BA CFQUERY CFSET temp ValueList GetParkInfo ParkName cfoutput p The original list p temp cfoutput Change the delimiters in the list CFSET te...

Page 713: ...aList three p Here is a list cfoutput aList cfoutput p strong ListContains strong checks for substring wo in the list elements cfoutput p nbsp nbsp nbsp Substring wo is in B element ListContains aLis...

Page 714: ...it in the second element p nbsp nbsp nbsp strong ListContains strong cfoutput The string two is in b element ListContains aList two b of the list cfoutput nbsp nbsp nbsp p strong ListFind strong cfou...

Page 715: ...orm letter First query to get some values for our list cfquery name GetParkInfo datasource cfdocexamples SELECT PARKNAME CITY STATE FROM Parks WHERE PARKNAME LIKE form letter cfquery cfset tempList Va...

Page 716: ...pty list elements thus the list a b c d has four elements Example First query to get some values for our list elements CFQUERY NAME GetParkInfo DATASOURCE cfdocexamples SELECT PARKNAME CITY STATE FROM...

Page 717: ...foutput Delete the third element from the list CFSET temp2 ListDeleteAt Temp 3 cfoutput p The changed list temp2 p I This list element br deleted_element br is no longer present at position three of t...

Page 718: ...list form action listfind cfm method POST p Try changing the case in Leary s last name br input type Text size 25 name myString value Leary p Pick a search type select name type option value ListFind...

Page 719: ...ListGetAt ValueList SearchEmpLastName Department temp Department can be reached at ListGetAt ValueList SearchEmpLastName Phone temp p This was the first employee found under this case sensitive last...

Page 720: ...ind cfm method POST p Try changing the case in Leary s last name br input type Text size 25 name myString value Leary p Pick a search type select name type option value ListFind selected Case Sensitiv...

Page 721: ...chEmpLastName Department temp Department can be reached at ListGetAt ValueList SearchEmpLastName Phone temp p This was the first employee found under this case sensitive last name search cfoutput cfif...

Page 722: ...FROM Messages cfquery cfset temp ValueList GetMessageUser Username p Before editing the list it is nbsp cfoutput ValueList GetMessageUser Username cfoutput p Users who posted more than once are liste...

Page 723: ...ist use the trim function to remove the space before the returned value cfset MyValue trim listGetAt myList 2 With this usage MyValue two hundred not two hundred and spaces within a list element are p...

Page 724: ...r Username loop through the list and show it with ListGetAt h3 This list of usernames who have posted messages numbers cfoutput ListLen temp cfoutput users h3 ul cfloop From 1 To ListLen temp index Co...

Page 725: ...a b c d has four elements Example This example shows ListInsertAt cfquery name GetParkInfo datasource cfdocexamples SELECT PARKNAME CITY STATE FROM PARKS WHERE PARKNAME LIKE DE cfquery cfset temp Val...

Page 726: ...ove the space before the returned value cfset MyValue trim ListLast myList With this usage the MyValue variable gets the value three hundred not three hundred and spaces within a list element are pres...

Page 727: ...ore than once are listed more than once Show the first user in the list p The first user in the list is cfoutput ListFirst temp cfoutput p The rest of the list is nbsp cfoutput ListRest temp cfoutput...

Page 728: ...ry name GetMessageUser datasource cfdocexamples SELECT Username Subject Posted FROM Messages cfquery cfset temp ValueList GetMessageUser Username loop through the list and show it with ListGetAt h3 Th...

Page 729: ...ListLen 729 cfoutput ListLen temp cfoutput users h3 ul cfloop From 1 TO ListLen temp INDEX Counter cfoutput li Username Counter ListGetAt temp Counter cfoutput cfloop ul...

Page 730: ...ents thus the list a b c d has four elements If the delimiters parameter is the empty string ColdFusion returns the contents of the value parameter Example This example shows ListPrepend cfquery name...

Page 731: ...list ColdFusion ignores empty list elements thus the list a b c d has four elements Example cfquery name GetEmployeeNames datasource cfdocexamples SELECT FirstName LastName FROM Employees cfquery h3 L...

Page 732: ...st cfoutput show the resulting alphabetized array as a qualified list with single quotation marks around each full name cfset qualifiedList1 ListQualify myList CHAR output the array as a list cfoutput...

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

Page 734: ...inserts a delimiter If delimiters contains more than one delimiter ColdFusion uses the first delimiter in the string or if delimiters was omitted a comma ColdFusion ignores empty list elements thus t...

Page 735: ...put subjects posted in messages h3 cfset ChangedElement ListGetAt temp 2 cfset TempToo ListSetAt temp 2 I changed this subject ul cfloop From 1 To ListLen temptoo INDEX Counter cfoutput li Counter SUB...

Page 736: ...er only in case Both operations are correct The new operation 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...

Page 737: ...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 alphabetically wit...

Page 738: ...ldFusion will break the list at either a comma or a plus sign Example h3 ListToArray Example h3 Find a list of users who wrote messages cfquery name GetMessageUser datasource cfdocexamples SELECT User...

Page 739: ...h3 p This example uses ListValueCount to count employees in a department form action listvaluecount cfm p Select a department p select name departmentName option value Accounting Accounting OPTION opt...

Page 740: ...me cfset myList ValueList SearchByDepartment Department cfset numberInDepartment ListValueCount myList FORM departmentName cfif numberInDepartment is 0 h3 There are no employees in cfoutput FORM depar...

Page 741: ...ple h3 p This example uses ListValueCountNoCase to count employees in a department form action listvaluecountnocase cfm p Select a department p select name departmentName option value Accounting Accou...

Page 742: ...partmentName cfset myList ValueList SearchByDepartment Department cfset numberInDepartment ListValueCountNoCase myList FORM departmentName cfif numberInDepartment is 0 h3 There are no employees in cfo...

Page 743: ...aram 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 Enter a string...

Page 744: ...br Enter a positive 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 loga...

Page 745: ...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 number to bas...

Page 746: ...ed to it it returns a negative number If type local it returns the value in the current locale s standard format If type international it returns the value in the current locale s international standa...

Page 747: ...d 100 000 00 NZD100 000 00 100 000 00 English UK 100 000 00 GBP100 000 00 100 000 00 English US 100 000 00 USD100 000 00 100 000 00 French Belgian 100 000 00 100 000 00 FB EUR100 000 00 BEF100 000 00...

Page 748: ...dLocales index locale delimiters cfset oldlocale SetLocale locale cfoutput p b I locale I b br Local LSCurrencyFormat 100000 local br International LSCurrencyFormat 100000 international br None LSCurr...

Page 749: ...International functions Function syntax LSDateFormat date mask See also LSParseDateTime LSTimeFormat DateFormat SetLocale Handling data in ColdFusion MX in Chapter 17 Developing Globalized Applicatio...

Page 750: ...r LSDateFormat Now br 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 sin...

Page 751: ...LSDateFormat 751 hr noshade cfoutput cfloop...

Page 752: ...atting rules for all JVM versions as follows If the 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...

Page 753: ...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 754: ...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 755: ...belongs to the Euro Zone Parameters Usage For examples of ColdFusion code and output that shows differences between earlier ColdFusion releases and ColdFusion MX in accepting input formats and displa...

Page 756: ...a proper currency value for cfoutput GetLocale cfoutput p Answer cfoutput LSIsCurrency FORM myValue cfoutput cfif p form action LSIsCurrency cfm p Select a locale for which you would like to check a...

Page 757: ...le formatting rules on all platforms Changed behavior this function accepts a dash or hyphen character only in the Dutch Standard and Portuguese Standard locales If called this way for example LsIsDat...

Page 758: ...cFOUTPUT a proper date value for cfoutput GetLocale cfoutput p Answer cfoutput LSIsDate FORM myValue cfoutput cfif p form action LSIsDate cfm p Select a locale for which you would like to check a date...

Page 759: ...function might return a different result than in earlier releases This function uses Java standard locale formatting rules on all platforms Parameters Usage To set the default display format of date t...

Page 760: ...X Changed behavior if the specified mask format cannot correctly mask a number this function returns the number unchanged In earlier releases it truncated the number or threw an error If no mask is sp...

Page 761: ...s for a symbol are far left near left near 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...

Page 762: ...ounding factor the conversion correctly results in a value 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 i...

Page 763: ...uses the locale formatting rules of the JVM specified in the ColdFusion Administrator Java and JVM page on all platforms These rules changed between Sun JVM 1 3 1 and JVM 1 4 1 JVM 1 3 1 requires tha...

Page 764: ...456 units cfloop LIST Server Coldfusion SupportedLocales index locale delimiters cfset oldlocale SetLocale locale cfoutput p B I locale I B br Local LSCurrencyFormat 123456 78 local br Parsed local C...

Page 765: ...standard locale formatting rules on all platforms Changed how the date time string parameter value is processed ColdFusion processes the date time string parameter value time zone information differen...

Page 766: ...eTime Example returns a locale specific date time object h3 loop through a list of locales and show date values for Now cfloop LIST Server Coldfusion SupportedLocales index locale delimiters cfset old...

Page 767: ...tries in the Euro currency zone Parameters Usage This function determines whether the current locale s country belongs to the Euro Zone whose members have converted to the euro if so the currency stri...

Page 768: ...arseEuroCurrency localCurrency br cfset IntlCurrency LSEuroCurrencyFormat 123456 international Value with International currency formatting IntlCurrency br Parsed using LSParseEuroCurrency LSParseEuro...

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

Page 770: ...ter 3 ColdFusion Functions LSNumberFormat 1234 5678 _________ ___ br LSNumberFormat 1234 5678 _________ ___ br The actual number LSParseNumber LSNumberFormat 1234 5678 _________ br hr noshade cfoutput...

Page 771: ...sk See also LSParseDateTime LSDateFormat TimeFormat Locales in Chapter 17 Developing Globalized Applications in ColdFusion MX Developer s Guide History ColdFusion MX 6 1 Added the mask character L or...

Page 772: ...ldlocale SetLocale locale Parameter Description string A date time value A string that is convertible to a time value A date time object is in the range 100 AD 9999 AD mask Masking characters that det...

Page 773: ...Format 773 cfoutput p B I locale I B br LSTimeFormat Now br LSTimeFormat Now hh mm ss br LSTimeFormat Now hh mm sst br LSTimeFormat Now hh mm sstt br LSTimeFormat Now HH mm ss br hr noshade cfoutput c...

Page 774: ...so RTrim ToBase64 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...

Page 775: ...meric 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 Please en...

Page 776: ...myText cfoutput p style color red font weight bold Your string Form myText only has Len Form myText characters You cannot start at position Form startPos p cfoutput cfelse cfoutput p Your original st...

Page 777: ...ter a starting position from the beginning of the entered text br input name startPos type text size 1 p p How many characters do you want to show select name RemoveChars option value 1 1 option value...

Page 778: ...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 779: ...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 780: ...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 781: ...ore 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...

Page 782: ...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 783: ...d It does not truncate the number nor throw an error If no mask is selected ColdFusion MX rounds the decimal part as ColdFusion 5 does For example it rounds 34 567 to 35 Parameters The following table...

Page 784: ...umbers The positions for a symbol are far left near left near 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...

Page 785: ...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 time number and currency v...

Page 786: ...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 787: ...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 788: ...nfo function To set the default display format of date time number and currency values use the SetLocale function Example h3 ParseDateTime Example h3 cfif IsDefined form theTestValue cfif IsDate form...

Page 789: ...ot a valid date h3 cfif cfif form action CGI 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 DateForma...

Page 790: ...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 791: ...useful in SQL statements to defer evaluation of a variable reference until runtime This prevents errors that result from the evaluation of a single quote or apostrophe data character for example Joe...

Page 792: ...is example we pick the list of Centers in Suisun San Francisco 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 L...

Page 793: ...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 794: ...if a user attempts to add a column whose name is invalid ColdFusion throws an error In earlier releases ColdFusion permitted the add operation but the user could not reference the column after adding...

Page 795: ...shorter than the third QueryAddColumn adds padding to the corresponding columns in the query Make a query cfset myQuery QueryNew Create an array cfset FastFoodArray ArrayNew 1 cfset FastFoodArray 1 F...

Page 796: ...796 Chapter 3 ColdFusion Functions th align left Health Food th tr cfoutput query myQuery tr td FastFood td td FineCuisine td td HealthFood td tr cfoutput table...

Page 797: ...ELECT Course_ID Descript FROM Courses cfquery p The Query GetCourses has cfoutput GetCourses RecordCount cfoutput rows cfset CountVar 0 cfloop CONDITION CountVar LT 15 cfset temp QueryAddRow GetCourse...

Page 798: ...ypelist parameter Without this parameter ColdFusion must try to determine data types when it uses the query object in a query of queries Determining data types requires additional processing and can r...

Page 799: ...the query cfset temp QuerySetCell myQuery Name The Wonderful World of CMFL 1 cfset temp QuerySetCell myQuery Time 9 15 AM 1 cfset temp QuerySetCell myQuery Advanced False 1 cfset temp QuerySetCell my...

Page 800: ...ource cfdocexamples SELECT Course_ID Descript FROM Courses cfquery p The Query GetCourses has cfoutput GetCourses RecordCount cfoutput rows cfset CountVar 0 cfloop CONDITION CountVar LT 15 cfset temp...

Page 801: ...cfquery name GetDepartments datasource cfdocexamples SELECT Dept_ID FROM Departments WHERE Dept_ID IN PreserveSingleQuotes List cfquery now select the courses for that department based on the quotedVa...

Page 802: ...rity provider This provider includes the algorithms listed in the Parameters section except the default algorithm The JCE framework includes facilities for using other provider implementations however...

Page 803: ...talls a Sun Java 1 4 2 runtime that includes the Sun JCE default security provider This provider includes the algorithms listed in the Parameters section except the default algorithm The JCE framework...

Page 804: ...eric FORM myRandomInt cfoutput b Seed value is FORM myRandomInt b br cfoutput br Call Randomize to seed the random number generator cfset r Randomize FORM myRandomInt SHA1PRNG cfoutput b Random number...

Page 805: ...he Sun JCE default security provider This provider includes the algorithms listed in the Parameters section except the default algorithm The JCE framework includes facilities for using other provider...

Page 806: ...mySeed b br cfoutput br Call Randomize to seed the random number generator cfset r Randomize FORM mySeed SHA1PRNG cfelse b No Seed value submitted b br cfif Generate and display the random number cfo...

Page 807: ...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 the r...

Page 808: ...u 5 cfoutput p Set startPos to one returnMatchedSubexpressions TRUE hr size 2 color 0000A0 p If you use the i returnssubexpression i parameter REFind returns the position and length of the first occu...

Page 809: ...A0 p However if you use parentheses in the regular expression the first element contains the position and length of the first instance of the whole expression The position and length of the first inst...

Page 810: ...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 811: ...ndNoCase rep report cfm rep 1234 u 5 cfoutput p Set startPos to one returnMatchedSubexpressions True hr size 2 color 0000A0 p If you do use the i returnssubexpression i parameter REFindNoCase returns...

Page 812: ...t p hr size 2 color 0000A0 p However if you use parentheses to denote subexpressions in the regular expression the first element contains the position and length of the first instance of the whole exp...

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

Page 814: ...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 a lo...

Page 815: ...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 816: ...zy 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 cfi...

Page 817: ...ed scope cfif IsDefined FORM MyString p Your original string cfoutput FORM MyString cfoutput p You wanted to replace the substring cfoutput FORM MySubstring1 cfoutput with the substring cfoutput FORM...

Page 818: ...r 3 ColdFusion Functions h3 Replacelist Example Two h3 cfset stringtoreplace The quick brown fox jumped over the lazy dog cfoutput ReplaceList stringtoreplace dog brown fox black cow black ferret whit...

Page 819: ...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 MySub...

Page 820: ...ring functions Function syntax REReplace string reg_expression substring scope See also REFind Replace ReplaceList REReplaceNoCase History ColdFusion MX Added supports for the following special codes...

Page 821: ...ced with i substring i in the specified scope Case sensitive search 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...

Page 822: ...cement strings to control case conversion u U l L and E If any of these strings is present in a ColdFusion 5 application you must insert a backslash before it for example change u to u Parameters Usag...

Page 823: ...A Z G ALL cfoutput REReplaceNoCase cabaret A Z G ALL cfoutput p REReplaceNoCase I LOVE JELLIES jell y ies cookies cfoutput REReplaceNoCase I LOVE JELLIES jell y ies cookies cfoutput p REReplaceNoCase...

Page 824: ...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 825: ...ump over the fence 9 br Right ColdFusion 6 cfoutput Right Example using form input h3 Right Example h3 cfif IsDefined Form MyText If len returns 0 zero then show error message cfif Len FORM myText cfi...

Page 826: ...f form action cfoutput CGI ScriptName cfoutput method POST p Type in some text br input type Text name myText p p How many characters from the right do you want to show select name RemoveChars option...

Page 827: ...Defined 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 justified within...

Page 828: ...rounds numbers that end with 5 up to the nearest integer It rounds 3 5 to 4 and 3 5 to 3 Example h3 Round Example h3 p This function rounds a number to the closest integer ul li Round 7 49 cfoutput R...

Page 829: ...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 post p Enter som...

Page 830: ...ute Parameters 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 exampl...

Page 831: ...outgoingMessage method The value returned by the function depends on the gateway type The following table describes the return values for standard ColdFusion MX gateway types Parameter Description ga...

Page 832: ...e ColdFusion MX Administrator as Asynch Logger br cfscript status false props structNew props message Replace me with a variable with data to log status SendGatewayMessage Asynch Logger props if statu...

Page 833: ...tEncoding scope_name charset See also GetEncoding cfcontent cfprocessingdirective URLDecode URLEncodedFormat Locales in Chapter 17 Developing Globalized Applications in ColdFusion MX Developer s Guide...

Page 834: ...tl encoding doc html lists the character encoding that Java 1 4 1 and therefore the default ColdFusion configuration can interpret If you use a JVM that does not conform to the Sun Java 2 Platform Sta...

Page 835: ...This function uses 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 release...

Page 836: ...locale setting you can save the original locale value You can restore the original locale by calling SetLocale again with the saved variable For example the following line saves the original locale i...

Page 837: ...the form was submitted If so this section sets the initialization path and timeout value to the path and timeout value specified in the form cfif Isdefined Form Submit cfset IniPath FORM iniPath cfset...

Page 838: ...on timeout cfset default GetProfileString IniPath Section default h4 Boot Loader h4 p Timeout is set to cfoutput timeout cfoutput p p Default directory is cfoutput default cfoutput p cfif form action...

Page 839: ...e in quotation marks and number signs for example cfset DynamicVar2 ABD cfset DynamicVar2 Test Value2 Also the following lines are equivalent cfset myVar i myVal SetVariable myVar i myVal For more inf...

Page 840: ...840 Chapter 3 ColdFusion Functions cfset varNameValue Evaluate myName cfoutput p Your variable varName p The value of varName is varNameValue cfoutput cfif...

Page 841: ...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 is negative p...

Page 842: ...should produce 0 To test for a 0 value check whether the value is less than 0 0000000000001 Example h3 Sin Example h3 Calculate sine if form has been submitted cfif IsDefined FORM sinNum Make sure inp...

Page 843: ...Sin 843 cfif cfif form action CGI script_name method post Enter an angle in degrees to get its sine br input type Text name sinNum size 15 br br input type Submit name nbsp nbsp input type RESET form...

Page 844: ...ing Example h3 cfif IsDefined FORM myString p Your string was cfoutput FORM myString cfoutput p Your set of characters was cfoutput FORM mySet cfoutput p Your string up until one of the characters in...

Page 845: ...f IsDefined FORM myString p Your string was cfoutput FORM 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 c...

Page 846: ...See also Abs 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...

Page 847: ...ction 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 use Chr 10 Chr 13 to...

Page 848: ...2 to struct1 struct2 is not modified If struct1 already contains a field of struct2 overwriteFlag determines whether the value in struct2 overwrites it A structure s keys are unordered Example html bo...

Page 849: ...struct before the Append p The person struct b before b the Append call br cfloop collection personCLK item myItem cfoutput myItem br cfoutput cfloop Merge the address struct into the top level perso...

Page 850: ...Note 14143 ColdFusion 4 5 and the StructClear Session function at www coldfusion com Support KnowledgeBase SearchForm cfm The article applies to ColdFusion 4 5 5 x and ColdFusion MX Example Shows Stru...

Page 851: ...StructInsert employee email Form email StructInsert employee phone Form phone StructInsert employee department Form department cfscript cfoutput Call the custom tag that adds employees cf_addemployee...

Page 852: ...ide Parameters Usage The following code shows how this function copies a structure that contains a string field a number field and a two dimensional array at the top level cfoutput cfset assignedCopy...

Page 853: ...cript Output original structure hr b Original Values b br cfoutput Simple values br s number s number br s string s string br Array value br s array 1 1 s array 1 1 br s array 1 2 s array 1 2 br cfout...

Page 854: ...t Create elements s StructNew s nested StructNew s nested array ArrayNew 2 Assign simple values to nested structure fields s nested number 99 s nested string hello tommy Assign values to nested array...

Page 855: ...should reflect changes to original b br cfoutput Simple values br copied nested number copied nested number br copied nested string copied nested string br Array values br copied nested array 1 1 copi...

Page 856: ...ilar to addemployee cfm which is called by StructNew StructClear and StructDelete To test copy StructCount function to appropriate place in addemployee cfm cfswitch expression ThisTag ExecutionMode cf...

Page 857: ...StructCount 857 cfquery cfif cfoutput hr Employee Add Complete p StructCount attributes EMPINFO columns added cfoutput cfcase cfswitch...

Page 858: ...k p This example uses the StructInsert and StructDelete functions Establish params for first time through cfparam name firstname default Mary cfparam name lastname default Sante cfparam name email def...

Page 859: ...rm field The code indicates rc br The structure now looks like this br cfdump var employee br cfoutput cfif br br form method post action CGI Script_Name p Select the field to be deleted nbsp select n...

Page 860: ...ructNew StructClear and StructDelete It adds employees Employee information is passed through the employee structure EMPINFO attribute In UNIX you must also add the Emp_ID cfswitch expression ThisTag...

Page 861: ...StructFind 861 cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...

Page 862: ...n MX Developer s Guide Parameters Usage Returns an array 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...

Page 863: ...dFusion MX Developer s Guide Parameters 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...

Page 864: ...tructure or array present in pathDesired this function creates structures or arrays to make pathDesired a valid variable path Parameters Usage You can inadvertently create invalid structures using thi...

Page 865: ...defined br cfif cfoutput dog myscope test foo br cfoutput cfset test StructGet request myscope 1 test cfset test foo 2 cfoutput request myscope 1 test foo br cfoutput cfset test StructGet request mys...

Page 866: ...ior this function can be used on XML objects Parameters Usage A structure s keys are unordered Example h1 Add New Employees h1 Establish params for first time through cfparam name FORM firstname defau...

Page 867: ...loyee phone p p Department is StructFind employee department p cfoutput Call the custom tag that adds employees CF_ADDEMPLOYEE EMPINFO employee cfif Hr form action structinsert cfm p First Name nbsp i...

Page 868: ...ee cfm which is called by StructNew StructClear and StructDelete It adds employees Employee information is passed through employee structure EMPINFO attribute In UNIX you must also add the Emp_ID cfsw...

Page 869: ...StructIsEmpty 869 cfoutput cfquery cfif cfoutput hr Employee Add Complete cfoutput cfcase cfswitch...

Page 870: ...xtracting the Keys from the Employee Structure h3 Create structure Check whether Submit was pressed If so define fields in employee structure with user entries on form cfset employee StructNew cfif Is...

Page 871: ...h 30 td tr tr td Phone td td input name phone type text value hspace 20 maxlength 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 n...

Page 872: ...StructKeyExists Form JediMaster A structure s keys are unordered Example This example shows the use of StructKeyExists p This file is similar to addemployee cfm which is called by StructNew StructClea...

Page 873: ...and fills it with information user enters in form fields This section creates structure and checks whether Submit has been pressed If so code defines fields in the employee structure with what the us...

Page 874: ...rst Name td td input name firstname type text value hspace 30 maxlength 30 td tr tr td Last Name td td input name lastname type text value hspace 30 maxlength 30 td tr tr td EMail td td input name ema...

Page 875: ...email default cfparam name FORM phone default cfparam name FORM department default cfif FORM firstname EQ p Please fill out the form cfelse cfoutput cfscript employee StructNew StructInsert employee f...

Page 876: ...t string does not support array notation and only supports substructures of structures This function does not sort or change the structure Example cfscript salaries StructNew employees StructNew depar...

Page 877: ...ries numeric ASC br 6 ArrayToList StructSort salaries numeric DESC br p list of employees based on the salary subfield search br 7 ArrayToList StructSort employees numeric DESC salary br 8 ArrayToList...

Page 878: ...ee cfm which is called by StructNew StructClear and 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 t...

Page 879: ...To test for a 0 value check whether the value is 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 h...

Page 880: ...oldFusion Functions cfif cfif form action CGI script_name method post Enter an angle in degrees to get its tangent br input type Text name tanNum size 15 br br input type Submit name nbsp nbsp input t...

Page 881: ...Fusion 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 fun...

Page 882: ...utput ul li TimeFormat todayDate li TimeFormat todayDate hh mm ss li TimeFormat todayDate hh mm sst li TimeFormat todayDate hh mm sstt li TimeFormat todayDate HH mm ss ul cfoutput p To generate a stan...

Page 883: ...TimeFormat 883 TimeFormat function For example dateformat now yyyy mm dd T TimeFormat now HH mm ss produces p cfoutput dateformat now yyyy mm dd T TimeFormat now HH mm ss cfoutput body...

Page 884: ...ormation about serializing and deserializing binary data IsBinary and ToBinary for checking for binary data and converting a Base64 object to binary format History ColdFusion MX Added the encoding par...

Page 885: ...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 p Create a Base64 representation of this string...

Page 886: ...ary data type and binary encoding in Chapter 3 Using ColdFusion Variables in ColdFusion MX Developer s Guide Parameters Usage Macromedia recommends that you use the BinaryDecode function to convert Ba...

Page 887: ...binary back to Base64 cfset another64 toBase64 binaryData Compare another64 with data64 to ensure that they are equal cfif another64 eq data64 h3 Base64 representation of binary data is identical to...

Page 888: ...s Parameter Description cfvar A ColdFusion variable This can contain one of the following String Number Array Structure Query javascriptvar A string that specifies the name of the JavaScript variable...

Page 889: ...a column name and the value of the recordlist entry is an array of the corresponding query column entries as follows WDDXQuery new WddxRecordset col0 new Array col0 0 John col0 1 John WDDXQuery first...

Page 890: ...his is a string cfoutput b The thisString variable in ColdFusion b br thisString br br strong The output of ToScript thisString jsVar strong br ToScript thisString jsVar br br strong In a JavaScript s...

Page 891: ...align left width 9 header b FirstName b text FirstName cfcol align left width 9 header b LastName b text LastName cftable strong JavaScript generated by ToScript thisQuery WDDXQuery strong br toScrip...

Page 892: ...See also ToBase64 ToBinary CharsetEncode Chapter 35 Using XML and WDDX in ColdFusion MX Developer s Guide History ColdFusion MX Changed Unicode support ColdFusion supports the Java UCS 2 representatio...

Page 893: ...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 string br cfoutput data64 cfoutput...

Page 894: ...nctions cfset dataBinary toBinary data64 Create the string representation of the binary data cfset dataString ToString dataBinary p The following is the string representation of the binary data br cfo...

Page 895: ...ample 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 method post action trim cfm p Type in...

Page 896: ...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 897: ...ColdFusion MX Changed Unicode support ColdFusion supports the Java UCS 2 representation of Unicode character values 0 65535 Earlier releases supported ASCII values Added the charset parameter Paramete...

Page 898: ...y strings in HTTP are always URL encoded Example This example creates encodes and decodes a string that contains ASCII character codes cfscript Build string s for c 1 c lte 256 c c 1 s s chr c Encode...

Page 899: ...ns for globalizing in Chapter 17 Developing Globalized Applications in ColdFusion MX Developer s Guide History ColdFusion MX 6 1 Changed the default encoding to be the response character encoding Cold...

Page 900: ...a plus sign Query strings in HTTP are always URL encoded Example h3 URLEncodedFormat Example h3 cfif IsDefined url myExample p The url variable url myExample was passed from the previous link its valu...

Page 901: ...r to code Returns A URL if cookies are disabled for the browser client and session data are appended Category Other functions Chapter 15 Maintaining client identity in Chapter 15 Using Persistent Data...

Page 902: ...ue 0 not an error If 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...

Page 903: ...Val 903 value Is the beginning numeric name form...

Page 904: ...e GetDepartments datasource cfdocexamples SELECT Dept_ID FROM Departments WHERE Dept_ID IN BIOL cfquery cfquery name GetCourseList datasource cfdocexamples SELECT FROM CourseList WHERE Dept_ID IN GetD...

Page 905: ...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 906: ...d newline 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...

Page 907: ...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 cfs...

Page 908: ...functions to change XML document objects If the specified child is not found the function returns 1 Example The following example searches XML document element xmlobject employee name 1 for its secon...

Page 909: ...nd the second Status child of the first employee name element cfscript elempos XMLChildPos xmlobject employee name 1 Status 2 ArrayDeleteAt xmlobject employee name 1 XmlChildren elempos cfscript Dump...

Page 910: ...by the xmlObj parameter The following statements show this use MyDoc MyRoot XmlChildren 2 XmlElemNew MyDoc childNode ArrayAppend MyDoc MyRoot XmlChildren XmlElemNew MyDoc childNode If you do not spec...

Page 911: ...else MyDoc MyRoot XmlText The value of testVar is False for i 1 i LTE 4 i i 1 MyDoc MyRoot XmlChildren i XmlElemNew MyDoc childNode MyDoc MyRoot XmlChildren i XmlText This is Child node i cfscript cf...

Page 912: ...llowing example shows how XmlFormat escapes special XML characters Use the View Source command in the browser to see the results ColdFusion interprets the in the second text string as representing a s...

Page 913: ...XmlFormat 913 someXML someElement someAttribute XmlFormat a quoted value XmlFormat Body of element with and goes here someElement someXML cfoutput...

Page 914: ...Added this function Parameters Usage The XmlGetNodeType function can determine the types of the nodes returned by the XmlSearch function or the types of the entries in an element s XmlNodes array Exa...

Page 915: ...GetNodeType xmlobject order br br Now check the types of all the nodes in the xmlobject order items item element s XmlNodes array br Note the many apparently empty Text nodes generated by whitespace c...

Page 916: ...nd NAME refer to different elements or attributes If False these names refer to the same elements or attributes If your XML object is case sensitive you cannot use dot notation to reference an element...

Page 917: ...mlNew MyDoc xmlRoot XmlElemNew MyDoc MyRoot if testVar IS TRUE MyDoc MyRoot XmlText The value of testVar is True else MyDoc MyRoot XmlText The value of testVar is False for i 1 i LTE 4 i i 1 MyDoc MyR...

Page 918: ...specify a relative URL or path name in a parameter ColdFusion uses the directory or for URLs the logical directory that contains the current ColdFusion page as the path root Parameter Description xmlT...

Page 919: ...se function validate your document If you do not specify a validator parameter and the XML file specifies a DTD or Schema ColdFusion ignores the DTD or Schema If you specify a validator parameter you...

Page 920: ...CDATA REQUIRED accountNum CDATA REQUIRED ELEMENT items item ELEMENT item name quantity unitprice ATTLIST item id CDATA REQUIRED ELEMENT name PCDATA ELEMENT quantity PCDATA ELEMENT unitprice PCDATA Th...

Page 921: ...orts XPath expressions that return one or more XML nodes and attribute searches XPath expressions that return any other type of value such as a string number or Boolean generate errors XPath is specif...

Page 922: ...ast name employee The CFML file contains the following lines cfscript myxmldoc XmlParse C CFusionMX7 wwwroot examples employeesimple xml selectedElements XmlSearch myxmldoc employee name last for i 1...

Page 923: ...plying an Extensible Stylesheet Language XSL stylesheet to it XSL including XSLT syntax is specified by the World Wide Web Consortium W3C For detailed information on XSL and XSLT see the W3C website a...

Page 924: ...tem id 43 name Deluxe Carpenter apos s Hammer name quantity 1 quantity unitprice 15 95 unitprice item item id 54 name 36 quot Plastic Rake name quantity 2 quantity unitprice 6 95 unitprice item item i...

Page 925: ...mplate xsl stylesheet The CFML file has the following lines cffile action read file C CFusionMX7 wwwroot examples custorder xsl variable xmltrans cfset xmldoc XmlParse C CFusionMX7 wwwroot examples cu...

Page 926: ...is not valid FatalErrors An array containing any validator fatal error messages Fatal errors indicate that the document contains XML formatting errors is not well formed XML Status A Boolean value Tr...

Page 927: ...processing As a result the returned structure can have a combination of Warning Error and FatalError fields and each field can contain multiple error messages Example The following example has three...

Page 928: ...m xs complexType xs sequence xs element ref name xs element ref quantity xs element ref unitprice xs sequence xs attribute name id type xs integer use required xs attribute xs complexType xs element x...

Page 929: ...XmlValidate 929 Did custorder xml validate against custorder xsd results status br br cfoutput Dump of myResults structure returned by XMLValidate br cfdump var myResults...

Page 930: ...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 day DayOfWeek...

Page 931: ...oFormat value See also IsBinary IsNumeric Parameters Example h3 YesNoFormat Example h3 p The YesNoFormat function returns non zero values as Yes zero false and no Boolean values and empty strings as N...

Page 932: ...932 Chapter 3 ColdFusion Functions...

Page 933: ...cfformgroup with tabnavigator type attribute 939 Styles for cfformitem with hrule or vrule type attributes 939 Styles for cfinput with radioButton checkbox button image or submit type attributes 940 S...

Page 934: ...color of components when disabled The default value is EFEEEF light gray backgroundSize N Scales the image specified by backgroundImage to different percentage sizes By default the value is auto which...

Page 935: ...bold Recognized values are normal and bold The default value is normal highlightColor Y Format color color of the control when it is in focus horizontalGap N Format length number of pixels between chi...

Page 936: ...marginBottom N Format length number of pixels between the container s bottom border and its content area The default value is 16 marginTop N Format length number of pixels between the container s top...

Page 937: ...t of children in the container The default value is left Possible values are left center and right horizontalGap N Format length number of pixels between children in the horizontal direction The defau...

Page 938: ...t of two colors used to draw the header The first color is the top color The second color is the bottom color The default value is E1E5EB F4F5F7 headerHeight N Format length height of the header The d...

Page 939: ...a size larger than its preferred width to see different alignments horizontalGap N Format length number of pixels between children in the horizontal direction The default value is 6 tabHeight N Format...

Page 940: ...er than 2 the rule is a hollow rectangle with 1 pixel wide edges The default value is 2 Style Inh Description borderThickness N Thickness of border ring A value of 0 means no border Any value greater...

Page 941: ...84 dark gray texRollOverColor Y Format color text color of the label as you move the mouse pointer over the control The default value is 2B333C textSelectColor Y Format color text color of the label a...

Page 942: ...round when the user moves the mouse pointer over the link The default value is 0EFFD6 selectionColor Y Format color color of the background when the user selects the link The default value is 0DFFC1 s...

Page 943: ...The default value is 8 Style Inh Description alternatingRowColors Y Type Array colors for rows in an alternating pattern Value can be an Array of two or more colors depthColors Y Type Array array of...

Page 944: ...944 Chapter 4 ColdFusion MX Flash Form Style Reference...

Page 945: ...ia recommends that you always start the Application cfc filename with an uppoercase A Both application cfc and Application cfc are reserved words Note If your application has an Application cfc and an...

Page 946: ...e stored can be cookie registry or the name of a data source loginStorage cookie Whether to store login information in the Cookie scope or the Session scope sessionManagement no Whether the applicatio...

Page 947: ...ollowing order 1 onApplicationStart if not run before for this application 2 onSessionStart if not run before for this session 3 onRequestStart 4 onRequest 5 onRequestEnd The onApplicationEnd onSessio...

Page 948: ...not associated with a request The application ends even if this method throws an exception If you call this method explicitly ColdFusion does not end the application it does execute the method code b...

Page 949: ...ou normally do for example as Application myVariable This method can access the requested page s Variables scope only if the Application cfc file includes an onRequest method that calls the page If yo...

Page 950: ...ailable message cfcatch message Detail cfcatch detail Native Error cfcatch NativeErrorCode cfreturn False cfcatch cftry cflog file This Name type Information text Application Started You do not have t...

Page 951: ...f an error occurs during an onApplicationStart onSessionStart onRequestStart onRequest or onRequestEnd event method or while processing a request The onError method cannot display output to the user i...

Page 952: ...ues for the remaining errors Example cffunction name onError cfargument name Exception required true cfargument type String name EventName required true Log all errors cflog file This Name type error...

Page 953: ...behavior of running the requested pages The following rules specify where and how you use the onRequest method Implement this method only if the following are true The directory and any subdirectories...

Page 954: ...also implement the onRequestStart and onRequestEnd methods You can use this method to do preprocessing that is required for all requests Typical uses include filtering and modifying request page conte...

Page 955: ...page context and can generate output This method can be useful for gathering performance metrics or for displaying dynamic footer information This method can access the requested page s Variables scop...

Page 956: ...ank you for shopping at our store theAuthUser h3 cfoutput A very simple noauthuserfooter cfm page consists of the following code cfoutput h3 Remember only registered users get all our benefits h3 cfou...

Page 957: ...uses the cfthrow tag ColdFusion handles the error and does not process the request further If you call this method explicitly ColdFusion does not start a request but does execute the method code This...

Page 958: ...those hours tell people to come back later and do not process the request further cfscript if Hour now gt 1 and Hour now lt 3 WriteOutput The system is undergoing periodic maintenance Please return af...

Page 959: ...u can for example save session related data such as shopping cart contents or whether the user has not completed an order in a database or do any other required processing based on the user s status Y...

Page 960: ...ethod is not called when an application ends The onSessionEnd does not execute if there is no active application however Example The following method decrements an Application scope session count vari...

Page 961: ...the Session scope to set its variables using this method If you call this method explicitly ColdFusion does not start a session it does execute the method code but does not lock the Session scope Thi...

Page 962: ...962 Chapter 5 Application CFC Reference...

Page 963: ...structure and commands 1042 CFML event gateway SendGatewayMessage data parameter 1052 Note The following CFML functions also apply to gateway application development GetGatewayHelper SendGatewayMessa...

Page 964: ...elper getHelper Returns an instance of the GatewayHelper class for this gateway type instance or null if the gateway does not have a GatewayHelper class int getStatus Gets the event gateway status Str...

Page 965: ...e single parameter version ColdFusion always uses the setGatewayID method to set the ID Example The following example shows the two argument constructor implemented in the ColdFusion MX SocketGateway...

Page 966: ...ng getGatewayID See also setGatewayID Providing Gateway class service and information routines in Chapter 45 Creating Custom Event Gateways in ColdFusion MX Developer s Guide Usage This method returns...

Page 967: ...coldfusion eventgateway GatewayHelper class instance or null if the gateway does not have a GatewayHelper class Usage ColdFusion calls this method when a ColdFusion MX application calls the CFML GetG...

Page 968: ...Gateway class service and information routines in Chapter 45 Creating Custom Event Gateways in ColdFusion MX Developer s Guide Returns An integer status value The Gateway interface defines the followi...

Page 969: ...oldFusion application calls the SendGatewayMessage function ColdFusion MX passes the String returned by this method back as the return value of a CFML SendGatewayMessage function Example The following...

Page 970: ...ad st SocketServerThread socketRegistry get data get OriginatorID if st null st writeOutput message else log error Cannot send outgoing message OriginatorID data get OriginatorID is not a valid socket...

Page 971: ...blic void restart See also start stop Usage In most cases you implement this method as a call to the stop method followed by a start method but you may be able to optimize the restart method based on...

Page 972: ...s method with the names in the instance s listener list in the ColdFusion MX Administrator ColdFusion MX can also call this method if the ColdFusion MX Administrator listener list changes while the ga...

Page 973: ...loper s Guide Parameters Usage This method sets a string value that is returned by the getGatewayID method ColdFusion MX calls this method to set the gateway ID with the value specified in the gateway...

Page 974: ...d should update the status information that is returned by the getStatus method to indicate when the gateway is starting and when the gateway is running The ColdFusion MX Administrator Gateway Types p...

Page 975: ...urces The ColdFusion MX Administrator calls this function when it stops a gateway instance This method should update the status information that is returned by the getStatus method to indicate when th...

Page 976: ...efine a class that provides gateway specific utility methods to the ColdFusion application or listener CFC For example an instant messaging event gateway might use a helper class to provide buddy list...

Page 977: ...at returns the GatewayServices object boolean addEvent CFEvent msg Sends a CFEvent instance to ColdFusion for dispatching to a listener CFC coldfusion eventgateway Logger getLogger String logfile Retu...

Page 978: ...ing Custom Event Gateways in ColdFusion MX Developer s Guide Returns The GatewayServices object Usage Gateway constructors can call this method to get a convenient reference to the GatewayServices cla...

Page 979: ...ng messages to the application for processing Example The following example from the ColdFusion MX SocketGateway code sends an event to all listener CFCs for int i 0 i listeners length i String path l...

Page 980: ...ption information in the exceptions log file Example The ColdFusion MX example DirectoryWatcherGateway includes the following line in the constructor to get a logger object We create our own log file...

Page 981: ...You can use this method and the getQueueSize method to control the rate of event queuing and to help diagnose any throughput problems in your gateways Example The following example logs the queue siz...

Page 982: ...getMaxQueueSize method to control the rate of event queuing and to help diagnose any throughput problems in your gateways Example The following example logs the queue size maximum queue size and other...

Page 983: ...tring gatewayID CFEvent constructor String getGatewayID Returns the gateway ID set in the CFEvent constructor void setCFCMethod String method String getCFCMethod Sets or gets the name of the CFC metho...

Page 984: ...code for the ColdFusion asynchronous CFML gateway sends a message to that the gateway has received to a CFC public String outgoingMessage coldfusion eventgateway CFEvent cfmsg Get the data Map data c...

Page 985: ...the method that gateway services will call in the listener CFC as set by the setCFCMethod method If setCFCMethod has not been called returns null and not onIncomingMessge which ColdFusion gateway ser...

Page 986: ...h to the application listener CFC that will process the event as set by the setCFCPath method If the setCFCPath method has not been called returns null not the path specified in the ColdFusion Adminis...

Page 987: ...Gateways in ColdFusion MX Developer s Guide Returns The listener CFC time out in seconds as set by the setCFCTimeout method or null Usage Most gateways do not need to use this function When ColdFusio...

Page 988: ...command Note The returned Map object has case insensitive keys Example The following outgoingMessage method from the SocketGateway example gateway gets the message contents from the CFEvent data fiel...

Page 989: ...t See also CFEvent CFML CFEvent structure on page 1004 CFEvent class in Chapter 45 Creating Custom Event Gateways in ColdFusion MX Developer s Guide Returns The gateway ID of the CFEvent object or nul...

Page 990: ...ect Category Event Gateway Development Syntax String getGatewayType See also setGatewayType CFML CFEvent structure on page 1004 CFEvent class in Chapter 45 Creating Custom Event Gateways in ColdFusion...

Page 991: ...response back to the originator does not have to explicitly set a destination in the return variable If the field is empty as it is in messages sent by the CFML SendGatewayMessage function the gateway...

Page 992: ...er methods for different message types uses this method to identify the destination method Example The following example code comes from the ColdFusion XMPP gateway incoming message handler It creates...

Page 993: ...cket gateway processInput method that takes input from the socket and sends it to the CFC listener methods The listeners variable contains an array of listener CFCS and is set by the gateway s setCFCL...

Page 994: ...o not use this method ColdFusion uses the Timeout Request value set on the Server Settings page in the ColdFusion MX Administrator Use this method if your messages require a longer or shorter time out...

Page 995: ...a result do not create entries in the data with names that differ only in case Example The following code shows the routine from the example JMS gateway that handles incoming messages It puts the JMS...

Page 996: ...s those in an instant messaging application that handles multiple instant messaging providers could use this field to determine the protocol type and any gateway type specific actions Example The foll...

Page 997: ...hat handles incoming messages It sets the originator ID to the name of the JMS topic that the gateway handles public void handleMessage String msg String topicName String msgID coldfusion eventgateway...

Page 998: ...dFusion logs directory You set this directory on the ColdFusion MX Administrator Logging Settings page The coldfusion eventgateway GatewayServices getLogger method returns an instance of the Logger cl...

Page 999: ...er configuration or cf_root WEB INF cfusion lib neo logging xml in the J2EE configuration Change the following entry var name priority string information string var to the following var name priority...

Page 1000: ...messages with a severity of error to the log file specified in the getLogger method that returned the Logger instance or the default log file Example The ColdFusion MX example SocketGateway class inc...

Page 1001: ...Chapter 45 Creating Custom Event Gateways in ColdFusion MX Developer s Guide Parameters Usage Use this method to send a fatal error message to the ColdFusion MX logging subsystem ColdFusion MX will w...

Page 1002: ...he log file specified in the getLogger method that returned the Logger instance or the default log file ColdFusion normally logs all information severity messages so you should not use this severity f...

Page 1003: ...default log file Example The ColdFusion MX example SocketWatcherGateway class includes the following code in its constructor to load a configuration file If it cannot load the file it converts the exc...

Page 1004: ...alls the SendGatewayMessage function to respond to the event gateway it uses this ID as the function s first parameter Data A structure containing the event data including the message The Data structu...

Page 1005: ...the method names and disable event types in the gateway configuration file Method Message type onAddBuddyRequest Requests from other IM users to add the gateway ID as their buddy onAddBuddyResponse Re...

Page 1006: ...cfcMethod This CFC method by default onAddBuddyRequest data MESSAGE The message that was sent with the request data SENDER The sender s ID identical to the originatorID field value data RECIPIENT The...

Page 1007: ...take no action if buddysearch RecordCount IS 0 action decline reason Invalid ID else if buddysearch RecordCount IS 1 action accept reason Valid ID Add the buddy to the buddy status structure only if a...

Page 1008: ...1008 Chapter 6 ColdFusion MX Event Gateway Reference cfset retValue Reason reason cfreturn retValue cffunction...

Page 1009: ...cflock scope APPLICATION timeout 10 type EXCLUSIVE cfscript Do the following only if the buddy accepted the request if NOT StructKeyExists Application buddyStatus Application buddyStatus StructNew if...

Page 1010: ...Data SENDER status Buddy accepted us Application buddyStatus CFEvent Data SENDER timeStamp CFEvent Data TIMESTAMP Application buddyStatus CFEvent Data SENDER message CFEvent Data MESSAGE cfscript cflo...

Page 1011: ...AMETIME gatewayID The ID of the Gateway instance as configured in ColdFusion MX Administrator originatorID The IM ID buddy name of the message originator cfcMethod This CFC method by default onIMServe...

Page 1012: ...ructKeyExists Application buddyStatus CFEvent Data BUDDYNAME Application buddyStatus CFEvent Data BUDDYNAME StructNew Save the buddy status timestamp and custom away message Application buddyStatus CF...

Page 1013: ...ssage cfargument name CFEvent type struct required YES cflog file CFEvent GatewayID Status text onIMServerMEssage SENDER CFEvent OriginatorID MESSAGE CFEvent Data MESSAGE TIMESTAMP CFEvent Data TIMEST...

Page 1014: ...mple shows a simple onIncomingMessage method that echoes a message back to the sender cffunction name onIncomingMessage cfargument name CFEvent type struct required YES cfset input_mesg CFEvent data M...

Page 1015: ...FC incoming message methods 1015 cfset retValue structNew cfset retValue command submit cfset retValue buddyID CFEvent originatorID cfset retValue message Message Received input_mesg cfreturn retValue...

Page 1016: ...r no command because submit is the default command in SendGatewayMessage CFML functions and the return value of the onIncomingMessage CFC method Command Description submit Default Sends a normal messa...

Page 1017: ...tion includes the following methods addBuddy getDenyList getStatusAsString removeDeny addDeny getName getStatusTimeStamp removePermit addPermit getNickName isOnline setNickName getBuddyInfo getPermitL...

Page 1018: ...e from the buddy so it returns True and the gateway adds the buddy to the list even if the buddy denies the subscription request Use the listener CFC onAddBuddyResponse method to monitor the buddy s r...

Page 1019: ...in the XMPP 1 0 draft specification but several XMPP servers that were available at the time of the ColdFusion MX 7 release do not support permission management If the server does not support permiss...

Page 1020: ...uded in the XMPP 1 0 draft specification but several XMPP servers that were available at the time of the ColdFusion MX 7 release do not support permission management If the server does not support per...

Page 1021: ...o information for a field it is blank Parameter Description name The unique instant messaging user name for the person about whom you want to get information Field Description BUDDYNAME The user s uni...

Page 1022: ...BUDDYLISTTIYPE The type of list that this buddy record is in one of the following BUDDY_LIST The list of users whose presence status information the gateway can receive DENY_LIST The list of users wh...

Page 1023: ...in Chapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Returns An array of IDs buddy names of the users on the gateway s buddy list a list of instant messaging IDs...

Page 1024: ...AsString getStatusTimeStamp isOnline setStatus Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways of ColdFusion MX Developer s Guide Returns The gateway s custom a...

Page 1025: ...Developer s Guide Returns An array of IDs buddy names of the users on the gateway s deny list the list of IDs to which the IM server does not send presence status information Note XMPP permission mana...

Page 1026: ...sagesSent setNickName Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways of ColdFusion MX Developer s Guide Returns The gateway s user name as specified in gateway...

Page 1027: ...etProtocolName numberOfMessagesReceived numberOfMessagesSent setNickName Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways of ColdFusion MX Developer s Guide Retu...

Page 1028: ...y of IDs buddy names of the users on the gateway s permit list the list of IDs to which the IM server sends presence status information if the permit mode is set to PERMIT_SOME Note XMPP permission ma...

Page 1029: ...llowing values Note XMPP permission management is included in the XMPP 1 0 draft specification but several XMPP servers that were available at the time of the ColdFusion MX 7 release do not support pe...

Page 1030: ...ssagesSent setNickName Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Returns The gateway s protocol as determined by the ga...

Page 1031: ...Fusion MX Developer s Guide Returns The gateway s online status one of the following ONLINE OFFLINE AWAY DO NOT DISTURB XMPP only NOT AVAILABLE FREE TO CHAT Sametime only IDLE Usage The DO NOT DISTURB...

Page 1032: ...isOnline setStatus Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Returns The date and time that the gateway changed its onl...

Page 1033: ...AsString getStatusTimeStamp setStatus Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Returns True if the gateway is connecte...

Page 1034: ...ickName getProtocolName numberOfMessagesSent setNickName Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Returns The number o...

Page 1035: ...ProtocolName numberOfMessagesReceived setNickName Using the GatewayHelper object in Chapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Returns The number of messa...

Page 1036: ...ns True if the ID was removed from the group False otherwise Usage If the user is in multiple groups in your buddy list you remove the buddy separately from each group The IM server does not stop send...

Page 1037: ...1 0 draft specification but several XMPP servers that were available at the time of the ColdFusion MX 7 release do not support permission management If the server does not support permission manageme...

Page 1038: ...0 draft specification but several XMPP servers that were available at the time of the ColdFusion MX 7 release do not support permission management If the server does not support permission management...

Page 1039: ...hapter 43 Using the Instant Messaging Event Gateways in ColdFusion MX Developer s Guide Parameters Returns True if the nickname got set false otherwise Example See GatewayHelper example in Chapter 43...

Page 1040: ...ncluded in the XMPP 1 0 draft specification but several XMPP servers that were available at the time of the ColdFusion MX 7 release do not support permission management If the server does not support...

Page 1041: ...s method to go offline Although the method accepts a parameter of OFFLINE the gateway immediately resets itself to be online To set the gateway offline stop the gateway instance in the ColdFusion MX A...

Page 1042: ...vent structure and commands This section describes the detailed contents of the following structures that you use in the SMS Gateway listener CFCs and CFML SendGatewayMessage functions SMS Gateway inc...

Page 1043: ...t xx0100xx SME Manual User Acknowledgement xx0110xx Conversation abort Korean CDMA only xx1000xx Intermediate Delivery Notification For more information on this field see the SMPP specification Data p...

Page 1044: ...ents as follows 00000000 SMSC Default Alphabet 00000001 IA5 CCITT T 50 ASCII ANSI X3 4 00000010 Octet unspecified 8 bit binary 00000011 Latin 1 ISO 8859 1 00000100 Octet unspecified 8 bit binary 00000...

Page 1045: ...SMS gateway message sending commands ColdFusion applications that use gateways of the Short Message Service SMS type can send the following commands to the event gateway in an outgoing message submit...

Page 1046: ...messagePayload The message contents You must specify one of these fields but not both The SMPP specification imposes a maximum size of 254 bytes on the shortMessage field and some carriers might limit...

Page 1047: ...sage originator cffunction name onIncomingMessage output no cfargument name CFEvent type struct required yes Create a return structure that contains the message cfset retValue structNew cfset retValue...

Page 1048: ...e of these fields but not both The SMPP specification imposes a maximum size of 254 bytes on the shortMessage field and some carriers might limit its size further The messagePayload field can contain...

Page 1049: ...FEvent type struct required yes Get the message cfset data cfevent DATA cfset message data message Create the return structure cfset retValue structNew cfset retValue command submitmulti cfset retValu...

Page 1050: ...values Field Contents command Must be data messagePayload The message data To convert data to binary format use the ColdFusion MX ToBinary function destAddress The address to which to send the messag...

Page 1051: ...nIncomingMessage output no cfargument name CFEvent type struct required yes Get the message cfset data CFEvent DATA cfset message data message Create the return structure cfset retValue structNew cfse...

Page 1052: ...le with data to log props file GenericCFCtest props type warning status SendGatewayMessage DefaultCFC props if status IS True WriteOutput Event Message props Message has been sent cfscript Field Use c...

Page 1053: ...and message cfcomponent cffunction name logEvent output no cfargument name CFEvent type struct required yes cfscript if NOT IsDefined CFEvent Data file CFEvent Data file defaultEventLog if NOT IsDefin...

Page 1054: ...1054 Chapter 6 ColdFusion MX Event Gateway Reference...

Page 1055: ...CCFXException class 1056 CCFXQuery class 1058 CCFXRequest class 1062 CCFXStringSet class 1072 C class overview The following table lists the CFXAPI classes and methods Class Methods CCFXException clas...

Page 1056: ...uteExists CCFXRequest CreateStringSet CCFXRequest Debug CCFXRequest GetAttribute CCFXRequest GetAttributeList CCFXRequest GetCustomData CCFXRequest GetQuery CCFXRequest ReThrowException CCFXRequest Se...

Page 1057: ...from CFX_FOO2 pRequest ThrowException User Error You goof d Output optional debug info if pRequest Debug pRequest WriteDebug Debug info Catch ColdFusion exceptions re raise them catch CCFXException e...

Page 1058: ...Query GetColumns retrieves a list of a query s column names virtual LPCSTR GetData int iRow int iColumn CCFXQuery GetData retrieves a data element from a row and column of a query virtual LPCSTR GetNa...

Page 1059: ...n Retrieves a list of the column names contained in a query Returns Returns an object of CCFXStringSet class that contains a list of the columns in the query ColdFusion automatically frees the memory...

Page 1060: ...urned string set Returns Returns the value of the requested data element Parameters Example The following example iterates over the elements of a query and writes the data in the query back to the use...

Page 1061: ...CCFXQuery pQuery pRequest GetQuery char buffOutput 256 wsprintf buffOutput The number of rows in the query is ld pQuery GetRowCount pRequest Write buffOutput CCFXQuery SetData Syntax void CCFXQuery S...

Page 1062: ...tom extension for the following actions Reading and writing variables Returning output Creating and using queries Throwing exceptions Class methods virtual BOOL AttributeExists LPCSTR lpszName CCFXReq...

Page 1063: ...et pColumns CCFXRequest AddQuery adds a query to the template that contains this tag virtual BOOL Debug CCFXRequest Debug checks whether the tag contains the Debug attribute virtual void WriteDebug LP...

Page 1064: ...ry SetData iRow iLastName Smith iRow pQuery AddRow pQuery SetData iRow iFirstName Jane pQuery SetData iRow iLastName Doe CCFXRequest AttributeExists Syntax BOOL CCFXRequest AttributeExists LPCSTR lpsz...

Page 1065: ...ddString Blue CCFXRequest Debug Syntax BOOL CCFXRequest Debug void Description Checks whether the tag contains the Debug attribute Use this function to determine whether to write debug information for...

Page 1066: ...ue of one attribute use CCFXRequest GetAttribute Returns Returns an object of class CCFXStringSet class that contains a list of attributes passed to the tag The memory allocated for the returned strin...

Page 1067: ...tWork CCFXRequest pRequest MYTAGDATA pTagData MYTAGDATA pRequest GetCustomData remainder of procedure CCFXRequest GetQuery Syntax CCFXQuery CCFXRequest GetQuery void Description Retrieves a query that...

Page 1068: ...on is used to avoid having C exceptions that are thrown by DLL extension code propagate back into ColdFusion Catch ALL C exceptions that occur in extension code and either re throw them if they are of...

Page 1069: ...id ProcessTagRequest CCFXRequest pRequest try MYTAGDATA tagData pRequest SetCustomData LPVOID tagData remainder of procedure CCFXRequest SetVariable Syntax void CCFXRequest SetVariable LPCSTR lpszName...

Page 1070: ...nds processing of a request Call this function when you encounter an error that does not allow you to continue processing the request This function is almost always combined with the CCFXRequest ReThr...

Page 1071: ...STINATION pRequest Write buffOutput CCFXRequest WriteDebug Syntax void CCFXRequest WriteDebug LPCSTR lpszOutput Description Writes text output into the debug stream The text is only displayed to the e...

Page 1072: ...ings to a string set and saving the indexes of the items that are added CCFXStringSet pSet pRequest CreateStringSet int iRed pSet AddString Red int iGreen pSet AddString Green int iBlue pSet AddString...

Page 1073: ...tString i pRequest Write BR CCFXStringSet GetIndexForString Syntax int CCFXStringSet GetIndexForString LPCSTR lpszString Description Searches for a passed string The search is case insensitive Returns...

Page 1074: ...Returns Returns the string located at the passed index Parameters Example The following example demonstrates GetString with CCFXStringSet GetCount to iterate over a string set and write the contents...

Page 1075: ...iew 1075 Custom tag interface 1076 Query interface 1077 Request interface 1082 Response interface 1087 Debugging classes reference 1090 Class libraries overview The following Java interfaces are avail...

Page 1076: ...available using the Request object passed to the processRequest method Methods processRequest Description Processes a request originating from the Java CFX tag Category Custom tag interface Syntax pu...

Page 1077: ...that has three columns City State and Zip Define column indexes Parameter Description request Parameters attributes query and so on for this request response Interface for generating response to requ...

Page 1078: ...if no such column exists Category Query interface Syntax public int getColumnIndex String name See also getColumns getData Parameters Example The following example retrieves the index of the EMAIL col...

Page 1079: ...ns length Print the list of columns to the user response write Columns in query for int i 0 i nNumColumns i response write columns i getData Description Retrieves a data element from a row and column...

Page 1080: ...ow iCol response write BR getName Description Returns the name of a query Category Query interface Syntax public String getName Example The following example retrieves the name of a query and writes i...

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

Page 1082: ...name See also getAttribute getAttributeList Parameters Returns Syntax Description boolean attributeExists String name Checks whether the attribute was passed to this tag boolean debug Checks whether t...

Page 1083: ...tag contains the debug attribute False otherwise Category Request interface Syntax public boolean debug See also writeDebug Example The following example checks whether the debug attribute is present...

Page 1084: ...ieve the value of one attribute use the getAttribute method Returns an array of strings containing the names of the attributes passed to the tag Category Request interface Syntax public String getAttr...

Page 1085: ...is not a valid number See also attributeExists getAttributeList getIntAttribute Parameters Example The following example retrieves an attribute named PORT and writes its value back to the user int nPo...

Page 1086: ...ion Registry key Returns the value of the custom tag setting If no setting of that name exists an empty string is returned Category Request interface Syntax public String getSetting String name Parame...

Page 1087: ...String columns Throws IllegalArgumentException 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...

Page 1088: ...ists in the template its value is replaced If it does not exist a new variable is created Category Response interface Syntax public void setVariable String name String value Throws IllegalArgumentExce...

Page 1089: ...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 method Category Response interface Sy...

Page 1090: ...uest with 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 que...

Page 1091: ...ese are the JavaScript objects and functions WDDX JavaScript objects are defined in the wddx js file this file is installed in the CFIDE scripts directory To use these objects you must put a JavaScrip...

Page 1092: ...WddxRecordset instance Example This example shows a JavaScript function that you can call to serialize a WddxRecordset instance It copies serialized data to a form field for display function serializ...

Page 1093: ...ters Return value Returns a Boolean True if serialization was successful False otherwise This is an internal function you do not typically call it Example This example is from the WddxSerializer seria...

Page 1094: ...alue Returns a Boolean True if obj was serialized successfully False otherwise Usage This is an internal function you do not typically call it Example This example is from the WddxSerializer serialize...

Page 1095: ...lue this write boolean value obj WddxRecordset object Includes functions that you call as needed when constructing a WDDX record set For more information on using this object see Using WDDX in Chapter...

Page 1096: ...ddx 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 column...

Page 1097: ...eviously 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 Usage This func...

Page 1098: ...position Usage Call this function to access a value in a WDDX record set Example This example calls the getField function the variable r is a reference to a WddxRecordset instance for row 0 row nRows...

Page 1099: ...Description Sets the element in the specified row column position Syntax object setField row col value Parameters Return value None Usage Call this function to set a value in a WddxRecordset instance...

Page 1100: ...eturn value Returns a Boolean True if serialization was successful False otherwise Usage This is an internal function you do not typically call it Example This example is from the WddxSerializer seria...

Page 1101: ...R 10 ColdFusion ActionScript Functions This chapter explains the syntax and usage of the two Macromedia ColdFusion MX 7 server side ActionScript functions CF query and CF http Contents CF query 1102 C...

Page 1102: ...a shorthand coding style does not support all arguments Use the following syntax to code the CF query function using positional arguments CF query datasource sql CF query datasource sql maxrows CF qu...

Page 1103: ...ailed information about the RecordSet ActionScript class see Using Flash Remoting Example Define a function to do a basic query Note use of positional arguments function basicQuery result CF query myq...

Page 1104: ...rd resolveurl yes or no params arrayvar path path file filename Arguments Arguments Req Opt Description method Required One of two arguments get downloads a text or binary file or creates a query from...

Page 1105: ...at is returned into the Filecontent property has its internal URLs fully resolved including port number so that links remain intact The following HTML tags which can contain links are resolved img src...

Page 1106: ...cified URL location contains text data Charset The charset used by the document specified in the URL HTTP servers normally provide this information or the charset is specified in the charset parameter...

Page 1107: ...rams 3 name arg3 type CGI value value3 url http localhost 8100 path application getContext getRealPath file foo txt result CF http method post url url username karl password salsa resolveurl true para...

Page 1108: ...s new Array params 1 name arg2 type URL value value2 url http localhost 8100 Invoke with the method url and params result CF http post url params return result get Filecontent Example with username an...

Reviews: