Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext User
    Join Date
    Dec 2009
    Posts
    1
    Vote Rating
    0
    magnus76 is on a distinguished road

      0  

    Default [FIXED][3.1] Restful Store incorrectly overrides proxy configured HTTP method

    [FIXED][3.1] Restful Store incorrectly overrides proxy configured HTTP method


    Using a JsonStore (restful enabled), for created HttpProxy, the configuration for HTTP method to use (api configuration) is wrongly overriden in Ext.data.store constructor.

    Code:
    if((this.url || this.api) && !this.proxy){
                this.proxy = new Ext.data.HttpProxy({url: this.url, api: this.api});
            }
            
            if (this.restful === true && this.proxy) {
                
                
                this.batch = false;
                Ext.data.Api.restify(this.proxy); //Sets HTTP method to CRUD defaults
            }
    I am aware a strict CRUD backend should use methods as POST/GET/PUT/DELETE, but the proxy API for HttpProxy indicates this should be possible to modify even for restful, and confusing impl today.

    For reference, my implementation:

    Code:
     var giftsStore = new Ext.data.JsonStore({
                            proxy: new Ext.data.HttpProxy({
                                api: {
                                    create: {
                                                    url: '/api/gifts',
                                                    method: 'POST'
                                                },
                                                destroy: {
                                                    url: '/api/gifts',
                                                    method: 'DELETE'
                                                },
                                                read: {
                                                    url: '/api/gifts/',
                                                    method: 'GET'
                                                },
                                                update: {
                                                    url: '/api/gifts',
                                                    method: 'POST'
                                                }
                                } 
                            }),
                            //data: successJsonData, //test data
                            restful: true,
                            autoDestroy: true,
                            autoLoad: true,
                            autoSave: true,
                            //writer
                            writer: new Ext.data.JsonWriter({
                                encode: true,
                                writeAllFields: false // write all fields, not just those that changed
                            }),
                            
                            //reader configs
                            root: 'items',
                            idProperty: 'key',
                            fields: [
                                {name: 'reserved', type: 'boolean'},
                                {name: 'reserved_by_user', type: 'boolean'},
                                'url',
                                'title',
                                    ],
                            listeners:     
                                    {
                                      exception: function(a, b, c, d, e, f)
                                      {
                                        console.debug('loadexception!')
                                      },
                                      load: function()
                                      {
                                        console.debug('load!')
                                      },
                                      beforeload: function(a, b)
                                    {
                                    }
                                    }
    
    
                        }); 
    
    As a result, update requests will still use default PUT method.
    Running ext 3.1.0, and with current implementation of Ext.data.store, update will always run with PUT method.

  2. #2
    Sencha - Community Support Team hendricd's Avatar
    Join Date
    Aug 2007
    Location
    Long Island, NY USA
    Posts
    5,962
    Vote Rating
    10
    hendricd will become famous soon enough hendricd will become famous soon enough

      0  

    Default


    Fixed in SVN.
    "be dom-ready..."
    Doug Hendricks

    Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.


    Got Sencha licensing questions? Find out more here.


Thread Participants: 1