Hi Phillip, You might want to check out "Iterating Business Objects"
http://www.pbell.com/index.cfm/2006/11/21/My-First-CFDJ-Article-Encapsulatin g-Recordsets (and search for "iterating business object" at www.pbell.com). One piece is a generic getter and setter that allows for information hidig and overloading using custom methods. Basically get("FirstName") checks to see if first name should be gettable. If so, it looks to see if a getFirstName() method exists. If so, it calls it and returns the value. Otherwise it calls a method called access() which actually hard retrieves the value from a struct within the bean. It's been working pretty well for me on a number of projects . . . Best Wishes, Peter On 3/16/07 10:37 AM, "Phillip Senn" <[EMAIL PROTECTED]> wrote: > Here's a typical getter: > > <cffunction name="getCustomerName" access="public" output="false" > returntype="string"> > <cfreturn variables.strCustomerName /> > </cffunction> > > My impression is that if a table has 100 fields, then there are going to > be 100 getters. > > Q: Is it possible to write a generic getter that uses perhaps an array > index or some other voodoo method instead of hard coding 100 getters? > > <cffunction name="getter" access="public" output="false" > returntype="any"> > <cfargument name="Index" required="true"> > <cfreturn variables.Array[arguments.Index] /> > </cffunction> > > > If the number 100 makes you uncomfortable, substitute the number 50, or > 25. Whatever number you're comfortable with. I know some people balk > at a table having 100 fields. > > > > > You are subscribed to cfcdev. To unsubscribe, please follow the instructions > at http://www.cfczone.org/listserv.cfm > > CFCDev is supported by: > Katapult Media, Inc. > We are cool code geeks looking for fun projects to rock! > www.katapultmedia.com > > An archive of the CFCDev list is available at > www.mail-archive.com/[email protected] > You are subscribed to cfcdev. To unsubscribe, please follow the instructions at http://www.cfczone.org/listserv.cfm CFCDev is supported by: Katapult Media, Inc. We are cool code geeks looking for fun projects to rock! www.katapultmedia.com An archive of the CFCDev list is available at www.mail-archive.com/[email protected]
