Well, here you go then =) I wrote up this quick cfc to illustrate it. It
has some instancevars, one instance of single composition, and one instance
of multiple composition.
Barney, any chance you could look this over as it relates to your post?
Thanks,
Justin
<cfcomponent displayname="I am the main object">
<cfset variables.instance = StructNew()/>
<cfset variables.instance.multipleObjectStruct = StructNew()/>
<cffunction name="init" access="public" returntype="void">
<cfargument name="childObject" required="yes"
type="childObj"/>
<cfset setMyProperty("parentObject")/>
<cfset setMyChildObject(arguments.childObject)/>
</CFFUNCTION>
<cffunction access="public" returntype="void" name="setMyProperty">
<cfargument name="myProperty" required="yes" type="string">
<cfset variables.instance.myProperty = arguments.myProperty
/>
</cffunction>
<cffunction name="getMyProperty" returntype="string"
access="public">
<cfreturn variables.instance.myProperty/>
</cffunction>
<cffunction name="setMyChildObject" access="package" output="No"
returntype="void">
<cfargument name="myChildObject" type="childObj"
required="Yes"/>
<cfset variables.instance.childObject =
arguments.myChildObject />
</cffunction>
<cffunction name="getMyChildObject" access="public"
returntype="childObj">
<cfreturn variables.instance.childObject/>
</cffunction>
<!-----Here are the multiple object functions---->
<!-----I might call setMultipleOBject function and pass in the
individual objects
I want it to be composed of (i.e. addresses and such). I use this
method to validate
the type of object coming in etc. Then I call the
setMultipleObjectStruct() that adds the
object to the structure. ------>
<cffunction name="setMultipleObject" access="public"
returntype="void">
<cfargument name="multipleObject" required="yes"
type="multipleObj"/>
<cfset setMultipleObjectStruct(arguments.multipleObject)/>
</cffunction>
<cffunction name="setMultipleObjectStruct" access="private"
returntype="void">
<cfargument name="multipleObject" type="multipleObj"
required="yes"/>
<cfset var objCount = "" />
<cfset objCount =
StructCount(variables.instance.multipleObjectStruct)/>
<cfset
StructInsert(variables.instance.multipleObjectStruct,objCount,arguments.mult
ipleObject)/>
</cffunction>
<cffunction name="getMultipleObjectStruct" access="public"
returntype="struct">
<cfreturn variables.instance.multipleObjectStruct/>
</cffunction>
</cfcomponent>
-----Original Message-----
From: Aldo d'Aquino [mailto:[EMAIL PROTECTED]
Sent: Friday, October 03, 2003 1:09 PM
To: [EMAIL PROTECTED]
Subject: Re: [CFCDev] Multiplicity
I use an array or a struct to hold multiple instance variables values.
I will apreciate any more information.
Thanks,
Aldo d'Aquino.
----- Original Message -----
From: "Justin Balog" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, October 03, 2003 3:46 PM
Subject: [CFCDev] Multiplicity
>
>
> Howdy,
>
> I am curious how folks out there are handling multiplicity in their cfcs.
> Lets say I have a person cfc. A person can have multiple addresses (for
> arguments sake lets just say there are addresses, not home address, work
> address, etc.). How would you handle a cfc instance var being composed of
> multiple cfcs? Right now I would add a new struct key to a
> variables.instance.addressStruct each time an address is set in the person
> cfc? I will bet there is a much better way to do it =) Let me know if
you
> need any more information.
>
> Thanks,
>
> Justin
> ----------------------------------------------------------
> You are subscribed to cfcdev. To unsubscribe, send an email
> to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
> in the message of the email.
>
> CFCDev is run by CFCZone (www.cfczone.org) and supported
> by Mindtool, Corporation (www.mindtool.com).
>
> An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
>
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at
www.mail-archive.com/[EMAIL PROTECTED]
----------------------------------------------------------
You are subscribed to cfcdev. To unsubscribe, send an email
to [EMAIL PROTECTED] with the word 'unsubscribe cfcdev'
in the message of the email.
CFCDev is run by CFCZone (www.cfczone.org) and supported
by Mindtool, Corporation (www.mindtool.com).
An archive of the CFCDev list is available at www.mail-archive.com/[EMAIL PROTECTED]