View Full Version : [Closed] JsonWriter and UNDEFINED parameter

3 Aug 2009, 11:07 PM
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...

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

pRecordID 3
undefined {"title":".jpg","undefined":"TD_RN430_41058_5"}
xaction update

Does anybody have any ideas?

4 Aug 2009, 2:34 PM

4 Aug 2009, 2:37 PM
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 Aug 2009, 2:54 PM
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?

4 Aug 2009, 3:00 PM
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.

4 Aug 2009, 3:08 PM
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.

4 Aug 2009, 6:37 PM
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

var proxy = new Ext.data.HttpProxy({
url: 'app.php/users'

When the update command fires it constructs a url like


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

var proxy = new Ext.data.HttpProxy({
url: 'mystoredpackage.procedure'

I need to send the record id with a named parameter

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


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)

4 Aug 2009, 8:55 PM
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?

5 Aug 2009, 4:47 AM
The behavior smells like you have restful (http://extjs.com/deploy/ext-3.0.0/docs/?class=Ext.data.DataProxy&member=restful)=true

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

5 Aug 2009, 5:59 AM
The regexp in buildUrl casts too wide a net scanning for format information:

var m = url.match(/(.*)(\.\w+)$/)

It should have been this something like this instead:

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.

reader: new Ext.data.XmlReader({
record: "anMMO",
id: "mmo_id",
root: "data",
}, ["mmo_id", "detailsIMG", "fileName", "occ", "mmoURL", "size", "title", "description"]),

5 Aug 2009, 2:40 PM
Thanks for the replies guys, you have confirmed both my findings yesterday and I was in the process of investigating the XmlWriter when I found christocracy's other post mentioning the incomplete work of the XmlWriter class.

It's a pity this work isn't quite ready, it suits my requirement. Never mind, I guess will now simply write my own.