Yep, this is another way to go about doing things--lots of people put some way of returning a snapshot/instance in their beans so you might be able to use this approach depending on what you're really trying to accomplish.
Matt On Apr 11, 2005 1:10 PM, Knipp, Eric <[EMAIL PROTECTED]> wrote: > > I'm not Matt but I will explain if I can .. > > A getter is just a method. so getSomeArray() can return anything, including > an array. This means you should be able to do: > > <cfset myArray = object.getArray() /> > <cfoutput>#myArray[1]#</cfoutput> > > without any problem. > > Having said that, you may be looking for a collection object instead. > Collections have an item(index) method which will let you specify a specific > index and retrieve only that member of the collection. In CF, the best way > to implement collections are with an array, but you don't have to worry > about that as a consumer of the collection. > > I have some generic collection code I wrote that I can paste you if you > like. In the meantime here is a sample component that does nothing special > but may help you understand what I am talking about: > > <cfcomponent displayname="arraytest"> > <cfset variables.instance = StructNew() /> > <cfset variables.instance.theArray = ArrayNew(1) /> > > <cffunction name="init" access="public" returntype="arraytest"> > <cfreturn this /> > </cffunction> > > <cffunction name="dumpSnapShot" access="public" returntype="void"> > <cfdump var="#variables.instance#" /> > </cffunction> > > <cffunction name="setArray" access="public" returntype="void"> > <cfargument name="theArray" type="array" required="yes"> > <cfset variables.instance.theArray = Duplicate(theArray) /> > </cffunction> > <cffunction name="getArray" access="public" returntype="array"> > <cfreturn Duplicate(variables.instance.theArray) /> > </cffunction> > </cfcomponent> > > Thanks, > > Eric > > -----Original Message----- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] > Behalf Of Daniel Elmore > Sent: Monday, April 11, 2005 12:58 PM > To: [email protected] > Subject: CFC Bean Getter > > Calling Matt Woodward... > > If a getter() returns an array, how do you access a position in that array > in the same line of execution? > > <cfreturn getSomeArray()/> and I want to return the 1st cell only. > > Am I breaking bean rules? Can a getter not return an array? > > Thanks! > > ---------------------------------------------------------- > To post, send email to [email protected] > To unsubscribe: > http://www.dfwcfug.org/form_MemberUnsubscribe.cfm > To subscribe: > http://www.dfwcfug.org/form_MemberRegistration.cfm > > ----------------------------------------- > CONFIDENTIALITY NOTICE: The information contained in this e-mail and > attached document(s) may contain confidential information that is intended > only for the addressee(s). If you are not the intended recipient, you are > hereby advised that any disclosure, copying, distribution or the taking of > any action in reliance upon the information is prohibited. If you have > received this e-mail in error, please immediately notify the sender and > delete it from your system. > > ---------------------------------------------------------- > To post, send email to [email protected] > To unsubscribe: > http://www.dfwcfug.org/form_MemberUnsubscribe.cfm > To subscribe: > http://www.dfwcfug.org/form_MemberRegistration.cfm > > -- Matt Woodward [EMAIL PROTECTED] http://www.mattwoodward.com ---------------------------------------------------------- To post, send email to [email protected] To unsubscribe: http://www.dfwcfug.org/form_MemberUnsubscribe.cfm To subscribe: http://www.dfwcfug.org/form_MemberRegistration.cfm
