Defines properties and their annotations for a ColdFusion component (CFC). The properties are used to create complex data types for web services, while the annotations are used to define Object Relational Model (ORM) for a CFC. The attributes of this tag are exposed as component metadata and are subject to inheritance rules.
Extensibility tags
<cfproperty
name="name"
default="default value"
displayname="descriptive name"
hint="extended description"
required="false|true"
serializable="true|false"
type="type" >
cfargument, cfcomponent, cffunction, cfinvoke, cfinvokeargument, cfobject, cfreturn; Documenting
CFCs in Building and
Using ColdFusion Components , Implicit
Get and Set Functions in the Developing ColdFusion Applications
ColdFusion
9: Added the serializable attribute.
ColdFusion MX: Added this tag.
Added attributes for defining Object Relational Model for the CFC.
Added implicit getters and setters. Added validate and validateparams attributes.
Attribute |
Req/Opt |
Default |
Description |
|---|---|---|---|
|
Required |
A string; a property name. Must be a static value. |
|
|
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 For ORM-specific usage of the default attribute, see ColdFusion ORM . |
|
|
Optional |
A value to be displayed when using introspection to show information about the CFC. The value appears in parentheses following the property name. |
|
|
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. |
|
|
Optional |
|
Whether the parameter is required:
|
|
Optional |
|
Specifies whether this property can be serialized.
If you set this value to |
|
Optional |
|
A string; identifies the property data type:
|
|
Optional |
For more information, see Validate and validateparams attributes. |
|
|
Optional |
||
|
For information about these attributes, see ColdFusion ORM . |
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
For information about these attributes, see ColdFusion ORM . |
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
For information about these attributes, see ColdFusion ORM . |
||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
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, <cfproperty> only
provides metadata information of the property. It does not define
variables or set values that you can use in your component. However,
it creates implicit setters and getters for the property in the
CFC depending on whether getter/setter attributes are enabled. For
details, see Implicit
Get and Set Functions in Developing ColdFusion Applications.
For
Object Relational Model (ORM), cfproperty is used
to define relational mapping for the property of the CFC. For details,
see ColdFusion
ORM in Developing ColdFusion Applications.
For
web services that you create in ColdFusion, the cfproperty tag
defines complex variables used by the web service.
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>