Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Platinum Edition Using HTML 4, XML, and Java 1.2
(Publisher: Macmillan Computer Publishing)
Author(s): Eric Ladd
ISBN: 078971759x
Publication Date: 11/01/98

Bookmark It

Search this book:
 
Previous Table of Contents Next


  <CFLOCATION><CFLOCATION> enables you to put redirects into your applications. It takes the URL attribute, which is set equal to the URL of the page where you want to redirect your users. You might do some queries to insert some information into one of your data sources, for example, and redirect the user back to the main page of your site with the following code:
<CFQUERY DATASOURCE=“info” NAME=“add”.
INSERT
INTO Transactions (Item_number,quantity)
VALUES (‘#Form.item_number#’, #Form.quantity#)
</CFQUERY>
...
<CFLOCATION URL=“index.cfm”>
  <CFCOOKIE>—If you need to write a cookie to a user’s browser, you can do so easily with the <CFCOOKIE> tag. <CFCOOKIE> has two required attributes: NAME, which is set equal to the name of the cookie, and VALUE, which is set equal to the cookie’s value. Additionally, you can use the EXPIRES attribute to specify the cookie’s expiration date and the SECURE attribute to require secure transmission of the cookie. For example:
<CFCOOKIE NAME=“ID” VALUE=“#User_ID#” EXPIRES=“01/01/99” SECURE=“YES”>

You can also specify the domain for which the cookie is valid with the DOMAIN attribute and the paths on the server to which the cookie applies with the PATH attribute.
  <CFTRANSACTION>—Data integrity is important on transaction-oriented databases where several users might be accessing the database at any given time. Suppose you have the following three queries that insert a new record in the Contact_Info table, query the Contact_Info table for the primary key of the record that was just inserted, and then insert that primary key value into the Orders table, respectively:
<CFQUERY DATASOURCE=“store” NAME=“InsertInfo”>
INSERT
INTO Contact_Info (name,address,city,state,zip,phone)
VALUES (‘#Form.name#’,‘#Form.address#’,‘#Form.city#’,‘#Form.state#’,
‘#Form.zip#’, ‘#Form.phone#’)
</CFQUERY>

<CFQUERY DATASOURCE=“store” NAME=“GetPrimaryKey”>
SELECT MAX(Customer_ID) as pk
FROM Contact_Info
</CFQUERY>

<CFQUERY DATASOURCE=“store” NAME=“InsertPrimaryKey”>
INSERT
INTO Orders (Customer)
VALUE (#GetPrimaryKey.pk#)
</CFQUERY>

These queries will work just fine, so long as no other queries are processed between them. Suppose, for example, that immediately after the contact information for customer A is inserted, contact information for customer B is also inserted. Then, when ColdFusion goes to query the database for customer A’s primary key, it will really get customer B’s primary key and customer B will then be associated with customer A’s order in the Orders table. This creates the potential for erroneous orders throughout your entire electronic commerce application and sows the seeds for some pretty unhappy customers.
Fortunately, you can eliminate the potential by wrapping queries that should occur together in <CFTRANSACTION> and </CFTRANSACTION> tags. Queries grouped this way are treated as a single entity, and ColdFusion will not attempt any other queries until those in the <CFTRANSACTION> have finished.
  <CFFORM>—CFML has some souped-up versions of the HTML form tags that enable you to automatically build JavaScript into your pages that will enable you to check for required fields and for appropriate formatting of input items such as phone numbers and zip codes. To use these tags, you have to use <CFFORM> and </CFFORM> tags where you would normally use <FORM> and </FORM> tags. After you’ve declared your intention to build a ColdFusion form, you can use tags such as <CFINPUT> for text fields, <CFSELECT> for drop-down lists, <CFSLIDER> for a Java-based slider control, <CFTREE> for a Java-based tree control, and <CFGRID> for a Java-based spreadsheet-like control.
The automated JavaScript comes into play when you use attributes such as REQUIRED or VALIDATE in the CFML form tags. For example, the tag
<CFINPUT TYPE=“TEXT” NAME=“fax” REQUIRED=“YES” VALIDATE=“telephone”>

sets up a text input field rigged with JavaScript that checks to make sure the user entered a value into the field (REQUIRED=“YES”) and that what was entered is in a telephone number format (VALIDATE=“telephone”).

Of all the available CFML tags, you have read about slightly more than one-third of them here. But these should be enough to get you started with ColdFusion application development. Remember that the online documentation that comes with ColdFusion and ColdFusion Studio contains full documentation on all the CFML tags in the event that you need to look up one of them.

CFML Functions

If you thought 51 was a lot of CFML tags, you’ll be overwhelmed by the number of CFML functions—178 of them! Although that may seem like a huge number of new things to learn, you should make your best effort to get as familiar with as many of the CFML functions as you can. By using the built-in functions, you can accomplish critical tasks quickly and efficiently instead of trying to write your own tags to do the same work (which is almost always less efficient).

In reading about CFML tags, you were introduced to a few of the CFML functions as well. This section reviews several more of the key CFML functions. To help you understand them a little better, they are grouped as follows:

  String functions
  Formatting functions
  Array functions
  List functions
  Date and time functions
  Math functions
  Query functions
  Two other useful functions: IsDefined and URLEncodedFormat

As you read about these functions, try to focus on developing an awareness of the functions and what they do. You can always look up the details of the syntax later.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.