1 Reply Latest reply: Oct 16, 2009 4:46 AM by Arkadiusz Młynarczyk
slothbear Level 1 Level 1 (0 points)
I'm loving the new Dashcode 3.0 that came with Snow Leopard. Based on the presentation I saw at WWDC about the new "data sources", I thought I'd have my new application running in about 5 minutes. alas.

In case you haven't seen it, there's a new pane in Dashcode. You specify the URL for your XML or JSON feed. Dashcode automatically loads the feed and interprets its structure. The example at WWDC used the Apple movie trailers site. Dashcode loaded all the movie info and understood that there was a list of 50 movies. Drag from the "title" attribute onto the Dashcode "list" part, and you're done. The list now shows all 50 movies. It works a lot like connections in Interface Builder.

My feed requires a POST request (not a GET). The data source pane does not have an option for a POST request, nor an area for specifying the post data to send. I also read through the DC.AjaxController source (which implements a data source). AjaxController has a "method" property (which I could set to "POST"), but it calls XHR.get unconditionally. AjaxController also has a "parameters" property, which might eventually become my HTTP body, but XHR always formats it as form-encoded (adding the standard "=" and "&" characters). My POST request is pure XML -- no form involved.

I'd like to surgically add a POST request, perhaps by subclassing AjaxRequest and XHR, but I'm not sure where to start. Even if I could add the new behavior, I don't know how to tell the Dashcode UI to use it.

Maybe I should just do it all by hand, but the new "data sources" feature comes +so close+ to what I need. Any ideas on how I could do... any of this? Many thanks.

MacBook Pro 2.8, Mac OS X (10.6)
  • Arkadiusz Młynarczyk Level 1 Level 1 (0 points)
    I was checking that. You can create custom AjaxController with a code like this, but unfortunatelly it seams like it doesn't care for those parameters values. Even if fetchesInitially is set to false, it will still download data. Also method parameter doesn't work, because AjaxController uses XHR with "XHR.get" method.

    var list = document.getElementById('list').object;
    var ajax = new DC.AjaxController({url: 'http://someURL.com/whatever.xml', fetchesInitially: false, method: 'POST', parameters:{parameter1:'value', parameter2:'value2'}});
    DC.registerModelWithName(ajax, 'Ajax');
    list.bindNameToKeyPath('dataArray','Ajax.content', null);