【发布时间】:2014-11-10 18:56:33
【问题描述】:
我正在使用 ExtJS 5,我想访问复杂的 REST 资源,正如 in this similar thread using ExtJS 4 所讨论的那样。
我正在访问的 REST 服务公开了这些资源:
- GET
/rest/clients- 它返回客户端列表 - GET
/rest/users- 它返回所有用户的列表 - GET
/rest/clients/{clientId}/users- 它返回来自指定客户端的用户列表。
我有这些模型:
Ext.define('App.model.Base', {
extend: 'Ext.data.Model',
schema: {
namespace: 'App.model'
}
});
Ext.define('App.model.Client', {
extend: 'App.model.Base',
fields: [{
name: 'name',
type: 'string'
}],
proxy: {
url: 'rest/clients',
type: 'rest'
}
});
Ext.define('App.model.User', {
extend: 'App.model.Base',
fields: [{
name: 'name',
type: 'string'
},{
name: 'clientId',
reference: 'Client'
}],
proxy: {
url: 'rest/users',
type: 'rest'
}
});
我这样做了:
var client = App.model.Client.load(2);
var users = client.users().load();
它分别发送:
//GET rest/clients/2
//GET rest/users?filter:[{"property":"personId","value":"Person-1","exactMatch":true}]
问题:
- 有什么方法可以将我的请求发送到“
GET rest/clients/2/users”而不使用其 clientId 手动更新用户代理 url? - 如何发送上述请求而不丢失 App.model.User 中定义的原始 url,“
rest/users”
【问题讨论】: