Results 1 to 10 of 10

Thread: ExtJS Tree sending JSON data neither trough GET nor POST method?

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default ExtJS Tree sending JSON data neither trough GET nor POST method?

    Hi,

    I tryed to use the Extjs tree component with my Coldfusion application. I tought I would just have to inspire from this tutorial and also looking at that sample 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!

  2. #2
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    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).

  3. #3
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default

    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...?

  4. #4
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    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.

  5. #5
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default

    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?

  6. #6
    Sencha User Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,245

    Default

    Did you check in the Firebug Net tab that it really doesn't send parameters?

  7. #7
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default

    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:

    {"action":"TestAction","method":"getTree","data":["root"],"type":"rpc","tid":2}

    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 :-)

  8. #8
    Sencha User aconran's Avatar
    Join Date
    Mar 2007
    Posts
    9,488

    Default

    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.

    ColdFusion
    DirectCFM - Maintained by aconran (Aaron Conran)
    http://extjs.com/forum/showthread.php?t=67983

    ExtDirectCF: A Managed ColdFusion Server-side stack with security - Maintained by jimmifett
    http://extjs.com/forum/showthread.php?t=70279

    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:
    http://extjs.com/blog/2009/05/13/int...ng-ext-direct/

    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.
    Aaron Conran
    @aconran

  9. #9
    Ext JS Premium Member kanntronics's Avatar
    Join Date
    May 2009
    Posts
    23

    Lightbulb

    @ImShogun

    the first case utilizing Ext Direct. For ColdFusion, u might want to check DirectCFM. 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


    p/s:

    woot.. @aconran is fast..
    Last edited by kanntronics; 19 Jul 2009 at 6:07 AM. Reason: i'm late

  10. #10
    Sencha User
    Join Date
    Jul 2009
    Posts
    61

    Default

    @aconran,

    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.

    @kanntronics,

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •