Ext.NET  5.3.0
.NET Component Framework for Enterprise Level Apps
Ext.Net.RestProxy Class Reference

RestProxy is a specialization of the AjaxProxy which simply maps the four actions (create, read, update and destroy) to RESTful HTTP verbs. For example, let's set up a Model with an inline RestProxy More...

Inheritance diagram for Ext.Net.RestProxy:
Ext.Net.AjaxProxy Ext.Net.ServerProxy Ext.Net.AbstractProxy Ext.Net.BaseItem Ext.Net.IAlias Ext.Net.IXObject Ext.Net.IBase

Classes

class  Builder
 
class  Config
 

Public Member Functions

 RestProxy ()
 
RestProxy.Builder ToBuilder ()
 
override IControlBuilder ToNativeBuilder ()
 
 RestProxy (Config config)
 
- Public Member Functions inherited from Ext.Net.AjaxProxy
 AjaxProxy ()
 
AjaxProxy.Builder ToBuilder ()
 
 AjaxProxy (Config config)
 
- Public Member Functions inherited from Ext.Net.BaseItem
virtual bool HasExplicitValue (string name)
 
void EnsureDataBind ()
 
virtual void Call (string name)
 
virtual void Call (string name, params object[] args)
 
virtual void AddScript (string script)
 
virtual void AddScript (string script, params object[] args)
 
virtual bool IsEmptyObject ()
 
Apply< T > (IApply config)
 
BaseItem Apply (object config)
 
virtual void LoadViewState (object state)
 
virtual object SaveViewState ()
 
virtual void TrackViewState ()
 
void SetDirty ()
 
virtual void DataBind ()
 

Static Public Member Functions

static implicit operator RestProxy (RestProxy.Config config)
 
- Static Public Member Functions inherited from Ext.Net.AjaxProxy
static implicit operator AjaxProxy (AjaxProxy.Config config)
 

Properties

override string InstanceOf [get]
 
override string Type [get]
 Alias More...
 
virtual bool AppendId [get, set]
 True to automatically append the ID of a Model instance when performing a request based on that single instance. See RestProxy intro docs for more details. Defaults to true. More...
 
override bool BatchActions [get, set]
 True to batch actions of a particular type when synchronizing the store. Defaults to false. More...
 
virtual string Format [get, set]
 Optional data format to send to the server when making any request (e.g. 'json'). See the RestProxy intro docs for full details. Defaults to undefined. More...
 
override string ActionMethodsProxy [get]
 
override ConfigOptionsCollection ConfigOptions [get]
 
- Properties inherited from Ext.Net.AjaxProxy
override string InstanceOf [get]
 
override string Type [get]
 Alias More...
 
virtual ParameterCollection?? Headers [get]
 Any headers to add to the Ajax request. Defaults to undefined. More...
 
virtual bool Json [get, set]
 Send params as JSON object More...
 
virtual bool Xml [get, set]
 Send params as XML object More...
 
virtual CRUDMethods?? ActionMethods [get]
 Mapping of action name to HTTP request method. In the basic AjaxProxy these are set to 'GET' for 'read' actions and 'POST' for 'create', 'update' and 'destroy' actions. The Ext.data.proxy.Rest maps these to the correct RESTful methods. More...
 
virtual string ActionMethodsProxy [get]
 
virtual JFunction GetMethod [get]
 Returns the HTTP method name for a given request. By default this returns based on a lookup on actionMethods. Parameters request : Ext.data.Request The request object Returns The HTTP method to use (should be one of 'GET', 'POST', 'PUT' or 'DELETE') More...
 
virtual string Password [get, set]
 Most oData feeds require basic HTTP authentication. This configuration allows you to specify the password. More...
 
virtual bool UseDefaultXhrHeader [get, set]
 Set this to false to not send the default Xhr header (X-Requested-With) with every request. This should be set to false when making CORS (cross-domain) requests. Defaults to true. More...
 
virtual string Username [get, set]
 Most oData feeds require basic HTTP authentication. This configuration allows you to specify the username. More...
 
virtual bool WithCredentials [get, set]
 This configuration is sometimes necessary when using cross-origin resource sharing. Defaults to false. More...
 
override ConfigOptionsCollection ConfigOptions [get]
 
- Properties inherited from Ext.Net.ServerProxy
override string InstanceOf [get]
 
virtual CRUDUrls?? API [get]
 Specific urls to call on CRUD action methods "read", "create", "update" and "destroy". The url is built based upon the action being executed [load|create|save|destroy] using the commensurate api property, or if undefined default to the configured Ext.data.Store.url. If the specific URL for a given CRUD action is undefined, the CRUD action request will be directed to the configured url. More...
 
virtual string CacheString [get, set]
 The name of the cache param added to the url when using noCache (defaults to "_dc") More...
 
virtual string DirectionParam [get, set]
 The name of the direction parameter to send in a request. This is only used when simpleSortMode is set to true. Defaults to 'dir'. More...
 
virtual ParameterCollection?? ExtraParams [get]
 Extra parameters that will be included on every request. Individual requests with params of the same name will override these params when they are in conflict. More...
 
virtual string FilterParam [get, set]
 The name of the 'filter' parameter to send in a request. Defaults to 'filter'. Set this to undefined if you don't want to send a filter parameter More...
 
virtual string GroupParam [get, set]
 The name of the 'group' parameter to send in a request. Defaults to 'group'. Set this to undefined if you don't want to send a group parameter More...
 
virtual string GroupDirectionParam [get, set]
 The name of the direction parameter to send in a request. This is only used when simpleGroupMode is set to true. Defaults to 'groupDir'. More...
 
virtual string IDParam [get, set]
 The name of the parameter which carries the id of the entity being operated upon. Defaults to: "id" More...
 
virtual string LimitParam [get, set]
 The name of the 'limit' parameter to send in a request. Defaults to 'limit'. Set this to undefined if you don't want to send a limit parameter More...
 
virtual bool NoCache [get, set]
 Defaults to true. Disable caching by adding a unique parameter name to the request. Set to false to allow caching. Defaults to true. More...
 
virtual bool AppendAction [get, set]
 
virtual string PageParam [get, set]
 The name of the 'page' parameter to send in a request. Defaults to 'page'. Set this to undefined if you don't want to send a page parameter More...
 
virtual ReaderCollection?? Reader [get]
 The Ext.data.reader.Reader to use to decode the server's response. This can either be a Reader instance, a config object or just a valid Reader type name (e.g. 'json', 'xml'). More...
 
virtual bool SimpleSortMode [get, set]
 Enabling simpleSortMode in conjunction with remoteSort will only send one sort property and a direction when a remote sort is requested. The directionParam and sortParam will be sent with the property name and either 'ASC' or 'DESC'. Defaults to: false More...
 
virtual bool SimpleGroupMode [get, set]
 Enabling simpleGroupMode in conjunction with remoteGroup will only send one group property and a direction when a remote group is requested. The groupDirectionParam and groupParam will be sent with the property name and either 'ASC' or 'DESC'. Defaults to: false More...
 
virtual string SortParam [get, set]
 The name of the 'sort' parameter to send in a request. Defaults to 'sort'. Set this to undefined if you don't want to send a sort parameter More...
 
virtual string StartParam [get, set]
 The name of the 'start' parameter to send in a request. Defaults to 'start'. Set this to undefined if you don't want to send a start parameter More...
 
virtual int Timeout [get, set]
 The number of milliseconds to wait for a response. Defaults to 30000 milliseconds (30 seconds). More...
 
virtual string Url [get, set]
 The default URL to be used for requests to the server. More...
 
virtual string UrlProxy [get]
 
virtual string StartParamProxy [get]
 
virtual string LimitParamProxy [get]
 
virtual WriterCollection?? Writer [get]
 The Ext.data.writer.Writer to use to encode any request sent to the server. This can either be a Writer instance, a config object or just a valid Writer type name (e.g. 'json', 'xml'). More...
 
ProxyListeners?? Listeners [get]
 Client-side JavaScript Event Handlers More...
 
virtual JFunction BuildUrl [get]
 Generates a url based on a given Ext.data.Request object. By default, ServerProxy's buildUrl will add the cache-buster param to the end of the url. Subclasses may need to perform additional modifications to the url. Parameters request : Ext.data.Request The request object Returns The url More...
 
override ConfigOptionsCollection ConfigOptions [get]
 
- Properties inherited from Ext.Net.AbstractProxy
override string InstanceOf [get]
 
abstract string Type [get]
 Alias More...
 
virtual bool BatchActions [get, set]
 True to batch actions of a particular type when synchronizing the store. Defaults to true. More...
 
virtual string BatchOrder [get, set]
 Comma-separated ordering 'create', 'update' and 'destroy' actions when batching. Override this to set a different order for the batched CRUD actions to be executed in. Defaults to 'create,update,destroy' More...
 
string PropertyName [get]
 
override ConfigOptionsCollection ConfigOptions [get]
 
- Properties inherited from Ext.Net.BaseItem
virtual string InstanceOf [get]
 
ItemState State [get]
 
virtual DefaultValueMode DefaultValueMode [get, set]
 
virtual bool DesignMode [get]
 
bool AutoDataBind [get, set]
 
ResourceManager ResourceManager [get]
 
virtual Control Owner [get, set]
 The Owner Control for this Listener. More...
 
virtual bool IsDefault [get]
 Does this object currently represent it's default state. More...
 
bool IsTrackingViewState [get]
 
EventHandlerList Events [get]
 
EventHandler DataBinding
 
Control?? BindingContainer [get]
 
virtual ConfigItemCollection?? CustomConfig [get]
 Collection of custom js config More...
 
virtual ConfigOptionsCollection ConfigOptions [get]
 
virtual ConfigOptionsExtraction ConfigOptionsExtraction [get]
 
