riccardocagnasso

a (better?) extjs rest proxy

Sep 20th, 2012
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Ext.define('tesolepanel.store.MyRest',{
  2.     extend: 'Ext.data.proxy.Rest',
  3.     requires: ['Ext.data.proxy.Rest'],
  4.     alias: 'proxy.myrest',
  5.  
  6.     buildUrl: function(request) {
  7.         var me        = this,
  8.             operation = request.operation,
  9.             records   = operation.records || [],
  10.             record    = records[0],
  11.             format    = me.format,
  12.             url       = me.getUrl(request),
  13.             id        = record ? record.raw[record.idProperty] : operation.id
  14.        
  15.  
  16.         if (me.appendId) {
  17.             if (!url.match(/\/$/)) {
  18.                 url += '/';
  19.             }
  20.            
  21.             url += id;
  22.         }
  23.        
  24.         if (format) {
  25.             if (!url.match(/\.$/)) {
  26.                 url += '.';
  27.             }
  28.            
  29.             url += format;
  30.         }
  31.  
  32.         if (me.noCache) {
  33.             url = Ext.urlAppend(url, Ext.String.format("{0}={1}", me.cacheString, Ext.Date.now()));
  34.         }
  35.        
  36.         request.url = url;
  37.  
  38.         return url;
  39.     }
  40.  
  41. });
Advertisement
Add Comment
Please, Sign In to add comment