Adobe COLDFUSION 9 Manual page 1052

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
Working with Documents, Charts, and Reports
The following code creates a simple login page in ColdFusion. The form uses artist's last name as the user ID. (The
code does not include password verification):
<h3>Artist Login Form</h3>
<p>Please enter your last name and password.</p>
<cfform name="loginform" action="artSalesReport.cfm" method="post">
<table>
<tr>
<td>Last Name:</td>
<td><cfinput type="text" name="username" required="yes" message="A username is
required."></td>
</tr>
<tr>
<td>Password:</td>
<td><cfinput type="password" name="password" required="yes" message="A password is
required."></td>
</tr>
</table>
<br />
<cfinput type="submit" name="submit" value="Submit">
</cfform>
On the processing page, add a query like the one you created in the Report Builder report. The ColdFusion query must
contain at least all of the columns included in the Report Builder query; however, the ColdFusion query can contain
additional data.
The query in the following example selects all of the data from the ART and ARTISTS tables based on the artist's last
name. The
tag uses the pathname of the CFR file as the report template.
cfreport
<cfquery name="artsales" datasource="cfartgallery">
SELECT *
FROMAPP.ART, APP.ARTISTS
WHERE APP.ART.ARTISTID = APP.ARTISTS.ARTISTID
AND APP.ARTISTS.LASTNAME= <cfqueryparam value="#FORM.username#">
ORDER BY ARTISTS.LASTNAME
</cfquery>
<cfreport query="#artsales#" template="ArtSalesReport1.cfr" format="RTF"/>
ColdFusion displays the report for the artist in RTF format. Notice that the value of the
Default Output format defined in the CFR file.
Exporting the report in HTML
To generate a report in HTML and display it directly in the browser, change the format attribute to HTML:
<cfreport template="ArtSalesReport1.cfr" format="HTML"/>
ColdFusion automatically generates a temporary directory where it stores all of the image files in the report (charts are
saved as PNG files). The location of the temporary directory is:
C:\ColdFusion9\tmpCache\CFFileServlet\_cfreport\_report[unique_identifier]
You can specify when the temporary directory is removed from the server by using the
a value for the
resourceTimespan
<cfreport query="#artsales#" template="ArtSalesReport1.cfr" format="HTML"
resourceTimespan="#CreateTimeSpan(0,1,0,0)#"/>
attribute:
Last updated 8/5/2010
attribute overrides the
format
function as
CreateTimeSpan
1047

Advertisement

Table of Contents
loading

Table of Contents