System.Web.Mvc.HtmlHelper?? HtmlHelper [get, set]
 
- Properties inherited from Ext.Net.IXObject
ConfigOptionsCollection ConfigOptions [get]
 
ConfigOptionsExtraction ConfigOptionsExtraction [get]
 
DefaultValueMode DefaultValueMode [get, set]
 
- Properties inherited from Ext.Net.IAlias
string PropertyName [get]
 

Additional Inherited Members

- Protected Member Functions inherited from Ext.Net.BaseItem
 BaseItem (Control owner)
 
 BaseItem ()
 
virtual void OwnerUpdate (Control owner)
 
virtual void OnDataBinding (EventArgs e)
 

Detailed Description

RestProxy is a specialization of the AjaxProxy which simply maps the four actions (create, read, update and destroy) to RESTful HTTP verbs. For example, let's set up a Model with an inline RestProxy

Ext.regModel('User', { fields: ['id', 'name', 'email'],

proxy: { type: 'rest', url : '/users' } }); Now we can create a new User instance and save it via the RestProxy. Doing this will cause the Proxy to send a POST request to '/users':

var user = Ext.ModelManager.create({name: 'Ed Spencer', email: 'ed@se.nosp@m.ncha.nosp@m..com'}, 'User');

user.save(); //POST /users Let's expand this a little and provide a callback for the Ext.data.Model.save call to update the Model once it has been created. We'll assume the creation went successfully and that the server gave this user an ID of 123:

user.save({ success: function(user) { user.set('name', 'Khan Noonien Singh');

user.save(); //PUT /users/123 } }); Now that we're no longer creating a new Model instance, the request method is changed to an HTTP PUT, targeting the relevant url for that user. Now let's delete this user, which will use the DELETE method:

user.destroy(); //DELETE /users/123

Finally, when we perform a load of a Model or Store, RestProxy will use the GET method:

//1. Load via Store

//the Store automatically picks up the Proxy from the User model var store = new Ext.data.Store({ model: 'User' });

store.load(); //GET /users

//2. Load directly from the Model

//GET /users/123 Ext.ModelManager.getModel('User').load(123, { success: function(user) { console.log(user.getId()); //outputs 123 } }); Url generation

RestProxy is able to automatically generate the urls above based on two configuration options - appendId and format. If appendId is true (it is by default) then RestProxy will automatically append the ID of the Model instance in question to the configured url, resulting in the '/users/123' that we saw above.

If the request is not for a specific Model instance (e.g. loading a Store), the url is not appended with an id. RestProxy will automatically insert a '/' before the ID if one is not already present.

new Ext.data.proxy.Rest({ url: '/users', appendId: true //default });

// Collection url: /users // Instance url : /users/123 RestProxy can also optionally append a format string to the end of any generated url:

new Ext.data.proxy.Rest({ url: '/users', format: 'json' });

// Collection url: /users.json // Instance url : /users/123.json If further customization is needed, simply implement the buildUrl method and add your custom generated url onto the Request object that is passed to buildUrl. See RestProxy's implementation for an example of how to achieve this.

Note that RestProxy inherits from AjaxProxy, which already injects all of the sorter, filter, group and paging options into the generated url. See the AjaxProxy docs for more details.

Constructor & Destructor Documentation

◆ RestProxy() [1/2]

Ext.Net.RestProxy.RestProxy ( )
inline

◆ RestProxy() [2/2]

Ext.Net.RestProxy.RestProxy ( Config  config)
inline

Member Function Documentation

◆ operator RestProxy()

static implicit Ext.Net.RestProxy.operator RestProxy ( RestProxy.Config  config)
inlinestatic

◆ ToBuilder()

RestProxy.Builder Ext.Net.RestProxy.ToBuilder ( )
inline

◆ ToNativeBuilder()

override IControlBuilder Ext.Net.RestProxy.ToNativeBuilder ( )
inlinevirtual

Reimplemented from Ext.Net.AjaxProxy.

Property Documentation

◆ ActionMethodsProxy

override string Ext.Net.RestProxy.ActionMethodsProxy
getprotected

◆ AppendId

virtual bool Ext.Net.RestProxy.AppendId
getset

True to automatically append the ID of a Model instance when performing a request based on that single instance. See RestProxy intro docs for more details. Defaults to true.

◆ BatchActions

override bool Ext.Net.RestProxy.BatchActions
getset

True to batch actions of a particular type when synchronizing the store. Defaults to false.

◆ ConfigOptions

override ConfigOptionsCollection Ext.Net.RestProxy.ConfigOptions
get

◆ Format

virtual string Ext.Net.RestProxy.Format
getset

Optional data format to send to the server when making any request (e.g. 'json'). See the RestProxy intro docs for full details. Defaults to undefined.

◆ InstanceOf

override string Ext.Net.RestProxy.InstanceOf
get

◆ Type

override string Ext.Net.RestProxy.Type
getprotected

Alias


The documentation for this class was generated from the following files: