On 11/7/05, Ung, Seng <[EMAIL PROTECTED]> wrote:
> I am having a very tough time to understand what cfproperty does.
<cfproperty> does two things:
1. It describes public instance data in a CFC that is intended to be
the return type of a web service (or, in some cases, passed into a web
service).
Since CFML is essentially a typeless language, the <cfproperty> tag
provides information needed by the web service libraries to map
between a CFC and a strongly typed structure. Really this is just a
way to provide structs in CFML that have enough information associated
with them (metadata) to allow interaction with strongly typed web
services.
2. It adds to the metadata for a CFC
This can be useful for documentation purposes or tools that depend
on introspection however I don't advise building systems that perform
dynamic introspection (at runtime) since they often don't scale very
well.
In other words, most people actually won't need to use <cfproperty>.
If you're calling a web service that returns a strongly typed
structure containing two elements (C++ syntax):
struct Result {
double amount;
String currency;
}
The equivalent CFML code would be:
Result.cfc:
<cfcomponent>
<cfproperty name="amount" type="numeric"/>
<cfproperty name="currency" type="string"/>
</cfcomponent>
The returned object would be used like this:
<cfset result = ws.callMethod() />
<cfset amount = result.amount />
<cfset currency = result.currency />
(Caveat: all untested code off the top of my head - errors & omissions
excepted :)
--
Sean A Corfield -- http://corfield.org/
Got frameworks?
"If you're not annoying somebody, you're not really alive."
-- Margaret Atwood
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email to
[email protected] with the words 'unsubscribe cfcdev' as the subject of the
email.
CFCDev is run by CFCZone (www.cfczone.org) and supported by CFXHosting
(www.cfxhosting.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[email protected]