ColdFusion 9.0 Resources |
GetMetaDataDescriptionGets metadata (such as the methods, properties, and parameters of a component) associated with an object that is deployed on the ColdFusion server. ReturnsStructured metadata information: for ColdFusion components (CFCs) and user-defined functions (UDFs), a structure; for query objects, an array of structures. HistoryColdFusion MX 7: Added support for getting query object metadata. ColdFusion MX: Added this function. Parameters
UsageThis 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 are not part of CFCs. Use the GetComponentMetaData function to get information about ColdFusion interfaces, or about CFC definitions that you have not instantiated. The following table lists the data returned by the function for supported object 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 the Developing ColdFusion Applications. ExampleThe 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> |