View comments | RSS feed

cfproperty

Description

Defines properties of a ColdFusion component (CFC). Used to create complex data types for web services. The attributes of this tag are exposed as component metadata and are subject to inheritance rules.

Category

Extensibility tags

Syntax

<cfproperty 
name="name"
type="type"
required="boolean"
default="default value"
displayname="descriptive name"
hint="extended description"
>

See also

cfargument, cfcomponent, cffunction, cfinvoke, cfinvokeargument, cfobject, cfreturn; Documenting CFCs in Building and Using ColdFusion Components in ColdFusion MX Developer's Guide

History

ColdFusion MX: Added this tag.

Attributes

Attribute

Req/Opt

Default Description

name

Required

 

A string; a property name. Must be a static value.

type

Optional

any

A string; identifies the property data type:

  • any
  • array
  • binary
  • boolean
  • date
  • guid: the argument must be a UUID or GUID of the form xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx where each x is a character representing a hexadecimal number (0-9A-F).
  • numeric
  • query
  • string
  • struct
  • uuid: The argument must be a ColdFusion UUID of the form xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxxxxxx where each x is a character representing a hexadecimal number (0-9A-F).
  • variableName: a string formatted according to ColdFusion variable naming conventions.
  • a component name: if the type attribute value is not one of the preceding items, ColdFusion treats it as the name of a ColdFusion component. When The function executes, it generates an error if the argument that is passed in is not a CFC with the specified name.

required

Optional

no

Whether the parameter is required:

  • yes
  • no

default

Optional

 

If no property value is set when the component is used for a web service, specifies a default value.

If this attribute is present, the required attribute must be set to "no" or not specified.

displayname

Optional

 

A value to be displayed when using introspection to show information about the CFC. The value appears in parentheses following the property name.

hint

Optional

 

Text to be displayed when using introspection to show information about the CFC. This attribute can be useful for describing the purpose of the parameter.

Usage

You must position cfproperty tags at the beginning of a component, above executable code and function definitions.

If a component is not used as a web service, The cfproperty only provides metadata information when the component is viewed using introspection; for example, by opening the CFC file directly in the browser. It does not define variables or set values that you can then use in your component.

For web services that you create in ColdFusion, the cfproperty tag defines complex variables used by the web service.

Example

The following code defines a component in the file address.cfc that contains properties that represent a street address:

<cfcomponent>
   <cfproperty name="Number" type="numeric">
   <cfproperty name="Street" type="string">
   <cfproperty name="City" type="string">
   <cfproperty name="State" type="string">
   <cfproperty name="Country" type="string">
</cfcomponent>

This component represents a complex data type that can be used in a component that is exported as a web service, such as the following:

<cfcomponent>
   <cffunction name="echoAddress" returnType="address" access="remote">
         <cfargument name="input" type="address">
         <cfreturn arguments.input>
   </cffunction>
</cfcomponent>

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | KnowledgeBase | Bug Reporting

Version 7

Comments


babas said on Sep 6, 2005 at 2:51 AM :
Shouldn't it be: <cfcomponent extends="address" in the second component?
In fact I never found clear explanation of the use of cfproperty... if someone can help.
webnina said on Jan 21, 2006 at 6:13 PM :
When type attribute in <cfargument> tag is not recognized type, the attribute is assumed to be the name of ColdFusion Component - this is quote from B.Forta book "Advanced Macromedia ColdFusion MX7 Application Development", page 796
So you describe your custom type using <cfproperty> tag(s) in separate component, name it YourCustomType.cfc and then refer to it in <cfargument> of different component as follows:
<cfargument name="YourName" type="YourCustomType" required="yes">

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/7/htmldocs/00000315.htm