|
Using introspection to get information about components
ColdFusion
provides several ways for you to get information about components:
Request a component page from the browser
Use the ColdFusion component browser
Use the Adobe® Dreamweaver® Components panel
Use the GetMetaData function
Development teams can use the information about components as
up-to-date API reference information.
Note: For information about how to include documentation
in CFCs for display by using introspection, see Documenting CFCs.
Requesting a component page from the browserWhen you access a CFC directly
with a web browser without specifying a component method, the following
chain of events occurs:
The request is redirected to the cfcexplorer.cfc file,
which is located in the cf_root/wwwroot/CFIDE/componentutils
directory.
The cfcexplorer component prompts users for the ColdFusion
RDS or Administrator password, if necessary.
The cfcexplorer component renders an HTML description and
returns it to the browser.
Using the ColdFusion component browserYou can also browse the components available
in ColdFusion using the component browser, which is located at cf_root/wwwroot/CFIDE/componentutils/componentdoc.cfm.
The browser has three panes:
The upper-left pane lists all CFC packages that ColdFusion
can access, and has all components and refresh links.
The lower-left pane lists CFC component names. When the browser
first appears, or when you click the all components link in the
upper pane, the lower pane lists all available components. If you
click a package name in the upper left pane, the lower pane lists
only the components in the package.
The right pane initially lists the paths of all components.
When you click a component name in the lower-left pane, the right
pane shows the ColdFusion introspection page, as described in Requesting a component page from the browser.
Note: When RDS user names are enabled, the component
browser accepts the root administrator user (admin) with either
the administrator or RDS single password.
Using the Dreamweaver Components panelThe
Dreamweaver Components panel lists all available components, including their
methods, method parameters, and properties. The panel’s context
menu includes options to create a component, edit the selected component,
insert code to invoke the component, or show detailed information
on the component or component element. The Get description option
shows the ColdFusion introspection page, as described in Requesting a component page from the browser. For more information on
viewing and editing CFCs in Dreamweaver, see the Dreamweaver online
Help.
Using the GetMetaData functionThe CFML GetMetaData function returns a structure
that contains all the metadata of a CFC instance. This structure
contains substantially more data about the CFC than the cfdump tag shows, and includes the
following information:
All attributes to the component tag, including any metadata-only
attributes, plus the component path.
An array of structures that contains complete information
on each method (function) in the component. This information describes
all attributes, including metadata-only function and parameter attributes.
Within each function structure, a Parameters element that
contains an array of parameters specified by cfargument tags. Information on each
parameter includes any metadata-only attributes.
Information about any properties that are specified using
the cfproperty tag.
Display metadata for a CFCCreate the tellAboutCfcs.cfm file in the same directory
as the telltime.cfc file, with the following code:
<!--- Create an instance of the component. --->
<cfobject component="tellTime" name="tellTimeObj">
<!--- Create a structure. --->
<cfset aboutcfc=structNew()>
<!--- Populate the structure with the metadata for the
tellTimeObj instance of the tellTime CFC. --->
<cfset aboutcfc=GetMetaData(tellTimeObj)>
<cfdump var="aboutcfc">
View the tellAboutCfcs.cfm file in a browser.
For information on how to specify CFC metadata, including how
to use component tags and how to specify metadata-only attributes,
see Documenting CFCs.
|