• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Loop over CFC properties?

Engaged ,
Jul 09, 2010 Jul 09, 2010

Copy link to clipboard

Copied

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

TOPICS
Advanced techniques

Views

858

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 09, 2010 Jul 09, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Jul 09, 2010 Jul 09, 2010

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2010 Jul 10, 2010

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation