CFQueryReader v1.1
May 13
A while back, Justin Carter contacted me about some updates he was making to the ColdExt, a wrapper for the Ext JS library for ColdFusion. He had been looking at my CFQueryReader, as a reader for ColdFusion's JSON data return, and had noticed that there was no support for the 'root' attribute that's associated with most JSON readers in Ext. CFQueryReader is specifically designed for use with Query objects of ColdFusion 8's native JSON return type.
When I first wrote CFQueryReader, I was replacing the CFJsonReader with something better suited to the array structure used in the ColdFusion JSON return of a Query Object, and really did a one-for-one port. So, I took a deeper look at the issue Justin wanted resolved.
I did a deep comparison of Ext's ArrayReader and JsonReader source code, following everything that was being accomplished. What I found was how it used an internal accessor method to pull certain information on demand. I was able to refactor the reader to now support all of the base level meta attributes that are currently available to the ArrayReader: id, root, successProperty, and totalProperty.
In the previous version of CFQueryReader, when defining your fieldsets you were also required to uppercase the entire value of the column names. This is no longer a requirement either, although casing is important in identifying your 'root' and 'totalProperty' attributes.
The download below includes the reader, as well as some sample code showing how to implement it. I also setup these sample in a subdomain to show it working (requires Firefox with Firebug for full effect). There is a fair amount of comment documentation directly within the CFQueryReader.js file. A big shout out to Justin, Adam Bellas, and a few others, for helping me out with the testing.


#1 by John on 5/13/09 - 4:32 PM
#2 by Steve 'Cutter' Blades on 5/14/09 - 6:42 AM
#3 by John Farrar on 5/29/09 - 9:52 AM
#4 by Steve 'Cutter' Blades on 5/29/09 - 11:47 AM
Yeah, I've been doing some opening research. Aaron Conran, who is the Team Lead for Ext Js, is a long time CF guy. He wrote the ColdFusion stack (DirectCFM) examples that are currently available from Ext. I've run some testing with that, with and without CFQueryReader. Direct is pretty slick, and it took me nearly nothing to be successful with it. Aaron's DirectCFM works out ok, but I would tweak some things for better scalability. You should take a few and read over the DirectCFM forum post, and take a look at his code:
http://extjs.com/forum/showthread.php?t=67983
#5 by Tony Walker on 10/6/09 - 6:20 PM
Could not find the ColdFusion Component or Interface com.cutterscrossing.Test.
Ensure that the name is correct and that the component or interface exists.
The error occurred in C:\inetpub\wwwroot\CFQueryReader\servicebus\Direct.cfc: line 71
69 : <cfloop query="totalCFCs">
70 : <cfset cfcName = ListFirst(totalCFCs.name, '.') />
71 : <cfset newCfComponentMeta = GetComponentMetaData(cfcName) />
72 : <cfif StructKeyExists(newCfComponentMeta, "ExtDirect")>
73 : <cfset CFCApi = ArrayNew(1) />
any help is appreciated
#6 by Steve 'Cutter' Blades on 10/7/09 - 1:06 PM
#7 by Steve 'Cutter' Blades on 10/7/09 - 4:16 PM
[BTW, I accidentally blew out Tony's comment, which I'll place below.]
Yes - see code below...
<cfset args = StructNew() />
<cfset args['ns'] = "../CFQueryReader/com.cc" />
<cfset args['desc'] = "APIDesc" />
<cfinvoke component="Direct" method="getAPIScript" argumentcollection="#args#" returnVariable="apiScript" />
<cfcontent reset="true" />
<cfoutput>#apiScript#</cfoutput>
#8 by Tony Walker on 10/7/09 - 4:42 PM
#9 by Steve 'Cutter' Blades on 10/7/09 - 4:52 PM
#10 by pbyhistorian on 12/16/10 - 7:25 PM
I can consume a Coldfusion query object returned from a CFC on a pure Ext JS page -
even if the specifically loads the Coldfusion (9.0.1) Ext JS libraries.
However, if I add a Coldfusion tag for a component built on Ext JS,
Coldfusion generates HTML to load its Ext JS libraries (so I commented out my lines
that load ext-base.js and ext-all.js).
Immediately, Store.load fails, stating that "f is undefined".
This appears to be a reference to "return f.asyncRequest(t,r,n,s)" in Coldfusion's ext-yui-adapter.js.
When I noticed that Coldfusion was loading ext-yui-adapter.js instead of ext-base.js,
I uncommented my lines loading ext-base.js and ext-all.js (they must be in that order) and
the code works again. But I suspect I'm breaking ext-yui-adapter.js by doing this.
Will this approach work on page that mixes Coldfusion and Ext JS components?
#11 by pbyhistorian on 12/16/10 - 7:27 PM
#12 by pbyhistorian on 12/16/10 - 8:59 PM
#13 by Steve 'Cutter' Blades on 12/18/10 - 7:33 AM
Personally, I wouldn't use the CFAjax tags in conjunction with ExtJS. Depending on which version of CF you are using, the included library is either 1.1 or 2.2, and you're missing out on the more advanced features of the 3.3.1 library.