View comments | RSS feed
Contents > CFML Reference > ColdFusion Tags > cfproperty PreviousNext

cfproperty

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.

Extensibility tags

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

cfargument, cfcomponent, cffunction, cfinvoke, cfinvokeargument, cfobject, cfreturn

ColdFusion MX: Added this tag.

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.

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 compoenent.

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 represnts 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>

Contents > CFML Reference > ColdFusion Tags > cfproperty PreviousNext

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

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


digitalcreationz said on Feb 13, 2004 at 4:55 PM :
Remove the #'s.

Another MM example that shows how _not_ to code.
Didgiman said on May 4, 2004 at 7:07 AM :
Can anyone tell me how to present the following array in a WSDL? With or without using cfproperty.

myArray[1].type = "type1";
myArray[1].id = "1";
myArray[1].value = "value 1";

myArray[2].type = "type2";
myArray[2].id = "2";
myArray[2].value = "value 3";

etc...
ASandstrom said on May 4, 2004 at 7:40 AM :
LiveDocs does not receive enough traffic to handle questions such as this. I suggest posting your issue to the online forums:
http://webforums.macromedia.com/coldfusion/
CF_NEWBIE said on Jun 2, 2004 at 11:58 PM :
Clarification please. The doc said that I could specify a default value which should conform to the var type. What I'm trying to do is define a cfc property of an array or struct type which are not required. Thus the line look like:

<cfproperty name="cfcArr" type="array" required="no" default="#arrayNew(1)#">


<cfproperty name="cfcStruct" type="struct" required="no" default="#structNew()#">

However, I encounter errors on both cases. With regards to the array, I just receive a "7" as the error message while with regards to the structure I receive: " Complex object types cannot be converted to simple values." The workaround is to define the properties in a <cfscript> as this.cfcStruct = structNew() and this.cfcArr = arrayNew(1) but I thought I should post this here in case someone else is wracking their head over this :D
halL said on Jun 3, 2004 at 2:28 PM :
We have submitted bug report 55758 agains the behavior described by CF_NEWBIE.
LoGalvatron said on Aug 3, 2004 at 1:16 PM :
"This component represnts a complex data type that can ..."

typo
yummy-rutabaga said on Dec 6, 2004 at 1:35 PM :
Whats the difference between <cfproperty> and defining variables in the This scope?
jrunrandy said on Dec 7, 2004 at 6:50 AM :
I think the main difference is that the ones you defin
with cfproperty are exposed in the web service.

 

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

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/tags-b18.htm