• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

[HELPED] calling the sync method on a Store object

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • [HELPED] calling the sync method on a Store object

    I'm trying to use the sync method on a Store object which is supposed to formulate a "batched" Ajax request with all the changes, additions & deletions to the store.

    I had to listen for the "beforeSync" event in which I set the "action" query string parameter appropriately.

    When I look at the resulting Network traffic with the Chrome developer tools I can see that my "action" query string is set correctly and I see something labeled "Request Payload" which contains a JSON object with the record (model) I am trying to sync back to the DB2/400 database.... it all looks fine.

    However, there doesn's appear to be a way for vvIn to retrieve this "Request Payload". At least I couldnt find a way.

    So my question; "How do I retrieve the 'Request Payload' in my RPG program"?

    I've inserted a screen shoot of the Chrome Network traffic which includes the "Request Payload" I mentioned.
    StoreSyncRequestPayload1.jpg

  • #2
    Well I received no replies to my question regarding the "request payload" resulting from the sync method of Ext.data.Store. Which leads me to believe Valence does not support its retrieval, this also leads me to believe that no one using Valence is using the sync method of the Ext.data.Store or, for that matter, the save method of the Ext.data.Model class.

    So are my assumptions correct? Is anyone using the sync() or the save() methods to update your back-end database or does everyone just use the Ext.Ajax.request() and include the individual data elements to create/update/delete in the params property?

    Comment


    • #3
      Hi Tim,

      Sorry, as of now there's no vvIn mechanism for pulling data from the request payload.

      So, at least for the meantime, you could try transforming the request payload data into a regular post by hooking into the "beforerequest" event of Ext.data.Connection. The second parameter contains objects of both jsonData and params, so you could just apply jsonData to params. Something like this:

      Code:
      Ext.data.Connection.on({
          beforerequest: function(conn,options){
                Ext.apply(options.params,options.jsonData)
          }
      })
      Let us know if this works out for you!

      -Rob

      Comment


      • #4
        Rob,
        Thanks for confirming my assumption regarding the inability to retrieve the request payload.

        At this point I think hooking into the Ext.data.Connection object might be a bit to broad of an interface point.

        I've had some success with a listener on the "beforesync" event, but the real problem for me is the way Sencha has implemented the sync. Depending on what has occurred within the store object (adds, updates, & deletes) you could potentially have multiple server requests from one call to the sync method (one for each action: add,update,delete) and since there is only one "beforesync" event fired the subsequent server requests would ultimately execute the same RPG sub-procedure for each, I could probably code for this but it would be problematic.

        I think what I am actually going to have to do is simply override the sync method of my stores and code a custom Ext.Ajax request (combining the cool stuff Sencha coded into the stores with the simplicity of standard Ajax).

        Thanks again,
        TimG

        Comment

        Working...
        X