MACROMEDIA COLDFUSION 4.5-DEVELOPING WEB Applications - page 221
Chapter 12: Using the Application Framework
195
period, ColdFusion interprets this as the end of the session and clears any variables
associated with that session.
The default time-out for session variables is set to 20 minutes. In the Variables page of
the ColdFusion Administrator, you can change this time-out value. See Administering
ColdFusion Server for more information.
You can also set the time-out period for session variables inside a specific application
(thereby overruling the Administrator default setting) by using the SESSIONTIMEOUT
attribute of the CFAPPLICATION tag.
Storing session data in session variables
Session variables are designed to store session-level data. They are a convenient place
to store information that all pages of your application might need during a user
session. Using session variables, an application could initialize itself with user-specific
data the first time a user hit a page of that application. This information could then
remain available while that user continues to use that application. For example,
information about a specific user’s preferences could be retrieved from a database
once, the first time a user hits any page of an application. This information would
remain available throughout that user’s session, thereby avoiding the overhead of
retrieving the preferences again and again.
Session variables work exactly as client variables do, in that they require a client name
(client ID) and are always scoped within that client ID. Session variables also work
within the scope of an application name if one is supplied, in which case their scope
will be the combination of the client ID and the application name.
To enable session variables, set
SESSIONMANAGEMENT="Yes"
in the CFAPPLICATION tag
in your
Application.cfm
file. Note that when you turn on session management in the
CFAPPLICATION tag, you must specify the application’s name. Following is an
example of turning on session management:
MAILTO="webmaster@mysite.com"> MAILTO="webmaster@mysite.com"> structure functions there are several functions that help you create and manage structures in coldfusion applications. Structure functions function description isstruct returns true if the specified ... Chapter 9: handling complex data with structures 121 note that in all cases, except structdelete, an exception will be thrown if the referenced key or structure does not exist. For more information on these functions, see the cfml language reference. Structnew returns a new structure. Structupdate u... 122 developing web applications with coldfusion. C h a p t e r 1 0 chapter 10 building dynamic forms this chapter shows you how to use the cfform tag to enrich your forms with sophisticated graphical controls, including several java applet-based controls. These controls can be enabled without the need to code java directly. Contents • creating for... 124 developing web applications with coldfusion creating forms with the cfform tag you’ve already learned how to use html forms to gather user input. (see “using forms to specify the data to retrieve” on page 30 .) this chapter shows you how to use the cfform tag to create dynamic forms in cfml. In ... Chapter 10: building dynamic forms 125 improving performance with enablecab the cfform enablecab attribute allows you to improve the performance of java- applet based cfform controls. When you use enablecab, coldfusion prompts the end user to accept a download of the java classes needed for the cffo... 126 developing web applications with coldfusion input validation with cfform controls the cfinput and cftextinput tags include the validate attributes which allows you to specify a valid data type entry for the control. You can validate user entries on the following data types. When you specify an i... Chapter 10: building dynamic forms 127 input validation with javascript in addition to native coldfusion input validation using the validate attribute of the cfinput and cftextinput tags, the following tags support the onvalidate attribute , which allows you to specify a javascript function to handl... 128 developing web applications with coldfusion to use javascript to validate form data: 1. Create a new file in studio. 2. Edit the page so that it appears as follows: 4 please enter your email address: action="update.Cfm" > name="inputbox1" required="yes" 4 onvalidate="testbox" message="sorry, inv... Chapter 10: building dynamic forms 129 code review see the following web site for information on javascript validation scripts: • http://www.Dannyg.Com/javascript building tree controls with cftree the cftree form lets you display hierarchical information in a space-saving collapsible tree populated... 130 developing web applications with coldfusion 4 query="engquery" 4 queryasroot="yes" 4 img="folder,document"> 4 3. Save the page and view it in your browser. Code review grouping output from a query in a similar query, you may want to organize your employees by the department. In this case, you se... Chapter 10: building dynamic forms 131 method="post"> hscroll="no" vscroll="no" border="yes" height="350" required="yes"> query="deptquery" queryasroot="department_id" img="cd,folder"> method="post"> hscroll="no" vscroll="no" border="yes" height="350" required="yes"> query="deptquery" queryasroot="d... 132 developing web applications with coldfusion • form.Treename.Path — returns the complete path of the user selection, in the form: rootode1ode2ode_n\value the root part of the path is only returned if you set the completepath attribute tof cftree to yes; otherwise, the path value starts with... Chapter 10: building dynamic forms 133 example: multi-level tree control when populating a cftree, you manipulate the structure of the tree by specifying a treeitem parent. In this example, every treeitem, except the top level, specifies a parent. The parent attribute allows your cftree to show the ... 134 developing web applications with coldfusion the built-in image names are: • cd • computer • document • element • folder • floppy • fixed • remote embedding urls in a cftree the href attribute in the cftreeitem tag allows you to designate tree items as links. To use this feature in a cftree, you ... Chapter 10: building dynamic forms 135 code review specifying which tree items to send to the action page when a user selects a tree item and submits the form, the cftreeitemkey variable is appended to the url passed to the application page specified in the cfform action attribute, in the form: http... 136 developing web applications with coldfusion populating a grid from a query to populate a grid from a query: 1. Open a new file named grid1.Cfm in studio. 2. Edit the file so that it appears as follows: select * from employees selectmode="single"> selectmode="single"> note use the cfgridcolumn di... Chapter 10: building dynamic forms 137 code review note if you specify a cfgrid tag with a query attribute defined and no corresponding cfgriditem attributes the default grid that is created contains all the columns in the query. Creating an updateable grid you can build grids to allow users to edit... 138 developing web applications with coldfusion editing data in a cfgrid to enable grid editing, you use the selectmode="edit" attribute. When enabled, a user can edit cell data and insert or delete grid rows. When a cfform containing a cfgrid is submitted, data about changes to grid cells are store... Chapter 10: building dynamic forms 139 headeritalic="no" headerbold="yes" display="yes" select="yes"> header="department" width=240 italic="no" headeralign="center" headeritalic="no" headerbold="yes" bold="yes" display="yes"> 3. Save the file as grid2.Cfm . To update the data source with cfquery: 1.... 140 developing web applications with coldfusion datasource="companyinfo"> update employees set lastname=’#form.Employee_grid.Lastname[counter]#’, department_id=#form.Employee_grid.Department_id[counter]# where employee_id=#form.Employee_grid.Original.Employee_id[counter]# datasource="companyinfo"> u... Chapter 10: building dynamic forms 141 how user edits are stored the following arrays are created to keep track of edits to grid rows and cells: for example, you have an updateable cfgrid called "mygrid" consisting of two displayable columns, col1, col2, and one hidden column, col3. When an end user... 142 developing web applications with coldfusion building slider bar controls you can use the cfslider control to create a slider control and define a wide range of formatting options for slider label text, , colors for the groove in which the slider knob moves, label font name, size, boldface, itali... Chapter 10: building dynamic forms 143 validation methods using either a javascript or the validate attribute in cftextinput. The following example shows a basic cftextinput control. This example validates a date entry, which means that a user must enter a valid date in the form mm/dd/yy. For a comp... 144 developing web applications with coldfusion to populate a drop-down list box with query data using cfselect: 1. Open a new file in studio. 2. Modify the file so that it appears as follows: datasource="companyinfo"> select * from employees datasource="companyinfo"> select * from employees method=... Chapter 10: building dynamic forms 145 • parameter options — you can override parameter values you defined in the administrator by specifying the parameter value pair in cfapplet. Unless overridden, coldfusion uses the parameter value pairs you defined in the administrator. When an applet is registe... 146 developing web applications with coldfusion click create to complete the process. Using cfapplet to embed an applet once you’ve registered an applet, you can use the cfapplet tag to place the applet in a coldfusion page. The cfapplet tag has two required attributes, appletsource and name. Since ... Chapter 10: building dynamic forms 147 name="applet1_var" height=400 width=200 vspace=125 hspace=125 align="left"> overriding parameter values you can also override the values you assigned to applet parameters in the administrator by providing new values for any parameter. Note that in order to over... 148 developing web applications with coldfusion. C h a p t e r 1 1 chapter 11 indexing and searching data you can provide a full-text search capability for documents and data sources on a coldfusion site by enabling the verity search engine. Contents • searching a coldfusion web site.................................................................... 150 developing web applications with coldfusion searching a coldfusion web site until now, you’ve searched for records in databases based on the value of particular fields using odbc. However, to efficiently search through paragraphs of text or files of varying types requires full-text search capabi... Chapter 11: indexing and searching data 151 online verity training a video titled "creating search engines with verity" is available at http:// alive.Allaire.Com . The video gives an overview of the verity implementation in coldfusion and illustrates the development process with sample code. The vid... 152 developing web applications with coldfusion support for international languages the coldfusion international language search pack can be purchased and installed to index data in any the following languages: • danish • dutch • finnish • french • german • italian • norwegian • portuguese ms word f... Chapter 11: indexing and searching data 153 • spanish • swedish the default language for verity collections is english. To index data in one of the supported languages, you must select the language from the drop-down list when you create a collection on the coldfusion administrator verity page. You ... 154 developing web applications with coldfusion using the coldfusion administrator to create a collection to create a new collection: 1. Open the coldfusion administrator verity page. If you checked the option to install the coldfusion documentation, the documentation collection is listed by default... Chapter 11: indexing and searching data 155 collection name: size="25"> what do you want to do with the collection? Name="collectionaction" value="create" checked>create name="collectionaction" value="repair">repair name="collectionaction" value="optimize">optimize name="submit" value="submit"> 3. S... 156 developing web applications with coldfusion to create a collection action page: 1. Open a new file in studio. 2. Modify the file so that it appears as follows: collection="#form.Collectionname#" path="c:\cfusion\verity\collections\"> the collection #form.Collectionname# is created. Collection="#... Chapter 11: indexing and searching data 157 populating and indexing a collection at this point, the new collection is just an empty shell. To populate the collection with indexed data, you can use either of two methods: • the cf administrator • the cfindex tag you can use the verity wizard in coldfu... 158 developing web applications with coldfusion 5. Check the recursively index subdirectories box if you want to extend the indexing operation to all directories below the selected path. 6. Optionally, you can enter a return url to prepend to all indexed files. This allows you to easily create a lin... Chapter 11: indexing and searching data 159 to use cfindex to index a collection: 1. Open a new file in studio. 2. Modify the file so that it appears as follows: key="#form.Indexdir#" action="refresh" type="path" urlpath="#form.Indexdir#" extensions=".Htm, .Html" recurse="yes" language="english"> th... 160 developing web applications with coldfusion basic search operations to search the collection: 1. Create a new file in stuio. 2. Modify the file so that it appears as follows: enter the collection you want to search: p> select the type of search: name=type value=simple checked> simple name=type v... Chapter 11: indexing and searching data 161 collection="#form.Collection#" form type="#form.Type#" criteria="#form.Searchstring#"> search results collection="#form.Collection#" form type="#form.Type#" criteria="#form.Searchstring#"> #search1.Recordcount# found out of #search1.Recordssearched# search... 162 developing web applications with coldfusion cfsearch properties three properties are generated for each cfsearch query that provide information about a particular query: • recordcount — the total number of records returned by the query. • currentrow — the current row of the query being processed... Chapter 11: indexing and searching data 163 this cfindex statement specifies the messagetext column as the core of the collection and names the table’s primary key, the message_id column, as the key value. Note that the title attribute names the subject column. The title attribute can be used to des... Chapter 11: indexing and searching data 165 name="p_messages server="mail.Mycompany.Com" username="user1" password="user1"> #messagenumber# #from# #to# #subject# #body# ========================= collection="pop_query" key="messagenumber" type="custom" title="subject" query="p_messages" body="body"> ... 166 developing web applications with coldfusion pass a simple query expression to the search engine directly from an html input form. The verity query language provides many operators and modifiers for composing queries. The following search techniques can be used in searching a verity collection: •... Chapter 11: indexing and searching data 167 density of the search term in the searched documents. The more frequent the occurrence of a word in a document, the higher the document’s score. As a result, the search engine ranks documents according to word density as it searches for the word you specif... 168 developing web applications with coldfusion special characters a number of characters are handled in particular ways by the search engine. A backslash (\) removes special meaning from whatever character follows it. To enter a literal backslash in a query, use two in succession, such as this exam... Chapter 11: indexing and searching data 169 when prefix notation is used, precedence is handled explicitly within the expression. The following example means: "look for documents that contain b and c first, then documents that contain a": or (a, and (b,c)) when infix notation is used, precedence is ... 170 developing web applications with coldfusion searching with wildcards this table shows the wildcard characters for searching verity collections. Searching for wildcards as literals to search for a wildcard character in your collection, you need to escape the character with a backslash (\). For ex... Chapter 11: indexing and searching data 171 • left curly brace ({) • left bracket ([) • less than sign ( • backquote (‘ ) in addition to the backslash character, you can use paired backquotes (‘ ‘ ) to interpret special characters as literals. For example, to search for the wildcard string "a{b" you... 172 developing web applications with coldfusion • natural language operators — allow the use of natural language expressions in forming queries. Ordinarily, you use operators in explicit searches. They are used in the following manner: "search_string" evidence operators evidence operators can be use... Chapter 11: indexing and searching data 173 the following table describes each operator. Relational operators relational operators search document fields that have been defined in the collection. Documents containing specified field values are returned. Documents retrieved using relational operators... 174 developing web applications with coldfusion the following operators are used for numeric and date comparisons. Text comparison operators match words and parts of words. The following operators are used for text comparisons. Verity numerical and date relational operators operator description = eq... Chapter 11: indexing and searching data 175 document fields the values you specify for the cfindex attributes title, key, url, and custom can be specified as document fields for use with relational operators in the criteria attribute. Document fields are referenced in text comparison operators. They... 176 developing web applications with coldfusion the following application page matches records that have 1990 in the text column and are in the place utah. The search is performed against the collection that contains the text column and then is narrowed further by searching the string "utah" in the ... Chapter 11: indexing and searching data 177 #gettext_search.Title# concept operators concept operators combine the meaning of search elements to identify a concept in a document. Documents retrieved using concept operators are ranked by relevance. The following table describes each concept operator.... 178 developing web applications with coldfusion the following table lists the score operators. Modifiers modifiers can be used with operators to further refine query expressions. You can specify case sensitivity in a query, or force the output to be ranked by relevancy. Modifiers include: • case — s... Chapter 11: indexing and searching data 179 search modifiers modifiers are combined with operators to change the standard behavior of an operator in some way. For example, you can use the case modifier with an operator to specify that you want to match the case of the search word. Modifiers are as f... 180 developing web applications with coldfusion managing collections as with any data source, the maintenance requirements of a verity collection are dictated by the amount, frequency, and type of changes that occur in the records. You can run maintenance routines directly from either the cfcollecti... Chapter 11: indexing and searching data 181 • delete (when used as a cfindex action) — deletes the specified key value, or comma-separated values, from the collection. • delete (when used on the administrator verity page or in cfcollection) — deletes the entire collection. • update — re-populates th... 182 developing web applications with coldfusion. C h a p t e r 1 2 chapter 12 using the application framework the coldfusion web application framework is a powerful tool you can use to help structure your coldfusion applications. This section describes how to create and use the application.Cfm file, the application page that controls the applicati... 184 developing web applications with coldfusion understanding the web application framework a coldfusion application is a collection of application pages that work together. Applications can be as simple as a guest book or as sophisticated as a full internet commerce system with catalog pages, shopp... Chapter 12: using the application framework 185 custom error handling using the cferror tag, you can display customized html pages when errors occur. This allows you to maintain a consistent look and feel within your application even when errors occur. It also allows you to optionally suppress the d... 186 developing web applications with coldfusion • development: the application is easier to develop and maintain because the application page files are well organized. • portability: the application can be more easily moved to another server or another part of a server without having to change any c... Chapter 12: using the application framework 187 behavior with cfinclude only one application.Cfm file is ever processed for each coldfusion application page. The presence of an application.Cfm file is an implicit cfinclude. If it is present in the directory tree, there is no way not to include it. F... 188 developing web applications with coldfusion • default variables • custom error pages • data sources • default style settings • exclusive locks • other application-level constants note because unix is case sensitive, the application framework file must be spelled with an initial capital, applicat... Chapter 12: using the application framework 189 4 clientmanagement="yes"> 2. Save the file as application.Cfm in the root directory of your application framework. Choosing a client variable storage method once you have enabled client state management, you then have to determine where you want to sto... 190 developing web applications with coldfusion cookie storage when you set clientstorage="cookie" the cookie that coldfusion creates has the application’s name. Storing client data in a cookie is scalable to large numbers of clients, but this storage mechanism has some limitations. Chief among them... Chapter 12: using the application framework 191 creating a client variable to create a client variable and set the value of the parameter, use the cfset or cfparam tag., for example: once a client variable has been set in this manner, it is available for use within any application page in your appli... 192 developing web applications with coldfusion the client id (cfid)and the client security token (cftoken) between pages, either in hidden form fields or appended to urls. You accomplish this using the variable client.Urltoken or session.Urltoken. Note in coldfusion, client state management is expl... Chapter 12: using the application framework 193 variable caching all client variable reads and writes are cached to help decrease the overhead of client state management operations. See administering coldfusion server for information on variables and server clustering. Exporting the client variable ... 194 developing web applications with coldfusion for information on setting time-outs for variables, see administering coldfusion server. Differentiating client, session, and application variables this table shows the relationships among client, session, and application variables.: note coldfusion do... Chapter 12: using the application framework 195 period, coldfusion interprets this as the end of the session and clears any variables associated with that session. The default time-out for session variables is set to 20 minutes. In the variables page of the coldfusion administrator, you can change t... 196 developing web applications with coldfusion to be triggered on every page ---> using application variables application variables require an application name be associated with them and are always scoped within that application name. Unlike client and session variables, however, application varia... Chapter 12: using the application framework 197 you can set the time-out period for application variables within a specific application (thereby overriding the default setting in the coldfusion administrator) by using the applicationtimeout attribute of the cfapplication tag. If no clients access th... 198 developing web applications with coldfusion example: application.Cfm the following example shows a complete application.Cfm file for the sample products application: clientmanagement="yes" clientstorage="mycompany"> template="requesterr.Cfm" mailto="admin@company.Com"> template="validationerr.Cf... Chapter 12: using the application framework 199 • exclusive locks allow only one request to process the locked code. • read-only locks allow multiple requests to execute concurrently, provided that no exclusive locks are executing. Note unless you specify the type attribute, the default lock is excl... 200 developing web applications with coldfusion a deadlock is a state in which no request can execute the locked section of the page. Thus, all requests to the protected section of the page are blocked until there is a time- out. The following table shows one scenario that would cause a deadlock. On... Chapter 12: using the application framework 201 the following sample code might be part of the application.Cfm file. Cfapplication defines scoping for a coldfusion applicationand enables or disables the storing of client and/or session variables. This tag is placed in the application.Cfm file for th... 202 developing web applications with coldfusion e-turtleneck is proud to say that we have sold #application.Number# turtlenecks to date. Tip in general, you should limit lock scopes. When locking variables, queries, and arrays (anything other than structures), you can copy to a local variable in the... Chapter 12: using the application framework 203 congratulations! You have just selected the longest wearing, most comfortable turtleneck in the world. Please indicate the color and size you want to buy. Red white blue turquoise black forest green small medium large xlarge example of synchronizing ac... 204 developing web applications with coldfusion dynamic value for the name attribute to allow protection of a file with any given name. File=#filename# output=#texttoappend#> example of protecting coldfusion extensions this example illustrates how a custom tag wrapper can be built around cfxs that a... C h a p t e r 1 3 chapter 13 sending and receiving email you can add interactive email features to your coldfusion applications, providing complete two-way interface to mail servers via the cfmail tag and the cfpop tag. The boom in internet mail services makes coldfusion’s enhanced email capability ... 206 developing web applications with coldfusion using coldfusion with mail servers adding email to your coldfusion applications lets you respond automatically to user requests. You can use email in your coldfusion applications in many different ways. These are just a few examples: • trigger email me... Chapter 13: sending and receiving email 207 sending smtp mail with cfmail the cfmail tag provides support for sending smtp email from within coldfusion applications. The cfmail tag is similar to the cfoutput tag, except that cfmail outputs the generated text as smtp mail messages rather than to a pa... 208 developing web applications with coldfusion • use a query to send a customized mail message, such as a billing statement to a list of recipients that is dynamically populated from a database. • send a mime file attachment along with a mail message. Sending form-based email in the example below, ... Chapter 13: sending and receiving email 209 the "productrequests" query, while the text above and below it serve as the header and footer (respectively) for the mail message. Sending email to multiple recipients in the following example, a query ("cfbetatesters") is run to retrieve a list of people ... 210 developing web applications with coldfusion company name: #company# contact: #firstname# #lastname# address: #address1# #address2# #city#, #state# #zip# phone: #phone# fax: #fax# home page: #homepageurl# please let us know if any of the above information has changed, or if we need to get in touc... Chapter 13: sending and receiving email 211 advanced sending options the coldfusion implementation of smtp mail uses a spooled architecture. This means that when a cfmail tag is processed in an application page, the messages generated are not sent immediately. Instead, they are spooled to disk and p... 212 developing web applications with coldfusion use cfpop in applications when you want to receive email. Here are two instances where implementing pop mail makes sense: • if your site has generic mailboxes that are read by more than one person (sales@yourcompany.Com), it may be more efficient to co... Chapter 13: sending and receiving email 213 handling pop mail this section gives an example of each of the following usages: • retrieving only message headers • retrieving a message body • retrieving attachments • deleting messages returning only message headers the header includes: • date • from • ... 214 developing web applications with coldfusion cc: #htmleditformat(sample.Cc)# replyto: #htmleditformat(sample.Replyto)# 3. Change the following line so that it refers to a valid pop mail server, as well as a valid user name and password: username=#username# password=#password# 4. Save the file as ... Chapter 13: sending and receiving email 215 the message body: username=#username# password=#password# action="getall" name="sample"> messagenumber: #htmleditformat(sample.Messagenumber)# to: #htmleditformat(sample.To)# from: #htmleditformat(sample.From)# subject: #htmleditformat(sample.Subject)# dat... 216 developing web applications with coldfusion body, and all attachments: username=#username# password=#password# action="getall" attachmentpath="c:\attachdir" name="sample"> messagenumber: #htmleditformat(sample.Messagenumber)# to: #htmleditformat(sample.To)# from: #htmleditformat(sample.From)# su... Chapter 13: sending and receiving email 217 returned will be 1,2,3,4. If messages 1 and 2 are then deleted within a single cfpop tag, messages 3 and 4 will be assigned message numbers 1 and 2, respectively. To delete messages: 1. Create a new file in studio. 2. Modify the file so that it appears as ... 218 developing web applications with coldfusion. C h a p t e r 1 4 chapter 14 managing files on the server the cffile, cfdirectory, and cfcontent tags handle browser/server file management tasks. To perform server-to-server operations, use the cfftp tag. Contents • using cffile ......................................................................... 220 developing web applications with coldfusion using cffile the cffile tag gives you the ability to work with files on your server in a number of ways: • uploading files from a client to the web server using an html form. • moving, renaming, copying, or deleting files on the server. • reading, writ... Chapter 14: managing files on the server 221 code review html forms can be designed in most browsers to give users the ability to upload files. Setting the html input tag type to "file" instructs the browser to prepare to read and transmit a file from the user’s system to your server. Setting the en... 222 developing web applications with coldfusion 3. Change the following line to point to an appropriate location on your server: destination="c:\inetpub\wwwroot\hr\" 4. Save the file as uploadfileaction.Cfm in myapps under the web root directory. 5. View uploadfileform.Cfm in your browser, enter val... Chapter 14: managing files on the server 223 a file’s mime type is determined by the browser. Common types, like "image/gif" and "text/plain", are registered in your browser. Note not all browsers support mime type associations. Example: restricting file types this cffile specification will only sav... 224 developing web applications with coldfusion you enter permissions values in the mode attribute for each type of user: owner, group, other in that order. For example to assign read permissions for all: mode=444 to give a file or directory owner read/write/execute permissions and read only permiss... Chapter 14: managing files on the server 225 the following file upload status variables are available after an upload. File upload variables parameter description attemptedserverfile initial name coldfusion used attempting to save a file, for example, myfile.Txt . See " resolving conflicting file na... 226 developing web applications with coldfusion use the file prefix to refer to these variables, for example, #cffile.Fileexisted#. Note file status variables are read-only. They are set to the results of the most recent cffile operation. If two cffile tags execute, the results of the first are over... Chapter 14: managing files on the server 227 reading, writing, and appending to a text file in addition to managing files on the server, you can use cffile to read, create, and modify text files. This gives you the ability to • create log files. • generate static html documents. • use text files to ... 228 developing web applications with coldfusion to create a form in which to enter data for a text file: 1. Open a new file in studio. 2. Modify the file so that it appears a follows: enter you name: enter you the name of the file: name="filename" size="25"> enter your message: 3. Save the file as w... Chapter 14: managing files on the server 229 performing directory operations use the cfdirectory tag to return file information from a specified directory and to create, delete, and rename directories. As with cffile, coldfusion administrators can disable cfdirectory processing in the coldfusion adm... 230 developing web applications with coldfusion 3. Modify the line directory="c:\inetpub\wwwroot\mine" so that it points to a directory on your server. 4. Save the file as directoryinfo.Cfm and view it in your browser.. C h a p t e r 1 5 chapter 15 interacting with remote servers this chapter describes how coldfusion wraps the complexity of hypertext transfer protocol communications in a simplified tag syntax that allows you to easily extend your site’s offerings across the web. Contents • using cfhttp to interact ... 232 developing web applications with coldfusion using cfhttp to interact with the web the cfhttp tag is one of the more powerful tags in the cfml tag set. You can use one of two methods to interact with a remote server using the cfhttp tag: get or post. The get method is a one-way transaction in whi... Chapter 15: interacting with remote servers 233 code review to get a web page and save it in a file: 1. Open a new file in studio. 2. Modify the file so that it appears as follows: method = "get" url="http://www.Allaire.Com/index.Cfm" path="c:\mine" file="allaireindex.Cfm"> 3. Change the path from c... 234 developing web applications with coldfusion method="get" url="http://maximus/downloads/quakestuff/q2_test.Zip" path="c:\quake2\install" file="quake2beta.Zip"> #cfhttp.Mimetype# 3. Change the url to point to a binary file you want to download. 4. Change the path to point to a path on your hard dr... Chapter 15: interacting with remote servers 235 • when duplicate column heading names are encountered, coldfusion adds an underscore character to the duplicate column name to make it unique. For example, if two customerid columns are found, the second is renamed "customerid_". To create a query from... 236 developing web applications with coldfusion using the cfhttp post method use the post method to send cookie, form field, cgi, url, and file variables to a specified coldfusion page or cgi program. For post operations, you must use the cfhttpparam tag for each variable you want to post. Unlike th... Chapter 15: interacting with remote servers 237 you have posted to me. Nameconflict="overwrite" filefield="myfile" action="upload" attributes="normal"> the url variable is: #url.Myurl# the cookie variable is: #cookie.Mycookie6# the cgi variable is: #cgi.Mycgi#. The formfield variable is: #form.Myfor... 238 developing web applications with coldfusion this example runs a cgi program, search.Exe , that searches the site and returns the hits on the value specified in value. Using secure sockets layer (ssl) with cfhttp when using secure sockets layer (ssl) to transmit secured transactions via cfhttp, y... Chapter 15: interacting with remote servers 239 performing file operations with cfftp the cfftp tag allows you to perform tasks on remote servers via the file transfer protocol (ftp). Cfftp allows you to cache connections for batch file transfers. Note in order to use cfftp, make sure cfobject is en... 240 developing web applications with coldfusion text="date(format#lastmodified#)"> text="#isdirectory#"> 3. Change beta.Company.Com to the name of a server you have permission to ftp to. 4. Change betauser and monroe to a valid username and password. To establish an anonymous connection enter "anony... Chapter 15: interacting with remote servers 241 connection caching actions and attributes the following table shows which cfftp attributes are required for cfftp actions when employing connection caching. If connection caching is not used, the connection attributes username, password, and server mus... 242 developing web applications with coldfusion the best source of information about wddx is http://www.Wddx.Org/ . This site, sponsored by allaire corporation, offers a free download of the wddx sdk and a number of resources, including a wddx faq and a developer forum. An overview of distributed da... Chapter 15: interacting with remote servers 243 descriptors that allow the data to be manipulated on a target system between arbitrary application servers. Wddx is based on xml, which is a w3c recommendation. Other w3c efforts now in the works will have obvious application to wddx when they are comp... 244 developing web applications with coldfusion all of allaire’s wddx serializers (cfml, com, and js) have an attribute/property usetimezoneinfo that specifies whether time zone information should be used in the serialization process. The default value is true. In the cfml implementation, usetimezon... Chapter 15: interacting with remote servers 245 see the cfml language reference for more information on javascript objects. Converting cfml data to a javascript object the following example demonstrates the transfer of a cfquery result set from a cfml template executing on the server to a javascript... 246 developing web applications with coldfusion q.Dump(true); note to see how cfwddx action="cfml2js" works, view the source to the page. Transferring data from browser to server this example serializes form field data, posts it to the server, deserializes it, and outputs the data. For simplicity, o... Chapter 15: interacting with remote servers 247 name="personform"> personal information first name: last name: onclick="serializedata(personinfo, document.Personform.Wddxpacket)"> wddx packet display: /textarea> /textarea> server-side processing output="personinfo"> the submitted personal informatio... 248 developing web applications with coldfusion. C h a p t e r 1 6 chapter 16 connecting to ldap directories support for the lightweight directory access protocol (ldap) api in cfml is part of allaire’s commitment to open networking standards. Contents • what is ldap? ................................................................................... 250 developing web applications with coldfusion what is ldap? Ldap (lightweight directory access protocol) is a protocol that enables organizations to arrange directory information in a hierarchy. Note that in this case, "directory" refers to a collection of information something like a telephone di... Chapter 16: connecting to ldap directories 251 ldap attributes following is a list of the common attributes: key terms following is a brief description of the ldap information structure. Entry the basic information object of ldap is the entry. An entry is composed of attributes, each of which has a ... 252 developing web applications with coldfusion attribute is "ou=support, o=allaire" the level below "support" is searched. You can optionally restrict a query to the level of the start entry or extend it to the entire subtree. Referral while not supported directly in the ldap2 standard, the ability... Chapter 16: connecting to ldap directories 253 • build applications that incorporate data from directory queries in their processes. Working with ldap directories the cfldap tag allows you to work with ldap directories in the following ways. You can: • view the directory schema • search an ldap dire... 254 developing web applications with coldfusion attributes="dn, objectclasses, attributetypes" scope="base" filter="objectclass=*" start=#entrylist.Subschemasubentry# > dn=#dn# objectclasses: #objectclasses# attribute types: #attributetypes# 3. Change the server from testldap.Company.Com to a valid ... Chapter 16: connecting to ldap directories 255 although sophisticated search criteria can be constructed from these filter operators, performance may degrade if the ldap server is slow to process the synchronous search routines supported by cfldap. The timeout and maxrows attributes can be used to c... 256 developing web applications with coldfusion query="orglist" height=250 width=620 hspace=20 vspace="6"> header="organization" width=380> header="state" width=100> header="phone ##" width=150> query="orglist" height=250 width=620 hspace=20 vspace="6"> header="organization" width=380> header="state... Chapter 16: connecting to ldap directories 257 server="myserver" action="query" attributes="cn,mail,telephonenumber" scope="subtree" filter="ou=human resources" sort="cn asc" start="o=airius.Com"> human resources directory for arius server="myserver" action="query" attributes="cn,mail,telephonenumbe... 258 developing web applications with coldfusion action="modify" username="uid=kvaughan, ou=people, o=airius.Com" password="bribery" attributes="uniquemember=uid=scarter,,ou=people,,o=airius.Com, uid=tmorris,,ou=people,,o=airius.Com, id=gfarmer,,ou=people,,o=airius.Com" dn="cn=accounting managers, ou... Chapter 16: connecting to ldap directories 259 password="testldap" action="modifydn" attributes=#new_dn# dn=#rename_dn#> #phonetag# & #phone#> server="myserver" username="cn=directory manager, o=ace industry, c=us" password="testldap" action="modify" attributes=#update_attrs# dn=#dn#> person,organiz... 260 developing web applications with coldfusion server="myserver" action="query" attributes="dn,cn, sn" scope="subtree" sort="sn asc" filter="(&(sn=*ens*)(cn>=k))" start="o=ace industry, c=us" maxrows=50 timeout=30> server="myserver" action="query" attributes="dn,cn, sn" scope="subtree" sort="sn asc... Chapter 16: connecting to ldap directories 261 4. Change the uid to a valid user id. 5. Save the page as ldapchangeattr.Cfm and view it in your browser. To delete an entry: 1. Open a new file in studio. 2. Modify the file so that it appears as follows: server="myserver" username="cn=directory manage... 262 developing web applications with coldfusion. C h a p t e r 1 7 chapter 17 application security coldfusion 4.5 supports several levels of advanced security. This chapter teaches you how to deploy user security, which is controlled by the coldfusion developer and offers runtime security for coldfusion applications. It also describes the remote d... 264 developing web applications with coldfusion coldfusion security features coldfusion server professional and enterprise editions include advanced security features that provide scalable, granular security for building and deploying your coldfusion applications: • application development — system ... Chapter 17: application security 265 overview of user security user security authenticates users when they log into a coldfusion application, and then assigns privileges based on group membership or other criteria that you determine. For example, suppose you’ve used coldfusion to build and host your... 266 developing web applications with coldfusion • use the isauthenticated function to check if the current user is authenticated. • use the isauthorized function to check if the user is authorized to access resources. This function lets developers offer or deny access to protected resources based on... Chapter 17: application security 267 example username=#userid# password=#pwd#> if the user has not already been defined in the system, coldfusion throws a security exception. You can either reject access to the resource or re-route the user to a login page. For example, you can display a login form ... 268 developing web applications with coldfusion isauthorized returns true if the user is authorized to perform the specified action on the specified coldfusion resource. Isauthorized takes three parameters: isauthorized(resourcetype, resourcename, [resourceaction]) for example, to check whether the ... Chapter 17: application security 269 a new user. Username=#user# password=#pwd#> authentication error username=#user# password=#pwd#> you might place code here to define the user to the security context. ---> #cfcatch.Message# using the cfimpersonate tag cfimpersonate gives coldfusion developers a w... 270 developing web applications with coldfusion • username — the username of the user to impersonate. • password — the password of the user to impersonate. • type — indicates the type of impersonation to implement, application-level or operating-system-level. Application-level impersonation lets you... Chapter 17: application security 271 if a user passes the authentication test, coldfusion passes a cookie to carry the user’s authentication state to subsequent application pages governed by this application.Cfm page. • next, only authenticated users are able to access the requested application page... 272 developing web applications with coldfusion checking for authentication and authorization inside application pages, developers can use the isauthorized function to check whether an authenticated user is authorized to access the protected resources, and then display only the authorized resources.... Chapter 17: application security 273 example: orders.Cfm ... Insert into orders (customer, orderid) values (#customer#, #orderid#) authorization succeeded. Order information added: #customer# - #orderid# to update order information."> select * from orders authorization succeeded. Order information f... 274 developing web applications with coldfusion. C h a p t e r 1 8 chapter 18 building custom cfapi tags for some applications, building executables to run with coldfusion is the best solution. Perhaps the application requirements go beyond what is currently feasible in cfml. Or perhaps application performance can be improved for certain types of ... 276 developing web applications with coldfusion what are cfx tags? Cfx tags are custom tags written against the coldfusion application programming interface. Generally, you create a cfx if you want to do something that’s not possible in cfml, or if you want to improve performance of a task in cfml t... Chapter 18: building custom cfapi tags 277 using the tag wizard to create cfxs in c++ on windows nt, you can get a start in developing cfxs by using the coldfusion tag wizard. To use the wizard, the cfxapi tag development kit must be installed (it is by default), and the setup routine must detect mi... 278 developing web applications with coldfusion on unix solaris you can debug custom tags on unix using the dbx debugger. You should shut down coldfusion using the stop script. Set the environment variables, including ld_library_path and cfhome as they are set in the start script. You should then be... Chapter 18: building custom cfapi tags 279 • helloworldgraphic - generates a "hello world!" graphic in jpeg format. Demonstrates how to dynamically create and return graphics from a java cfx. Setting up your development environment to develop cfxs in java you can use a wide range of java development... 280 developing web applications with coldfusion to create a java cfx: 1. Create a new source file in your editor. 2. Enter the code, for example, the code below illustrates the creation of a very simple java cfx named simplejavacfx that writes a text string back to the calling page: import com.Allai... Chapter 18: building custom cfapi tags 281 request object passed to the processrequest method of the customtag interface. Provides methods for retrieving attributes passed to the tag, including queries, and reading global tag settings. Response object passed to the processrequest method of the custo... 282 developing web applications with coldfusion query object provides an interface for working with coldfusion queries, including methods for retrieving name, row count, and column names as well as methods for getting and setting data elements.. For detailed reference information on each of these in... Chapter 18: building custom cfapi tags 283 automatic class reloading you can determine how the server treats changed java cfx class files by using the reload (?) . The allowable values for the reload attribute are as follows:. The default value is reload=auto . This is appropriate for most applicati... 284 developing web applications with coldfusion your customtag object. If you wish to store data and/or objects that are accessible to all instances of your customtag you should use static data members. Calling the cfx from a coldfusion template you call java cfxs from within coldfusion templates by... Chapter 18: building custom cfapi tags 285 the java implementation of zipbrowser is as follows: import com.Allaire.Cfx.* ; import java.Util.Hashtable ; import java.Io.Fileinputstream ; import java.Util.Zip.* ; public class zipbrowser implements customtag { public void processrequest( request request... 286 developing web applications with coldfusion approaches to debugging java cfxs java cfxs are not standalone applications that run in their own process like typical java applications. Rather, they are created and invoked from an existing process — coldfusion server. This makes debugging java cfxs ... Chapter 18: building custom cfapi tags 287 • debugresponse — an implementation of the response interface that enables you to print the results of a request once it has completed. • debugquery — an implementation of the query interface that enables you to initialize a query with a name, columns, and ... 288 developing web applications with coldfusion debugquery query = new debugquery( "employees", columns, data ) ; // create tag, process debug request, and print results outputquery tag = new outputquery() ; debugrequest request = new debugrequest( attributes, query ) ; debugresponse response = new ... Chapter 18: building custom cfapi tags 289 debugquery // initialize a query with name and columns public debugquery( string name, string[] columns ) throws illegalargumentexception ; // initialize a query with name, columns, and data public debugquery( string name, string[] columns, string[][] data ... 290 developing web applications with coldfusion to register a c++ cfx: 1. In the cf administrator, open the extensions > cfx tags page. 2. Enter cfx_mynewtag in the tag name and, optionally, a description. 3. Select the type of tag (either c++ or java). 4. Click add to open the new cfx tag page. 5. ... Chapter 18: building custom cfapi tags 291 distribution if you are distributing a custom tag, you may want to automatically register the custom tag during the setup process by writing the registration entries directly into the registry. The location, key, and value names to write are as follows: you... 292 developing web applications with coldfusion to import a c++ custom tag: 1. Export the custom tag’s registry entry by using the regedit utility. This creates a file similar to the following: regedit4 [hkey_local_machine\software\allaire\coldfusion\currentversion\ customtags\cfx_test] "librarypath... Chapter 18: building custom cfapi tags 293 c++ cfx reference below is a listing of cfxapi classes and members. Individual members are described fully in the following sections. Class members ccfxexception class ccfxexception::geterror ccfxexception::getdiagnostics ccfxquery class ccfxquery::addrow c... 294 developing web applications with coldfusion ccfxexception class abstract class that represents an exception thrown during the processing of a coldfusion extension (cfx) procedure. Exceptions of this type can be thrown by ccfxrequest class , ccfxquery class , and ccfxstringset class . Your coldfu... Chapter 18: building custom cfapi tags 295 prequest->rethrowexception( e ) ; } // catch all other exceptions and throw them as // cold fusion exceptions (do not remove! -- // this prevents the server from crashing in // case of an unexpected exception) catch( ... ) { prequest->throwexception( "error... 296 developing web applications with coldfusion ccfxquery::addrow int ccfxquery::addrow(void) add a new row to the query. You should call this function each time you want to append a row to the query. Returns the index of the row that was appended to the query. Example the following example demonstr... Chapter 18: building custom cfapi tags 297 ccfxquery::getdata lpcstr ccfxquery::getdata(int irow , int icolumn ) retrieves a data element from a row and column of the query. Row and column indexes begin with 1. You can determine the number of rows in the query by calling ccfxquery::getrowcount . You... 298 developing web applications with coldfusion retrieves the number of rows in the query. Returns the number of rows contained in the query. Example the following example retrieves the number of rows in a query and writes it back to the user: ccfxquery* pquery = prequest->getquery() ; char buffoutp... Chapter 18: building custom cfapi tags 299 ccfxquery::setquerystring this is a deprecated function and should not be used. Ccfxquery::settotaltime this is a deprecated function and should not be used. Ccfxrequest class abstract class that represents a request made to a coldfusion extension (cfx). An... 300 developing web applications with coldfusion virtual void writedebug( lpcstr lpszoutput ) ccfxrequest::writedebug writes text output into the debug stream. Virtual ccfxstringset* createstringset() ccfxrequest::createstringset allocates and returns a new ccfxstringset instance. Virtual void throwe... Chapter 18: building custom cfapi tags 301 // create a query that contains these columns ccfxquery* pquery = prequest->addquery( "people", pcolumns ) ; // add data to the query int irow ; irow = pquery->addrow() ; pquery->setdata( irow, ifirstname, "john" ) ; pquery->setdata( irow, ilastname, "smith... 302 developing web applications with coldfusion ccfxrequest::debug bool ccfxrequest::debug(void) checks whether the tag contains the debug attribute. You should use this function to determine whether or not you need to write debug information for this request. (see the ccfxrequest::writedebug tag fo... Chapter 18: building custom cfapi tags 303 you are not responsible for freeing the memory allocated for the returned string set (it will be freed automatically by coldfusion after the request is completed). Example the following example retrieves the list of attributes and then iterates over the lis... 304 developing web applications with coldfusion (created using the cfquery tag or another custom tag). The query attribute is optional and should only be used by tags that need to process an existing data set. Returns an object of the ccfxquery class that represents the query that was passed to the ... Chapter 18: building custom cfapi tags 305 your extension code and then either re-throw them (if they are of the ccfxexception class ) or create and throw a new exception pointer using ccfxrequest::throwexception . E an existing ccfxexception that has been caught. Example the following code demonstr... 306 developing web applications with coldfusion void processtagrequest( ccfxrequest* prequest ) { try { mytagdata tagdata ; prequest->setcustomdata( (lpvoid)&tagdata ) ; ... Remainder of procedure ... } ccfxrequest::setvariable void ccfxrequest::setvariable(lpcstr lpszname, lpcstr lpszvalue) sets a ... Chapter 18: building custom cfapi tags 307 ccfxrequest::rethrowexception to provide protection against resource leaks in extension code. Lpszerror short identifier for error. Lpszdiagnostics error diagnostic information. Example the following example throws an exception indicating that an unexpected... 308 developing web applications with coldfusion example the following example checks to see whether the debug attribute is present, and if it is, it writes a brief debug message: if ( prequest->debug() ) { prequest->writedebug( "top secret debug info" ) ; } ccfxstringset class abstract class that re... Chapter 18: building custom cfapi tags 309 ccfxstringset::getcount int ccfxstringset::getcount(void) gets the number of strings contained in the string set. This value can be used along with ccfxstringset::getstring to iterate over the strings in the set (when iterating, remember that the index valu... 310 developing web applications with coldfusion ccfxstringset::getstring lpcstr ccfxstringset::getstring(int iindex) retrieves the string located at the passed index (note that index values are 1-based). Returns the string located at the passed index. Iindex index of string to retrieve. Example the ... Chapter 18: building custom cfapi tags 311 java cfx reference contents • interface customtag • interface query • interface request • interface response interface customtag public abstract interface customtag interface for implementing custom tags. Classes that implement this interface can be specifi... 312 developing web applications with coldfusion response — interface for generating response to request (output, variables, queries, etc.) throws: exception — if an unexpected error occurs while processing the request. Interface query public abstract interface query interface to a query used or crea... Chapter 18: building custom cfapi tags 313 returns: the name of the query. Getrowcount public int getrowcount() retrieves the number of rows in the query. The following example retrieves the number of rows in a query and writes it back to the user: query query = request.Getquery() ; int rows = query... 314 developing web applications with coldfusion retrieves a list of the column names contained in the query. The following example retrieves the array of columns and then iterates over the list, writing each column name back to the user: // get the list of columns from the query string[] columns = q... Chapter 18: building custom cfapi tags 315 throws: indexoutofboundsexception - if an invalid index is passed to the method. See also: setdata, addrow addrow public int addrow() adds a new row to the query. Call this method each time you want to append a row to the query. The following example demons... 316 developing web applications with coldfusion int icity = 1, istate = 2, izip = 3 ; // first row int irow = query.Addrow() ; query.Setdata( irow, icity, "minneapolis" ) ; query.Setdata( irow, istate, "mn" ) ; query.Setdata( irow, izip, "55345" ) ; // second row irow = query.Addrow() ; query.Setdat... Chapter 18: building custom cfapi tags 317 method detail attributeexists public boolean attributeexists(string name) checks to see whether the attribute was passed to this tag. The following example checks to see if the user passed an attribute named destination to the tag and throws an exception if... 318 developing web applications with coldfusion getattribute public string getattribute(string name) retrieves the value of the passed attribute. Returns an empty string if the attribute does not exist (use attributeexists to test whether an attribute was passed to the tag). Use getattribute(string,... Chapter 18: building custom cfapi tags 319 throws: numberformatexception — if the attribute is not a valid number. See also: attributeexists, getattributelist, getintattribute(string,int) getattributelist public string[] getattributelist() retrieves a list of all attributes passed to the tag. To ret... 320 developing web applications with coldfusion "order for this tag to work correctly." ) ; } returns: the query that was passed to the tag. If no query was passed to the tag then null is returned. Getsetting public string getsetting(string name) retrieves the value of a global custom tag setting. C... Chapter 18: building custom cfapi tags 321 returns: returns true if the tag contains the debug attribute otherwise returns false. See also: response.Writedebug interface response public abstract interface response interface to response generated from a customtag. This interface includes methods for ... 322 developing web applications with coldfusion sets a variable in the calling template. If the variable name specified already exists in the template then its value is replaced. If it does not already exist then a new variable is created. For example, this code sets the value of a variable named ’m... Chapter 18: building custom cfapi tags 323 query.Setdata( irow, ifirstname, "john" ) ; query.Setdata( irow, ilastname, "smith" ) ; irow = query.Addrow() ; query.Setdata( irow, ifirstname, "jane" ) ; query.Setdata( irow, ilastname, "doe" ) ; parameters: name — the name of the query to add to the temp... 324 developing web applications with coldfusion. C h a p t e r 1 9 chapter 19 using cfobject to invoke component objects the cfobject tag is used to invoke objects created by component technologies. This includes com/dcom, corba, java, and ejb objects. Contents • component object overview............................................................... 326 developing web applications with coldfusion component object overview this section gives you some basic information on objects supported in coldfusion and provides resources for further inquiry. About com com (component object model) is a specification and a set of services defined by microsoft ... Chapter 19: using cfobject to invoke component objects 327 invoking component objects the cfobject tag is used to create an instance of the object and other coldfusion tags, such as cfset and cfoutput, are used to invoke properties (attributes), and methods (operations) on the object. An object crea... 328 developing web applications with coldfusion calling nested objects the current release of coldfusion does not support nested (scoped) object calls. For example, if an object method returns another object and you would like to invoke a property/method on that object, the following is required: (t... Chapter 19: using cfobject to invoke component objects 329 deployed with their own setup programs that register objects automatically, while others may require manual registration. Inproc object servers (*.Dll, *.Ocx) can be registered manually by using the "regsvr32.Exe" utility using the following... 330 developing web applications with coldfusion to view an object’s properties: 1. Open the object viewer and scroll to the object you want to examine. 2. Select and expand the object in the object viewer. 3. Right-click the object to view it. If you view the typeinfo, you’ll see the object’s method... Chapter 19: using cfobject to invoke component objects 331 creating and using com objects in the following example, an smtp mail handling component is created using cfobject. Name=mailer class=smtp.Mailer> the component needs to be created by coldfusion before any methods in the component can be inv... 332 developing web applications with coldfusion • remote — this is also an out-of-process server object (also typically an exe) that is running remotely on the network. Using remote implies using the server attribute to identify where the object resides. Setting properties and invoking methods the f... Chapter 19: using cfobject to invoke component objects 333 • if visibroker is already installed on the server, the log directory is the directory pointed to by the vbroker_adm environment variable. • if this is a new visibroker installation, the log directory is created on the root of the drive from... 334 developing web applications with coldfusion { short s; long l; float d; }; struct nestedstruct { simplestruct f; char c; string s; }; typedef sequence blongsequence; interface someobject { short somemethod( in nestedstruct instruct, in blongsequence inseq); }; the applicable coldfusion code exce... Chapter 19: using cfobject to invoke component objects 335 calling java objects the cfobject tag can call any java class that’s available on the class path specified in the coldfusion administrator. For example: although this loads the class, it doesn’t create an instance object. Static methods and ... 336 developing web applications with coldfusion. C h a p t e r 2 0 chapter 20 extending coldfusion pages with cfml scripting coldfusion offers a server-side scripting language, cfscript, that provides coldfusion functionality in script syntax. This javascript-like language gives developers the same control flow, but without tags. This chapter desc... 338 developing web applications with coldfusion about cfscript the coldfusion server-side scripting language, cfscript, offers coldfusion functionality in script syntax. This javascript-like language offers the same control flow, but without tags. Cfscript regions are bounded by and . You can use co... Chapter 20: extending coldfusion pages with cfml scripting 339 • for • break • continue • for-in • switch-case for more information the following javascript references may be useful in understanding the concepts and control flow statements in cfscript: • netscape’s javascript guide • netscape’s java... 340 developing web applications with coldfusion for loop: for (init-expr ; test-expr ; final-expr) statement ; note that init-expr and final-expr can be one of the following: • a single assignment expression, for example, x=5 or loop=loop+1 • any coldfusion expression, for example, setvariable("a",a... Chapter 20: extending coldfusion pages with cfml scripting 341 do-while loop: do statement while (expr) ; // complete do-while loop on a single line a = arraynew(1); do {a[loop1] = loop1 + 5; loop1 = loop1 + 1;} while (loop1 lt 10); // multiline do-while loop a = arraynew(1); do { a[loop1] = loop1 +... 342 developing web applications with coldfusion continue: skip to next loop iteration for ( loop=1; loop lt 10; loop = loop+1) { if(a[loop]=0) continue; a[loop]=1; } break: break out of the current switch statement or loop for( ; ; ) { indx=indx+1; if(find("key",strings[indx],1)) break; } expression... Chapter 20: extending coldfusion pages with cfml scripting 343 • cfscript is case-insensitive. • all statements end in a semi-colon, and line breaks in your code are insignificant. • in cfscript, assignments are statements, not expressions. • some implicit objects are not available, such as window a... 344 developing web applications with coldfusion //‘testres' is a column in the "employees" query if( testres eq 1 ) result="positive"; else result="negative"; test for #name# is #result#.. C h a p t e r 2 1 chapter 21 accessing the windows nt registry the cfregistry tag gives you programmatic access to the windows registry. Contents • overview of registry access in coldfusion ................................................. 346 • getting registry values ................................. 346 developing web applications with coldfusion overview of registry access in coldfusion coldfusion includes the cfregistry tag, which allows you to get, set, and delete registry values. The registry is a database that windows uses to maintain hierarchical information about users, hardware, and sof... Chapter 21: accessing the windows nt registry 347 branch="hkey_local_machine\software\microsoft\java vm" type="any" name="regquery"> 2. Access the record set (this example uses the cftable tag): cfregistry action="getall" branch="hkey_local_machine\software\microsoft\java vm" type="any" name="regque... 348 developing web applications with coldfusion if the specified value does not exist, coldfusion creates it. If the value already exists, coldfusion updates the value data. To create a registry key: call the cfregistry tag with the set action, specifying the branch, the entry to set, specifying key... Index a accessing collections 181 action pages 34 active server pages 242 advanced security implementing 265 allaire xxiv contacting xxiv headquarters xxiv sales xxv technical support xxiv ancestor tags 77 and operator 23, 40 application framework, web custom error pages 93 application framwork 184 ... 350 developing web applications with coldfusion cfauthenticate tag 185, 266 example 270 syntax 266 using setcookie 266 cfcatch tag 95 cfcontent tag 239 cfdirectory tag 239 cfelse tag 42, 53 cfelseif tag 53 cferror page 93 cferror tag 185 cfexit tag 84, 185 cffile tag 220, 237 cfform tag 124 cfftp ta... Index 351 descendants 77 distributing 291 downloading 73 encrypting 86 executing 82 execution modes 83 installing 85 local 85 location of 73 managing 85 naming 73 nesting 77 parent 77 restricting access to 86 shared 85 using existing 73 d data converting to javascript object 245 exchanging 241 passi... 352 developing web applications with coldfusion cfform 124 form fields required 68 form variables in queries 35 naming 34 processing 34 referring to 34 testing 36 formatting data items 38 query results 38 forms 30 checkboxes 47 creating 55, 61 creating with cfform 124 deleting data 66 designing 34 d... Index 353 relational 173 score 177 searching 171 sql 23 or operator 23 order by clause 22 p parameters dynamic sql 53 parent tags 77 pattern matching 39 perl 242 pop 7 populating arrays 108 arrayset 108 cfloop 108 from queries 110 nested loops 109 populating collections 157 post method 232, 236 poun... 354 developing web applications with coldfusion application-level 184 shared data modifying 199 single quotes 21, 51 in form field values 49 using 21 slider bar controls 142 smtp 206 special characters searching 170 sql 2, 20, 21 clauses 22 dynamic 53, 56 dynamic parameters 53 insert statement 61 no...Page 147
Page 148
Page 149: Building Dynamic Forms
Page 150
Page 151
Page 152
Page 153
Page 154
Page 155
Page 156
Page 157
Page 158: Structuring Tree Controls
Page 159
Page 160: Embedding Urls In A Cftree
Page 161
Page 162
Page 163
Page 164
Page 165
Page 166
Page 167
Page 168: Building Text Entry Boxes
Page 169
Page 170: Embedding Java Applets
Page 171
Page 172
Page 173
Page 174
Page 175: Indexing and Searching Data
Page 176
Page 177: Supported File Types
Page 178
Page 179: Creating A Collection
Page 180
Page 181
Page 182
Page 183
Page 184
Page 185: Building A Search Interface
Page 186
Page 187
Page 188
Page 189
Page 191: Using Query Expressions
Page 192
Page 193
Page 194: Composing Search Expressions
Page 195
Page 196: Searching With Wildcards
Page 197: Operators And Modifiers
Page 198
Page 199
Page 200
Page 201
Page 202
Page 203
Page 204
Page 205
Page 206: Managing Collections
Page 207
Page 208
Page 209: Using The Application
Page 210
Page 211
Page 212
Page 213
Page 214
Page 215
Page 216
Page 217: Using Client Variables
Page 218
Page 219
Page 220: Using Session Variables
Page 221
Page 222: Using Application Variables
Page 223
Page 224
Page 225
Page 226: Cflock Examples
Page 227
Page 228
Page 229
Page 230
Page 231: Sending and Receiving Email
Page 232: Sending Email Messages
Page 233: Samples Uses Of Cfmail
Page 234
Page 235
Page 236
Page 237: Advanced Sending Options
Page 238
Page 239: Handling Pop Mail
Page 240
Page 241
Page 242
Page 243
Page 244
Page 245: Managing Files On The Server
Page 246: Using Cffile
Page 247
Page 248
Page 249
Page 250
Page 251
Page 252
Page 253
Page 254
Page 255
Page 256
Page 257
Page 258: Using The Cfhttp Get Method
Page 259
Page 260
Page 261
Page 262: Using The Cfhttp Post Method
Page 263
Page 264
Page 265
Page 266
Page 267: Wddx
Page 268: Wddx Components
Page 269
Page 270: How Wddx Works
Page 271
Page 272
Page 273
Page 274
Page 275
Page 276: What Is Ldap?
Page 277
Page 278
Page 279: Viewing The Directory Schema
Page 280: Querying An Ldap Directory
Page 281
Page 282: Updating An Ldap Directory
Page 283
Page 284
Page 285
Page 286
Page 287
Page 288
Page 289: Application Security
Page 290
Page 291: Overview of User Security
Page 292: Using The Cfauthenticate Tag
Page 293
Page 294
Page 295
Page 296
Page 297
Page 298
Page 299
Page 300
Page 301: Building Custom Cfapi Tags
Page 302: What Are Cfx Tags?
Page 303: Compiling C++ Cfxs
Page 304
Page 305: Writing A Java Cfx
Page 306
Page 307
Page 308
Page 309
Page 310: Zipbrowser Example
Page 311
Page 312
Page 313
Page 314
Page 315: Implementing C++ Cfx Tags
Page 316
Page 317
Page 318
Page 319: C++ Cfx Reference
Page 320: Ccfxexception Class
Page 321: Ccfxquery Class
Page 322
Page 323
Page 324
Page 325: Ccfxrequest Class
Page 326
Page 327
Page 328
Page 329
Page 330
Page 331
Page 332
Page 333
Page 334: Ccfxstringset Class
Page 335
Page 336
Page 337: Java Cfx Reference
Page 338: Interface Query
Page 339
Page 340
Page 341
Page 342: Interface Request
Page 343
Page 344
Page 345
Page 346
Page 347: Interface Response
Page 348
Page 349
Page 350
Page 351: Using Cfobject To Invoke
Page 352: Component Object Overview
Page 353: Invoking Component Objects
Page 354
Page 355
Page 356
Page 357
Page 358: Getting Started With Corba
Page 359: Calling A Corba Object
Page 360
Page 361: Calling Java Objects
Page 362
Page 363: Extending Coldfusion Pages
Page 364: About Cfscript
Page 365: The Cfscript Language
Page 366
Page 367
Page 368
Page 369
Page 370
Page 371: Accessing The Windows Nt
Page 372: Getting Registry Values
Page 373: Setting Registry Values
Page 374: Deleting Registry Values
Page 375: Index
Page 376
Page 377
Page 378
Page 379
Page 380