Skip to main content
Inspiring
July 9, 2010
Question

Loop over CFC properties?

  • July 9, 2010
  • 1 reply
  • 1035 views

How do you loop over the properties of an object?


I have this CFC and I have properties defined


<cfscript>

...

property name="firstname" getter="true" setter="true" type="string";

property name="lastname" getter="true" setter="true";

---

</cfscript>


I'm trying to loop over these properties and trim the values.


Thanks,


-ws

This topic has been closed for replies.

1 reply

Inspiring
July 9, 2010

First thing that popped into my mind was looping over a collection.

WestSideAuthor
Inspiring
July 10, 2010

Yes, me too, but what would be syntax.  I can dump the object and I see the properties and the methods, but how do I loop over the properties within the CFC.

I'm looking for specific syntax that would allow me to loop over the properties in a CFC.

-ws

Inspiring
July 10, 2010

I'm not in front of my computer to verify this, but I'm pretty sure properties aren't automatically exposed as a collection. You need to use getMetadata() and they're exposed in the returned struct.

I think.

--

Adam