This is where cf can get a little quirky. <cfoutput query="queryName">
You will notice is not: <cfoutput query="#queryName#"> That is because the 'query' attribute only takes the NAME of the variable containing the query. Not the query itself. (Don't ask me why, blame engineers back in CF4) So when you do: <cfoutput query="obj.getStuff()"> It goes looking for a variable named 'obj.getStuff()', which for obvious reasons doesn't exist. Mark On Tue, Feb 23, 2010 at 11:08 AM, nkosi <[email protected]> wrote: > Hi All, > > This is more of an observation rather than a call for help. > > Does anyone know why, if I attempt to call a method in the 'query' > parameter of <cfoutput> it errors? It also errors when using <cfloop > query="{method call here}"> > > e.g. > <cfset obj = CreateObject("component", "test")> > > <cfoutput query="obj.getStuff()"><!--- This is where the error is > thrown ---> > #id# - #month#<br /> > </cfoutput> > > I assume it has something to do with the way (sequence?) CF implements > cfoutput and method calls. This assumption is based on the fact that I > can successfully call the method in a <cfif> > > e.g. > <cfif obj.getStuff().recordcount gt 1> > <p>More than 1.</p> > </cfif> > > My test.cfc looks a little something like this ... > <cfcomponent> > <cffunction name="getStuff" access="public" returntype="query"> > <cfset var qryStuff = > QueryNew("id,month","integer,varchar")> > > <!--- Add 12 rows to the query ---> > <cfset QueryAddRow(qryStuff,12)> > > <!--- Loop over the rows and populate the table with month > data ---> > <cfloop query="qryStuff"> > <cfset QuerySetCell(qryStuff,"id", currentrow, > currentrow)> > <cfset QuerySetCell(qryStuff,"month", > MonthAsString(currentrow), > currentrow)> > </cfloop> > > <cfreturn qryStuff> > </cffunction> > </cfcomponent> > > BTW - I have only tested this on a CF8 developer instance. > > Cheers > Glen > > -- > You received this message because you are subscribed to the Google Groups > "cfaussie" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<cfaussie%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/cfaussie?hl=en. > > -- E: [email protected] T: http://www.twitter.com/neurotic W: www.compoundtheory.com Hands-on ColdFusion ORM Training @ cf.Objective() 2010 www.ColdFusionOrmTraining.com/ -- You received this message because you are subscribed to the Google Groups "cfaussie" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/cfaussie?hl=en.
