This example shows the use of the cfslider tag. Rate your approval of this example from 1 to 10 by sliding control.
cfftp Description Lets users implement File Transfer Protocol (FTP) operations. Category File management tags, Internet Protocol tags Syntax The tag syntax depends on the action attribute value. See the following sections: • “cfftp: Opening and closing FTP server connections” on page 138 • “cfftp: Connection: File and directory operations” on page 141 • “cfftp action = "listDir"” on page 145 See also cfhttp, cfldap, cfmail, cfpop History ColdFusion MX: Deprecated the agentname attribute.
cfftp: Opening and closing FTP server connections Description To establish a connection with an FTP server, you use the open action with a connection attribute.
Attribute Req/Opt Default Description stopOnError Optional No • Yes: halts processing, displays an appropriate error. • No: populates these variables: - cfftp.succeeded – Yes or No. - cfftp.errorCode – Error number. See the IETF Network Working Group RFC 959: File Transfer Protocol (FTP) www.ietf.org/rfc/rfc0959.txt. - cfftp.errorText – Message text For conditional operations, use cfftp.errorCode. Do not use cfftp.errorText for this purpose.
stopOnError = "Yes" name = "ListFiles" directory = "/" connection = "my_query"> #name# Close the connection: Did it succeed? #cfftp.
cfftp: Connection: File and directory operations Description Use this form of the cfftp tag to perform file and directory operations with cfftp.
Attribute Req/Opt Default Description ASCIIExtension Optional List txt;htm;html; Delimited list of file extensions that force ASCII transfer mode, if transferMode = "auto".
The cfftp.returnValue variable provides the return value for these actions: • • • • • getCurrentDir getCurrentURL existsDir existsFile exists For more information, see Developing ColdFusion MX Applications. Caution: Object (file and directory) names are case-sensitive. Action (cfftp.ReturnValue variable) The results of an action determine the value of the cfftp.returnValue variable. cfftp action Value of cfftp.returnValue getCurrentDir String. Current directory. getCurrentURL String. Current URL.
action = "close" stopOnError = "Yes"> Did it succeed? #cfftp.
cfftp action = "listDir" Description To access the columns in a query object, use this tag with action = "listDir". Usage When you use this action, you must specify a value for the name attribute. This value holds the results of the listDir action in a query object. The query object consists of columns that you can reference, in the form queryname.columname[row], where queryname is the name of the query, specified in the name attribute; and columnname is a column returned in the query object.
cffunction Description Defines a function that you can call in CFML. Required to defined ColdFusion component methods.
Attribute Req/Opt Default Description roles Optional "" (empty) A comma-delimited list of ColdFusion security roles that can invoke the method. Only users who are logged in with the specified roles can execute the function. If this attribute is omitted, all users can invoke the method.
access="remote" returnType="query" hint="This query returns all records in the employee database. It can drill-down or narrow the search, based on optional input parameters."> For information on using the cffunction tag for ColdFusion components, see Chapter 11, “Building and Using ColdFusion Components,” in Developing ColdFusion MX Applications. If you specify a roles attribute, the function executes only if a user is logged in and belongs to one of the specified roles.
cfgraph Description This tag is deprecated. Use the cfchart, cfchartdata, and cfchartseries tags instead. Displays data graphically. History ColdFusion MX: Deprecated this tag. It works differently than it did in ColdFusion 5, and it might not work in later releases.
cfgraph tag attribute ColdFusion MX functionality Showvaluelabel • yes: displays values on mouse-click; • no: suppresses value displays • rollover: displays values on mouse-over. Valuelocation Ignored url URL of page to open if any item in the graph is clicked.
cfgraphdata Description This tag is deprecated. Use the cfchart, cfchartdata, and cfchartseries tags instead. Displays a data point in a graph. Used within the cfgraph tag. History ColdFusion MX: Deprecated this tag. It works differently than in ColdFusion 5 and might not work in later releases.
cfgrid Description Used within the cfform tag. Puts a grid control (a table of data) in a ColdFusion form. To specify grid columns and row data, use the cfgridcolumn and cfgridrow tags, or use the query attribute, with or without cfgridcolumn tags.
deleteButton = "text" sortAscendingButton = "text" sortDescendingButton = "text"> See also cfgridcolumn, cfgridrow, cfgridupdate, cfapplet, cfform, cfinput, cfselect, cfslider, cftextinput, cftree, cftreeitem History ColdFusion MX: Changed the rowHeaderWidth attribute: ColdFusion does not use the rowHeaderWidth attribute. You can omit it. Attributes Attribute Req/Opt Default Description name Required height Optional 300 Height of grid control, in pixels.
Attribute Req/Opt Default Description sort Optional No The sort button performs simple text sort on column. User can sort columns by clicking column head or by clicking sort buttons. Not valid with selectmode=browse. • Yes: sort buttons display on grid control • No font Optional Font of column data in the grid control. fontSize Optional Size of text in the grid control, in points.
Attribute Req/Opt Default Description rowHeight Optional rowHeaders Optional Yes • Yes: displays a column of numeric row labels in grid control • No rowHeaderAlign Optional Left • Left: left-aligns data within row header • Right: right-aligns data within row header • Center: center-aligns data within row header rowHeaderFont Optional Row label font. rowHeaderFontSize Optional Row label text size in grid control, in points.
Attribute Req/Opt Default Description selectMode Optional Browse Selection mode for items in grid control. • Edit: user can edit grid data. Selecting a cell opens the editor for the cell type. • Single: user selections are limited to selected cell. • Row: user selections automatically extend to the row that contains selected cell. • Column: user selections automatically extend to column that contains selected cell.
Simple selection data (SelectMode = Single, Column, or Row) The data that form variables return to the cfform's action page contains information about which cells the user selected. In general, ColdFusion makes this data 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.#GridName#.#ColumnName# = "SelectedCellValue" • SelectMode="column" form.
Loop Index | Action | Old Value | New Value | #LoopCount# | #Val_Action# | #Val_Orig# | #Val_New# | form.#GridName#.
SELECT Course_ID, Dept_ID, CorNumber, CorName, CorLevel, CorDesc FROM CourseList ORDER by Dept_ID ASC, CorNumber ASC cfgrid Example cfgrid Example Try adding a course to the database, and then deleting it.
...
cfgridcolumn Description Used with the cfgrid tag in a cfform. Use this tag to specify column data in a cfgrid control. The font and alignment attributes used in cfgridcolumn override global font or alignment settings defined in cfgrid.
Attribute Req/Opt Default Description width Optional; see Description Column head Column width, in pixels. width font Optional As specified by cfgrid Font of data in column. fontSize Optional As specified by cfgrid Size of text in column.
Attribute Req/Opt Default Description select Optional display Optional type Optional headerFont Optional as specified by cfgrid Column header font headerFontSize Optional as specified by cfgrid Column header text size, in pixels headerItalic Optional as specified by cfgrid • Yes: displays column header in italics • No headerBold Optional as specified by cfgrid • Yes: displays header in bold • No • Yes: user can select the column in grid control.
Attribute Req/Opt values Optional Default Description Formats cells in column as drop-down list boxes; specify items in drop-down list. Example: values = "arthur, scott, charles, 1-20, mabel" valuesDisplay Optional valuesDelimiter Optional Maps elements in values attribute to string to display in drop-down list. Delimited strings and/or numeric range(s). , [comma] Delimiter in values and valuesDisplay attributes.
numberFormat mask characters You can use the following numberFormat attribute mask characters, which correspond to those in the NumberFormat function, to format output in U.S. numeric and currency styles. For more information, see NumberFormat on page 631. (This tag does not support international number formatting.) Character Meaning _ (Underscore) Digit placeholder. 9 Digit placeholder. . (Period) Location of mandatory decimal point.
cfgridrow Description Lets you define a cfgrid that does not use a query as source for row data. If a query attribute is specified in cfgrid, the cfgridrow tags are ignored. Category Forms tags Syntax See also cfgrid, cfgridcolumn, cfgridupdate, cfapplet, cfform, cfinput, cfselect, cfslider, cftextinput, cftree Attributes Attribute Req/Opt Default Description data Required Delimited list of column values.
This grid shows how the same grid can be built using cfgridrow with cfloop (i.e., defining query external to cfgrid, rather than within cfgrid). ...
cfheader Description Generates custom HTTP response headers to return to the client. Category Data output tags, Page processing tags Syntax or See also cfcache, cfflush, cfhtmlhead, cfinclude, cfsetting, cfsilent, cfcontent History ColdFusion MX 6.
Attribute Req/Opt Default Description statusCode Required if name not specified Number. HTTP status code statusText Optional Explains status code Usage If you use this tag after the cfflush tag on a page, an error is thrown. Example cfheader Example cfheader generates custom HTTP response headers to return to the client. This example forces browser client to purge its cache of requested file.
cfhtmlhead Description Writes text to the head section of a generated HTML page. It is useful for embedding JavaScript code, or putting other HTML tags, such as meta, link, title, or base in an HTML page header. Category Page processing tags Syntax See also cfcache, cfflush, cfheader, cfheader, cfinclude, cfsetting, cfsilent Attributes Attribute Req/Opt text Required Default Description Text to add to the area of an HTML page.
cfhttp Description Generates an HTTP request and handles the response from the server.
ColdFusion MX: • Added the charset and firstrowasheaders attributes. • Changed Secure Sockets Layer (SSL) support: ColdFusion uses the Sun JSSE library, which supports 128-bit encryption, to support SSL. Attributes The following attributes 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 the request. The URL must include the hostname or IP address.
Attribute Req/Opt Default Description proxyUser Opt User name to provide to the proxy server. proxyPassword Opt Password to provide to the proxy server. username Opt A username. May be required by server. password Opt A password. May be required by server userAgent Opt Cold Fusion Text to put in the user agent request header. Used to identify the request client software. Can make the ColdFusion application appear to be a browser.
Attribute Req/Opt Default Description throwOnError Opt No • Yes if the server returns an error response code, throws an exception that can be caught using the cftry and cfcatch or ColdFusion error pages. • No does not throw an exception if an error response is returned. In this case, your application can use the cfhttp.StatusCode variable to determine if there was an error and its cause.
The following attribute is used with the PUT method to determine how to send data specified with httpparam type="formField": Attribute Req/Opt Default Description multipart Optional Tells ColdFusion to send all data specified by cfhttpparam type="formField" tags as multipart form data, with a No (Sends as multipart only if request includes File type data.) Content-Type of multipart/form-data.
The following attributes tell ColdFusion to convert the HTTP response body into a ColdFusion query object. They can be used with the GET and POST methods only: Attribute Req/Opt Default Description name Opt Tells ColdFusion to create a query object with the given name from the returned HTTP response body. columns Opt First row of response contains column names. The column names for the query, separated by commas. Column names must start with a letter.
The HTTP protocol is the backbone of the World Wide Web and is used for every web transaction. Because the cfhttp tag can generate most types of requests, it provides significant flexibility. Possible uses include: • Interacting with dynamic web sites and services that are not available as web services. (Use the the cfinvoke tag to access SOAP web services.) • Getting the contents of an HTML page or other file such as an image on a web server for use in your CFML page or storage in a file.
Building a query from a delimited text file The cfhttp tag can create a ColdFusion query object form the response body. To do so, the response body must consist of lines of text, with each line having fields that are delimited by a character that identifies the column breaks. The default delimiter is a comma (,). The response data can also use a text qualifier; the default is a double quotation mark ("). If you surround a string field in the text qualifier, the field can contain the delimiter character.
http://www.macromedia.com/desdev/resources/macromedia_resources.xml See http://www.macromedia.com/desdev/articles/xml_resource_feed.html for more information on this feed ---> PAGE 198
query="book"> PAGE 199
datasource="book"> select * from book where bookid='file' --#description#-- PAGE 200
200 Chapter 2: ColdFusion Tags
cfinput Description Used within the cfform tag, to place radio buttons, check boxes, or text boxes on a form. Provides input validation for the specified control type.
Attribute Req/Opt Default Description validate Optional Verifies a value’s format: • date: US date mm/dd/yyyy • eurodate: European date dd/mm/yyyy • time: time hh:mm:ss • float: floating point entry • integer: integer entry • telephone: telephone ###-###-####. Separator: hyphen or blank. Area code and exchange must begin with a digit 1 – 9. • zipcode: (U.S. formats only) 5-digit ##### or 9-digit #####-####. Separator: hyphen or blank.
• • • • • • • • • class id onBlur onChange onClick onDblclick onFocus style tabIndex Usage If the cfform preserveData attribute is true and the form posts back to the same page, the posted value of the cfinput control is used, instead of its Value or Checked attribute. If cfinput check box or radio type values match the submitted value for the control, ColdFusion checks their values. If no value matches, nothing is checked.
message = "Enter a correctly formatted date (dd/mm/yy)" validate = "date" required = "No"> 204 Chapter 2: ColdFusion Tags
cfinsert Description Inserts records in data sources from data in a ColdFusion form or form Scope. Category Database manipulation tags Syntax PAGE 206
Example Your record was added to the database.
type = "hidden" = "posted" value = "#Now()#"> type = "Submit" = "" value = "insert my comment"> cfinsert 207
cfinvoke Description Does either of the following: • Invokes a component method from within a ColdFusion page or component. • Invokes a web service.
inputParam1 = "value1" inputParam2 = "value2" ... returnVariable = "var_name" ...> OR #res# Example3 This example uses Syntax 2.
cfinvokeargument Description Passes the name and value of a parameter to a component method or a web service. This tag is used within the cfinvoke tag. Category Extensibility tags Syntax See also cfargument, cfcomponent, cffunction, cfinvoke, cfobject, cfproperty, cfreturn History ColdFusion MX: Added this tag.
name="sourcedata" value="Hello world, friend"> #varName# 214 Chapter 2: ColdFusion Tags
cfldap Description Provides an interface to a Lightweight Directory Access Protocol (LDAP) directory server, such as the Netscape Directory Server. Category Forms tags, Internet Protocol tags Syntax PAGE 216
Attributes Attribute Req/Opt server Required port Optional 389 Port Required if (anonymous) User ID username Default Description Host name or IP address of LDAP server. secure = "CFSSL_BASIC" password Password that corresponds to user name. If secure = "CFSSL_BASIC", V2 encrypts the password before transmission. Required if secure = "CFSSL_BASIC" action name Optional query Required if • query: returns LDAP entry information only. Requires name, start, and attributes attributes.
Attribute Req/Opt sort Optional sortControl Optional dn startRow Default Description Attribute(s) by which to sort query results. Use a comma delimiter. asc • nocase: case-insensitive sort • asc: ascending (a to z) case-sensitive sort • desc: descending (z to a) case-sensitive sort You can enter a combination of sort types; for example, sortControl = "nocase, asc". Required if Distinguished name, for update action.
Attribute Req/Opt Default Description 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 sign), the attributes attribute could be "objectclass = top$person", where the first value of objectclass is top, and the second value is person. This avoids confusion if values include commas.
Provides an interface to LDAP directory servers. The example uses the University of Connecticut public LDAP server. For more public LDAP servers, see http://www.emailman.com. Enter a name and search the public LDAP resource. An asterisk before or after the name acts as a wildcard.
cflocation Description Stops execution of the current page and opens a ColdFusion page or HTML file. Category Flow-control tags, Page processing tags Syntax See also cfabort, cfbreak, cfexecute, cfexit, cfif, cfloop, cfswitch, cfthrow, cftry Attributes Attribute Req/Opt Default Description url Required URL of HTML file or CFML page to open. addToken Optional clientManagement must be enabled (see cfapplication on page 51).
cflock Description Ensures the integrity of shared data. Instantiates the following kinds of locks: • • Exclusive allows single-thread access to the CFML constructs in its body. The tag body can be executed by one request at a time. No other requests can start executing code within the tag while a request has an exclusive lock. ColdFusion issues exclusive locks on a first-come, first-served basis. Read-only allows multiple requests to access CFML constructs within the tag body concurrently.
Attribute Req/Opt Default Description throwOnTimeout Optional Yes type Exclusive • readOnly: lets more than one request read shared data. • exclusive: lets one request read or write shared data. Optional How timeout conditions are handled. • Yes: exception is generated for the timeout. • No: execution continues past this tag. Note: Limit the scope of code that updates shared data structures, files, and CFXs.
These examples show situations that cause deadlocks: Example deadlock with two users User 1 User 2 Locks the session scope. Locks the Application scope. Deadlock: Tries to lock the Application scope, but it is already locked by User 2. Deadlock: Tries to lock the Session scope, but it is already locked by User 1. The following deadlock could occur if you tried to nest an exclusive lock inside a read lock: Example deadlock with one user User 1 Locks the Session scope with a read lock.
E-Turtleneck has sold #application.number# turtlenecks to date. |