Wiki

Clone wiki

ExtJSPackages / Server URL Placeholders

This package allows placeholders in the URLs configured in a server proxy.

Released under GPLv3.

The motivation of this package was the necessity to load data from REST services with path variables in the form: /route/${foo}/and/${bar.baz}/and/maybe/id

With this package you have to configure the URLs for a server (in the form of a proxy, for example):

proxy: {
  type: 'rest',
  url: '/controller/${param1}/blah/${more.param2}'
}
or with the api option:
proxy: {
  type: 'rest',
  api: {
    create  : '/controller/new/${owner}/${foo.bar.baz}',
    read    : '/controller/load',
    update  : '/controller/update',
    destroy : '/controller/destroy_action'
  }
}

To set the parameter values, they can be configured with a default parameters values with extraParams:

proxy: {
  type: 'rest',
  url: '/controller/${param1}/blah/${more.param2}',
  extraParams: {
    param1: 'blah',
    more: {
      param2: 'bleh'
    }
  }
}
or programmatically:
store.getProxy().extraParams = {...} ;

Those default values will be overriden with the load config parameter. It can be configured when loading stores and models:

// With a store
store.load({
  params: {
      group: 3,
      type: 'user'
  },
  callback: function(records, operation, success) {
      // do something after the load finishes
  },
  scope: this
});

// With a model
model.load(id_or_null, {
  params: {
    parameter1: ...
  }
  ...
}) ;

##Warning for REST proxy server and appendId## This package includes a modification on appendId parameter behaviour. When appendId === false, the query parameter ?id=... it will not be appended to the URL string. When appendId === false, it is still possible to configure a placeholder like foo/${id}/bar/baz.

##How to install##

Install the package:

#!bash
$ sencha repo add alfonsonishikawa https://alfonsonishikawa.bitbucket.io/extjspackages/pkgs
$ sencha package install nishilua-server-url-placeholders
Add it to your app.json:
#!json
    requires: [
        .... ,
        "nishilua-server-url-placeholders"
    ],
It will be downloaded automatically when doing:
#!bash
$ sencha app watch
And you can start to use it.

##Compatibility##

  • ExtJS 6.0.1.250
  • ExtJS 6.2.0.981

Updated