
484
DEVELOPING
COLDFUSION 9 APPLICATIONS
Accessing and Using Data
Las
t
upda
te
d 8/5/2010
2
Save the file as collection_create_form.cfm in the myapps directory under the web root directory.
Note:
The form does not work until you write an action page for it, which is the next procedure.
Create a collection action page
1
Create a ColdFusion page with the following content:
<html>
<head>
<title>cfcollection</title>
</head>
<body>
<h2>Collection creation</h2>
<cfoutput>
<cfswitch expression=#Form.collectionaction#>
<cfcase value="Create">
<cfcollection action="Create"
collection="#Form.CollectionName#"
path="c:\CFusion\verity\collections\">
<p>The collection #Form.CollectionName# is created.</p>
</cfcase>
<cfcase value="Optimize">
<cfcollection action="Optimize"
collection="#Form.CollectionName#">
<p>The collection #Form.CollectionName# is optimized.</p>
</cfcase>
<cfcase value="Delete">
<cfcollection action="Delete"
collection="#Form.CollectionName#">
<p>The collection is deleted.</p>
</cfcase>
</cfswitch>
</cfoutput>
</body>
</html>
2
Save the file as collection_create_action.cfm in the myapps directory under the web root directory.
3
In the web browser, enter the following URL to display the form page:
http://hostname:portnumber/myapps/collection_create_form.cfm
4
Enter a collection name; for example, CodeColl.
5
Verify that Create is selected and submit the form.
6
(Optional) In the ColdFusion Administrator, reload the ColdFusion Collections page.
The name and full path of the new collection appear in the list of Verity Collections.
You successfully created a collection, named CodeColl, that currently has no data.