Custom proxies in stores and models seem inconsistent (and do not work on models)

I am using Extjs 4 and created a custom Rest Proxy to handle communication with my Zend backend server. (See Post http://techfrere.blogspot.com/2011/08/linking-extjs4-to-zend-using-rest.html )

When using the repository to handle communications, I used Ext.require to load the proxy server, and then referred to the proxy server in the type field, and everything was fine, and it downloaded my data: according to:

Ext.require('App.utils.ZendRest'); ... proxy : { type : 'zest', // My custom proxy alias url : '/admin/user' ... } 

Then I decided to try using proxies directly on the model ... and no luck. The above logic does not work.
Problems
1. When referencing zest, it does not find the previously loaded ZendRest class (aliased to proxy.zest)
2. He tries to load the missing class from App.proxy.zest (which was not).
So I tried moving my class to this place and renaming it to what he seemed to want. Bad luck.
It loads the class, but still does not initialize the application ... I don't get any errors anywhere, so it's hard for you to figure out where the problem is after that ...

At the moment, it seems to me that I will have to return to using my Zend Rest proxy always through the Store.

Question: Has anyone else seen the behavior? Is this a mistake, or am I missing something?

Thanks...

+6
source share
1 answer

Using your proxy definition, I managed to get it working. I am not sure why this does not work for you. I just moved the ZendRest space to Prj.proxy and added requires: ['Prj.proxy.ZendRest'] to the model.

the code:

 // controller/Primary.js Ext.define('Prj.controller.Primary', { extend: 'Ext.app.Controller', stores: ['Articles'], models: ['Article'], views: ['article.Grid'] }); // model/Article.js Ext.define('Prj.model.Article', { extend: 'Ext.data.Model', fields: [ 'title', 'author', { name: 'pubDate', type: 'date' }, 'link', 'description', 'content' ], requires: ['Prj.proxy.ZendRest'], proxy: { type: 'zest', url: 'feed-proxy.php' } }); // store/Articles.js Ext.define('Prj.store.Articles', { extend: 'Ext.data.Store', autoLoad: true, model: 'Prj.model.Article' }); // proxy/ZendRest.js Ext.define('Prj.proxy.ZendRest', { extend: 'Ext.data.proxy.Ajax', alias : 'proxy.zest', appendId: true, batchActions: false, buildUrl: function(request) { var me = this, operation = request.operation, records = operation.records || [], record = records[0], format = me.format, reqParams = request.params, url = me.getUrl(request), id = record ? record.getId() : operation.id; if (me.appendId && id) { if (!url.match(/\/$/)) { url += '/'; } url += 'id/' + id; } if (format) { reqParams['format'] = format; } /* <for example purpose> */ //request.url = url; /* </for example purpose> */ return me.callParent(arguments); } }, function() { Ext.apply(this.prototype, { actionMethods: { create : 'POST', read : 'GET', update : 'PUT', destroy: 'DELETE' }, /* <for example purpose> */ reader: { type: 'xml', record: 'item' } /* </for example purpose> */ }); }); 

Here the sample works, and here the encrypted code.

+3
source

Source: https://habr.com/ru/post/894440/


All Articles