Threaded View

  1. #1
    Sencha User
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    1
    stephenr85 is on a distinguished road

      0  

    Default Dynamic Proxy URLs

    Dynamic Proxy URLs


    With a REST proxy, rather than only allowing us to append a respective model ID, I would have expected to be able to define multiple variables in the URL. This is also sometimes necessary for standard AJAX URLs. I created a proxy override that uses a template to generate the URL. I'm using a standard Ext.Template, because it seemed an Ext.XTemplate seemed like overkill; although, the code could easily be modified to accomodate that.

    I'm posting the snippet here for anyone interested in doing the same thing. Any ideas for improvement are more than welcome.

    Code:
    Ext.define('MyNamespace.data.proxy.Ajax', {
        override: 'Ext.data.proxy.Ajax',
        buildUrl: function(request){
            //Create a template with the URL and replace the variables
            var url = this.getUrl(request),
                urlTemplate = new Ext.Template(url),
                params = request.getParams(),
                newUrl = urlTemplate.apply(params);
            //Remove variables embedded into URL
            Ext.Object.each(params, function(key, value){
                var regex = new RegExp('{'+key+'.*?}');
                if(regex.test(url)){
                    delete params[key];
                }
            });
            request.setUrl(newUrl);
            this.callParent([request]);
        }
    });

    Now you could have a url like "/service/model/{id}/update"; and call store.getProxy().setExtraParam('id', 1);

    Additionally, you could do something like "/service/model/{id}/{method}" and call store.getProxy().setExtraParams({id: 1, method: 'update'});
    Last edited by stephenr85; 20 Sep 2012 at 10:17 AM. Reason: Improvement

Thread Participants: 1

Tags for this Thread

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi