Rather late to the party, I'm trying to switch to using CFCs to make things easier. At this point, I'm just trying to find my legs and understand them - using CFWACK 9 as a guide.
However, my first attempt silenced me!
Here is what I have in my CFC;
<cffunction name="listBlogEntries" returntype="query" output="false" access="remote" hint="Find all blog entries by blogid, sorted by id desc"> <cfargument name="blogid" required="true" default="24"> <cfset var getBlogEntries = ""> <cfquery name="getBlogEntries"> SELECT ID, entry_title FROM blog_entries WHERE blogID='#ARGUMENTS.blogid#' ORDER BY ID DESC LIMIT 10 </cfquery> </cffunction> <cffunction name="printBlogEntries" returntype="void" access="remote" hint="Lookup blog entries and return formatted"> <cfargument name="blogid" required="true" default="24"> <cfset var qBlogEntries = listBlogEntries(ARGUMENTS.blogid)> <cfoutput query="qBlogEntries"> <h1>Entry ID: #qBlogEntries.ID#</h1> <h3>Entry Title: #qBlogEntries.entry_title#</h3> </cfoutput> <cfreturn> </cffunction>
And my .cfm page to call.
<cfparam name="blogid" default="24" > <cfinvoke component="td" method="printBlogEntries" searchString="#blogid#" returnvariable="blogentries" > <cfoutput>#blogentries#</cfoutput>
Error returned:
The value returned from the listBlogEntries function is not of type query.
If I manually run the request and do cfdump, everything looks as it should, so I am obviously doing something wrong in cfc. However, the way it is now is pretty much a copy of the example in CFWACK.
Pointers will be highly appreciated (like any recommended reading on this!)
source share