Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: [Closed] JsonWriter and UNDEFINED parameter

  1. #1

    Default [Closed] JsonWriter and UNDEFINED parameter

    Hi Folks,

    I've looked everywhere I know and cannot workout why, when my JsonWriter posts its changes it sends them to a param called UNDEFINED.

    Example code...
    HTML Code:
            this.mmoWriter = new Ext.data.JsonWriter({
                encode: true,
                writeAllFields: false // just those that changed
            });
    
            this.mmoStore = new Ext.data.Store({
                reader: new Ext.data.XmlReader({
             	          record: "anMMO",  
             	          id: "mmo_id" 
         		        }, ["mmo_id", "detailsIMG", "fileName", "occ", "mmoURL", "size", "title", "description"]
       	        ),
                writer: this.mmoWriter,
                url: "iq_attachment.store_handler",
                method: "POST",
                remoteSort: false,  
                batch: false,      
                autoSave: false,
                baseParams: {
                    pRecordID: document.RESPONDER.pRspID.value
                },
                sortInfo: {
                   field: "occ",
                   direction: "ASC" // or "DESC" (case sensitive)
                },
                restful: false
            });
    Example POST header
    HTML Code:
    pRecordID	3
    undefined	{"title":".jpg","undefined":"TD_RN430_41058_5"}
    xaction	update
    Does anybody have any ideas?

  2. #2

  3. #3
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    Suggest you state what version of Ext you are using and post either a working test case, or take one of the demo examples and modify it to reproduce the behavior you're experiencing.

  4. #4

    Default

    Thanks for the quick response. I must admit that I assumed posting in the Ext 3.0 thread meant I was using Ext 3.0 but I'm happy to confirm that. I was hoping I'd just missed something obvious (long day coding and all that).

    All my code is behind firewalls so a pain in the proverbial to get out as a working demo.

    I'd be happy to run with an example but cannot find one using a Store with a JsonWriter. Could you point me to one please?

  5. #5
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    Well, there's one at examples/writer/writer.html

    Also 3.0 is fairly vague. You might be using an RC, 3.0.0, 3.0 from svn, etc. The reason I asked is I vaguely recall where there may have been a bug that was patched.

    The reason I suggest a working demo is that it may just be a minor tweak here or there to have that working example produce the behavior you're experiencing. Makes it easier for someone like me to have a working example to debug against. Many times it takes longer to make the test case than it does to find where the bug is.

  6. #6

    Default

    Fair call. I didn't realise there were so many versions. Sorry about that. I'm actually not sure how to tell exactly what version I am on. Inside ext-all-debug.js it says "Ext JS Library 3.0.0".

    I fully understand the benefit of a working example for you and am happy to comply.
    I'll check out the example you kindly pointed me to and get back with some details.
    Thanks for your patience.

  7. #7

    Default

    I found the example. Can't believe I didn't see it earlier. Doh!
    I just downloaded the July 7 release of Ext3.0 (I already had it but just wanted to make sure)

    Anyway... In the RESTful store example the proxy looks like

    PHP Code:
    var proxy = new Ext.data.HttpProxy({
        
    url'app.php/users'
    }); 
    When the update command fires it constructs a url like
    HTML Code:
    https://extjs.com/deploy/dev/examples/restful/app.php/users/4
    It has appended a slash and a 4. Where the 4 is the id of the record in the store that was updated and the response is the json.

    My proxy needs to point at an oracle procedure with parameters, something like
    PHP Code:
    var proxy = new Ext.data.HttpProxy({
        
    url'mystoredpackage.procedure'
    }); 
    I need to send the record id with a named parameter
    Eg.
    PHP Code:
    var proxy = new Ext.data.HttpProxy({
        
    url'mystoredpackage.procedure',
        
    baseParams: {
            
    rec_id store.update_rec_id,
            
    json store.update_json 
        
    }
    }); 
    At the moment the url on my post ends up like
    HTML Code:
    http:xxx/mystoredprocedure./rec_id/procedure
    where the record id of the updated record in the store is spliced into the url. What the?

    I am looking into having a working example posted on our site, but that will take a while (it's not up to me)

  8. #8

    Default

    OK, the issue is in Ext.data.DataProxy.BuildUrl which is where it splices the record.id into the url when it finds a url with "provides" suffix. But I have no idea what that means.

    All I know is that my url "iq_attachment.store_loader" does NOT need to be tampered with.

    Ext has then correctly appended the baseParam I sent it but then appended a param called "undefined" that contains the update json.

    I can override the BuildUrl method but I still cannot find where the "undefined" param is coming from.

    Anybody point me in the right direction?

  9. #9
    Ext User
    Join Date
    Jul 2007
    Location
    Florida
    Posts
    9,996

    Default

    The behavior smells like you have restful=true

    Do you see similar behavior when you tinker with the stock example?

  10. #10
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    381

    Default

    The regexp in buildUrl casts too wide a net scanning for format information:
    Code:
    var m = url.match(/(.*)(\.\w+)$/)
    It should have been this something like this instead:
    Code:
    var m = url.match(/(.*)(\.json|xml|html)$/);
    I will change this in SVN.

    As for your params being placed in key UNDEFINED, I think it's because you're using an XmlReader along with JsonWriter. Development of XmlReader has lagged a bit (though I'm working on it lately). However, try specifying a root property on your XmlReader. Your params should now be stored in the key you specify as root.

    Code:
    reader: new Ext.data.XmlReader({
        record: "anMMO",  
        id: "mmo_id",
        root: "data",
    }, ["mmo_id", "detailsIMG", "fileName", "occ", "mmoURL", "size", "title", "description"]),
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $150USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

Page 1 of 2 12 LastLast

Posting Permissions

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