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/
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

Reply via email to