
227
DEVELOPING
COLDFUSION 9 APPLICATIONS
Building Blocks of ColdFusion Applications
Las
t
upda
te
d 8/5/2010
You can now call the tag from a ColdFusion page.
Call a CFX tag from a ColdFusion page
1
Create a ColdFusion page (.cfm) in your editor with the following content to call the HelloColdFusion custom tag:
<html>
<body>
<cfx_MyHelloColdFusion NAME="Les">
</body>
</html>
2
Save the file in a directory configured to serve ColdFusion pages. For example, you can save the file as
C:\inetpub\wwwroot\cfdocs\testjavacfx.cfm in Windows or /home/docroot/cfdocs/testjavacfx.cfm in UNIX.
3
If you have not already done so, register the CFX tag in the ColdFusion Administrator (see “
Registering CFX tags
”
on page 234).
4
Request the page from your browser using the appropriate URL; for example:
http://localhost/cfdocs/testjavacfx.cfm
ColdFusion processes the page and returns a page that displays the text “Hello, Les.” If an error is returned instead,
check the source code to make sure that you entered it correctly.
Delete a CFX tag in the ColdFusion Administrator
1
In the ColdFusion Administrator, select Extensions > CFX Tags.
2
For the tag to delete, click the Delete icon in the Controls column of the Registered CFX Tags list.
Processing requests
Implementing a Java CFX tag requires interaction with the
Request
and
Response
objects passed to the
processRequest
method. In addition, CFX tags that must work with ColdFusion queries also interface with the
Query
object. The
com.allaire.cfx
package, located in the WEB-INF/lib/cfx.jar archive, contains the
Request
,
Response
, and
Query
objects.
For a complete description of these object types, see ColdFusion Java CFX Reference in the
CFML Reference
. For a
complete example Java CFX tag that uses
Request
,
Response
, and
Query
objects, see “
ZipBrowser example
” on
page 228.
Request object
The
Request
object is passed to the
processRequest
method of the
CustomTag
interface. The following table lists the
methods of the
Request
object for retrieving attributes, including queries, passed to the tag and for reading global tag
settings:
Method
Description
attributeExists
Checks whether the attribute was passed to this tag.
debug
Checks whether the tag contains the
debug
attribute.
getAttribute
Retrieves the value of the passed attribute.
getAttributeList
Retrieves a list of all attributes passed to the tag.