Gets metadata (such as the methods, properties, and parameters of a component) associated with an object that is deployed on the ColdFusion server.
Structured metadata information: for ColdFusion components (CFCs) and user defined functions (UDFs), a structure; for query objects, an array of structures.
GetMetaData
(object)
CreateObject, QueryAddColumn, QueryNew
ColdFusion MX 7: Added support for getting query object metadata.
ColdFusion MX: Added this function.
Parameter | Description |
---|---|
object |
A ColdFusion component, user-defined function, or query object. |
This function provides information about application data, and lets applications dynamically determine the structure of an object and how to use it. This function is useful for CFCs and query objects. The metadata for a CFC includes information on the component and its functions, arguments, and properties. The getMetaData
function also returns metadata for user-defined functions that not part of CFCs.
The following table lists the data returned by the function for supported object types:
Object | Field | Description |
---|---|---|
Component |
A structure containing the following fields: |
|
|
displayname |
Value of the |
extends |
Metadata for the component's ancestor component. Components that do not explicitly extend another component extend the WEB-INF.cftags.component. |
|
functions |
Array of metadata structures for the component's functions. |
|
hint |
Value of the |
|
name |
Component name, including the period-delimited path from a component search root such as the web root or a directory specified in the administrator Custom Tag Paths page. |
|
output |
Value of the |
|
path |
Absolute path to the component. |
|
properties |
Array of structures containing metadata specified by the component's |
|
type |
Always, component. |
|
userMetadata |
User-specified attributes in the |
|
Function |
A structure containing the following fields. |
|
|
access |
Value of the |
displayname |
Value of the |
|
hint |
Value of the |
|
name |
Function name. |
|
output |
Value of the |
|
parameters |
Array of structures containing metadata for the function parameters. |
|
returntype |
Value of the |
|
roles |
Value of the |
|
userMetadata |
User-specified attributes in the |
|
Parameter or Property |
A structure containing the following fields: |
|
|
default |
Value of the |
displayname |
Value of the |
|
hint |
Value of the |
|
name |
Function parameter or CFC propery name. |
|
required |
Value of the |
|
type |
Value of the |
|
userMetadata |
User-specified attributes in the |
|
Query |
An array of structures containing the following elements: |
|
|
IsCaseSensitive |
Boolean value indicating whether character data must be case correct. |
Name |
The column name. |
|
TypeName |
The SQL data type (Omitted if the query object is created with QueryNew without specifying types.) |
Note: Use the This scope to access component metadata inside the CFC. The This scope is available at runtime in the component body and in the CFC methods. It is used to read and write variables that are present during the life of the component.
For more information, see Using introspection to get information about components in Building and Using ColdFusion Components in ColdFusion MX Developer's Guide.
The following example uses the cfdump
tag to display metadata for the utilities CFC that is used by the ColdFusion component browser. It also displays the names and data types of the fields in the cfdocexamples database Employees table.
<!--- Create an instance of the Component Explorer utilities CFC. and get its metadata ---> <cfscript> componentutils = createObject("component", "cfide.componentutils.utils"); utilmetadata = getMetaData(componentutils); </cfscript> <h4>Metadata for the CFC component utilities</h4> <cfdump var="#utilmetadata#"> <!--- use GetMetadata to get the names and data types of the fields in the
cfdocexamples Employees table ---> <cfquery name="getemployees" datasource="cfdocexamples"> SELECT * FROM Employees </cfquery> <cfset employeemeta=getMetaData(getemployees)> <h4>The Employees table has the following columns</h4> <cfloop index="i" from="1" to="#arrayLen(employeemeta)#"> <cfoutput> #employeemeta[i].name# #employeemeta[i].TypeName# #employeemeta[i].isCaseSensitive#<br> </cfoutput> </cfloop>