Something like this will work (totally pseudo) -
<cfset functions = getMetaData(bean).functions />
<cfset len = ArrayLen(function) />
<cfloop from="1" to="#len#" index="counter" >
<cfset function = functions[counter] />
<if function.name.startsWith("get") > <!--- use some handy java --->
<cfinvoke component="#bean#" method="#function.name#
returbVariable="value1" />
<cfinvoke component="#bean2#" method="#function.name#
returbVariable="value2" />
<cfif value1 neq value2 >
<!--- do stuff here --->
</cfif>
</cfif>
</loop>
I take no responsibility for syntactical errors.
Mark
On 10/26/06, Mike Kear <[EMAIL PROTECTED]> wrote:
Is there an easy way to loop over all the getter methods in a bean, rather
than spelling them all out one by one?
What I'm' doing is i have a client with user profiles that have
something like 50 fields (and therefore getters and setters) in the
profile. I need to send an email to the office when a user changes
their profile, and I want them to see what the user has changed, not
just the details as they are after the changes.
So thanks to a suggestion from Sean Corfield, I'm creating a bean for the
user when they go to the update profile page, and i'm creating another bean
with the same details and storing it in session scope. Then after the
update is finished, I want to compare the contents of each value in the two
beans, to see what the user has changed. That means doing
<CFIF session.User.getUsefirstname() NEQ User.getUserFirstname()>
50 or more times.
And if I add a field to the profile, (and therefore another
getter/setter) there's another bit of code to maintain.
Is there a way to loop over all the getters without explicitly typing them
all out?
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks Pty Ltd
http://afpwebworks.com
Full Scale ColdFusion hosting from A$15/month
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]
--
E: [EMAIL PROTECTED]
W: www.compoundtheory.com
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]