Dan,
 
I did something like this:
<!--- Display all the data from the fields in the USERS record --->
<cfloop list="#UserRecord._getObjectMetaData().getFieldList()#" index="thisField">
    #thisField# = #evaluate("UserRecord.get#thisField#()")#<br />
</cfloop>
Is that what you're looking for?
 
-matt
 

Matthew Newby
PNS Web Services
PH: 207-438-5263
email: [EMAIL PROTECTED]


When digitally signed, the signature is in accordance with DoDI 8520.2, dated 1 Apr 2004.

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]On Behalf Of Dan Sorensen
Sent: Wednesday, August 02, 2006 7:51 PM
To: [email protected]
Subject: [Reactor for CF] How do I dynamically call get(fieldname) methods?

I want to create a dynamically generated table from the contents of a single reactor record. What's the best way to dynamically call the get(fieldname) methods?

 

Example (assuming reactor was already initialized as application.reactor):

 

<!--- Get Field Names --->

<cfset fieldNames = application.reactor.createRecord("exampleTable")._getObjectMetaData().getFields()>

<!--- Get Record Data --->

<cfset record = application.reactor.createRecord("exampleTable").load(FORM.recordNumber)>

 

<cfoutput>

<table>

            <cfloop index="I" from="1" to="#arrayLen(fieldNames)#>

                        <tr>

                                    <td>#fieldnames[i].alias#</td>

                                    <td>

                                                HERE'S WHERE I'M STUCK: #record["get" & fieldname[i].name & "()"]#

</td>

                        </tr>

</cfloop>

</table>

</cfoutput>

 

Now, I'd like to loop over fieldNames and create a table with the field name in the left column, and the data in the right column, but I don't know how to dynamically call the getFieldName(). With a query it would simply be: record[fieldname[i].name][currentrow]. I'm sure this is a common issue. Have I overlooked a Reactor function that deals with this? What's the recommended practice?

 

Thanks,

Dan

 


-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Reactor for ColdFusion Mailing List
[email protected]
Archives at: http://www.mail-archive.com/reactor%40doughughes.net/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to