View Full Version : ExtJS Tree sending JSON data neither trough GET nor POST method?

17 Jul 2009, 3:01 AM

I tryed to use the Extjs tree component with my Coldfusion application. I tought I would just have to inspire from this tutorial (http://extjs.com/learn/Tutorial:Ext20_Tree_TreeLoader_PHP_MySQL) and also looking at that sample (http://extjs.com/deploy/dev/examples/direct/direct-tree.php)source but since I'm not familiar with php I tought I could try to talk to my own cfm file instead. I then discovered that there is JSON sent to the cfm template (Firebug showned it) but I can't find any way to read it from coldfusion: It is neither in the URL scope nor in the POST scope. I also found a few places on the web with pieces of code who where supposedly written to get this JSON data back from the request headers themselves, but it didn't worked.

The question is: Is there any way, with coldfusion, to read the JSON who's sent this way? I think jquery requests are also sending JSON this way?

Thank you for your help!

17 Jul 2009, 3:54 AM
Only the (second) example sends JSON data.

The tutorial uses the default method: application/x-www-form-urlencoded.

If you specify an url or a dataUrl (and not a directFn) then your cfm located at that url will receive a requires with a parameter called 'node' which contains the id of the node being expanded.
Your cfm needs to respond with a JSON array of nodes located under that node (and don't forget to give each node a unique id, for when they need to be expanded).

17 Jul 2009, 4:54 AM
Thank you Condor,

It helps a lot. I'll do that. You saved my time!

But because i'm so curious, I still wonder if there is any way to read the application/x-www-form-urlencoded method from coldfusion, so if any cf geek arround...?

17 Jul 2009, 5:38 AM
I have no idea how ColdFusion works, but application/x-www-form-urlencoded is the standard method to send POST parameters, so I expect that you already know how to handle these.

17 Jul 2009, 6:20 AM
That's the problem: Correct method is using the FORM scope, but it's empty. Probably because it is posted but with no variable name?

17 Jul 2009, 7:55 AM
Did you check in the Firebug Net tab that it really doesn't send parameters?

19 Jul 2009, 4:10 AM
Well, I know it is send:but I noticed some differences beetween the request made by the Extjs Tree posting the Json and a "simple form post request".

Under the POST tab:

1) ExtJS Tree to router.php:


2) Simple form with action=post:

myfield myvalue

In the second case, there is a variable name. There is none from the ExtJS Tree.

My guess, so far, is that Coldfusion don't see any variable name to assign the json string, so it simply ignores it?

I don't know if it is related, but I also had a similar issues using the jquery get() function to send Key/value pairs who where not catched in the coldfusion url scope. I then tryed to use the post() one, and where unable to catch them in the form scope neither. Then I found out that if I where to send $("#testform").serialize() instead of the Key/value pairs, he posted values then would show in the form scope.

As I sayd in my second post, gosh I hate not understanding something :-)

19 Jul 2009, 5:57 AM
This sample you are taking a look at is using Ext.Direct. There are two server-side stacks which exist for ColdFusion and can be found on the master list of server-side stacks.

DirectCFM - Maintained by aconran (Aaron Conran)

ExtDirectCF: A Managed ColdFusion Server-side stack with security - Maintained by jimmifett

Ext.Direct is a client-side technology which enables you to invoke server-side methods with ease. Think of it as cfajaxproxy or DWR on steroids. You can read more about Ext.Direct in this blog entry:

On a side note, if you are curious about getting the post data out of a request, take a look and the internals of either CF direct implementation. They need to dip into java to grab out the post body.

19 Jul 2009, 6:04 AM

the first case utilizing Ext Direct. For ColdFusion, u might want to check DirectCFM (http://extjs.com/forum/showthread.php?t=67983). u can examine how it handle the JSON request in Direct.cfc file.

For second case, u can handle the request in form scope in .cfm and argumentsscope in .cfc


woot.. @aconran is fast..

19 Jul 2009, 2:21 PM

Thanks a lot for the 3 very usefull links, I saw the cfcode in router.cfm file and was pleased to confirm my toughts and to find a piece of CF code I could use to grab these 'body embedded" json requests.

I started using the Tree component without Ext.direct, sending the ID trough url, but I promess I will look into Ext.direct concept.

I'm not frightened anymore, to do ExtJs with such a dynamic forum full of people helping!
Coldfusion 9 will come this year with ExtJS3.0+ embedded in CFtags instead of the YahooUI they had in the 8th version, I'll love that!

Again, thanks a lot.


Thank you for helping me remember that cfc comes with arguments scope filled instead of form. I know coldfusion since version 4.5 from Allaire, but sometimes I just forget things and get stucked. I wonder if the issues I had with jquery trying to GET or POST data where directed to a cfm or cfc, I'll have to check that tomorrow.

And yes, aconran is fast!

So, did I say thank you guys?