【问题标题】:How to access complex REST resources with ExtJS 5如何使用 ExtJS 5 访问复杂的 REST 资源
【发布时间】: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}]

问题:

  1. 有什么方法可以将我的请求发送到“GET rest/clients/2/users而不使用其 clientId 手动更新用户代理 url?
  2. 如何发送上述请求而不丢失 App.model.User 中定义的原始 url,“rest/users

【问题讨论】:

    标签: rest extjs extjs5


    【解决方案1】:

    我认为这与这个问题基本相同:

    Accessing complex REST resources with Ext JS

    我认为自从第一次提出要求以来没有太大变化。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-25
      • 2017-12-19
      • 2012-11-30
      • 2018-10-11
      • 1970-01-01
      • 2011-10-29
      • 1970-01-01
      相关资源
      最近更新 更多