The JsonRestStore will cause all saved modifications to be sent to the server using Rest commands (PUT, POST, or DELETE). When using a Rest store on a public network, it is important to implement proper security measures to control access to resources.
On the server side implementing a REST interface means providing GET, PUT, POST, and DELETE handlers.
These articles include more detailed information on using the JsonRestStore:
On the server side implementing a REST interface means providing GET, PUT, POST, and DELETE handlers.
These articles include more detailed information on using the JsonRestStore:
>Parameter | Type | Description |
---|---|---|
options | undefined | Keyword arguments The schema parameterThis is a schema object for this store. This should be JSON Schema format. The service parameterThis is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded The function should also have the following methods:
Note that it is critical that the service parses responses as JSON. If you are using dojox.rpc.Service, the easiest way to make sure this happens is to make the responses have a content type of application/json. If you are creating your own service, make sure you use handleAs: "json" with your XHR requests. The target parameterThis is the target URL for this Service store. This may be used in place of a service parameter to connect directly to RESTful URL without using a dojox.rpc.Service object. The idAttribute parameterDefaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index. The syncMode parameterSetting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary |
See the dojox/data/JsonRestStore reference documentation for more information.
Allow no trailing slash on target paths. This is generally discouraged since it creates prevents simple scalar values from being used a relative URLs. Disabled by default.
This parameter is used by the ServiceStore to estimate the total count. When paging is indicated in a fetch and the response includes the full number of items requested by the fetch's count parameter, then the total count will be estimated to be estimateCountFactor multiplied by the provided count. If this is 1, then it is assumed that the server does not support paging, and the response is the full set of items, where the total count is equal to the numer of items returned. If the server does support paging, an estimateCountFactor of 2 is a good value for estimating the total count It is also possible to override _processResults if the server can provide an exact total count.
Defaults to 'id'. The name of the attribute that holds an objects id. This can be a preexisting id provided by the server. If an ID isn't already provided when an object is fetched or added to the store, the autoIdentity system will generate an id for it and add it to the index.
Will load any schemas referenced content-type header or in Link headers
This is a schema object for this store. This should be JSON Schema format.
This is the service object that is used to retrieve lazy data and save results The function should be directly callable with a single parameter of an object id to be loaded
Setting this to true will set the store to using synchronous calls by default. Sync calls return their data immediately from the calling function, so callbacks are unnecessary. This will only work with a synchronous capable service.
Parameter | Type | Description |
---|---|---|
results | undefined | |
deferred | undefined |
Removes an object from the list of dirty objects This will prevent that object from being saved to the server on the next save
Parameter | Type | Description |
---|---|---|
object | undefined | The item to cancel changes on |
adds an item to the list of dirty items. This item contains a reference to the item itself as well as a cloned and trimmed version of old item for use with revert.
Parameter | Type | Description |
---|---|---|
item | undefined | |
_deleting | undefined |
Checks to see if 'item' has 'value' at 'attribute'
Parameter | Type | Description |
---|---|---|
item | Object | |
attribute | String | |
value | Anything |
deletes item and any references to that item from the store.
Parameter | Type | Description |
---|---|---|
item | undefined | item to delete |
See dojo/data/api/Read.fetch
Parameter | Type | Description |
---|---|---|
args | undefined | The queryOptions.cache parameterIf true, indicates that the query result should be cached for future use. This is only available if dojox.data.ClientFilter has been loaded before the ServiceStore The syncMode parameterIndicates that the call should be fetch synchronously if possible (this is not always possible) The clientFetch parameterThis is a fetch keyword argument for explicitly doing client side filtering, querying, and paging |
Gets the available attributes of an item's 'property' and returns it as an array.
Parameter | Type | Description |
---|---|---|
item | Object |
Gets the constructor for objects from this store
returns the attributes which are used to make up the identity of an item. Basically returns this.idAttribute
Parameter | Type | Description |
---|---|---|
item | undefined |
returns the label for an item. Just gets the "label" attribute.
Parameter | Type | Description |
---|---|---|
item | undefined |
returns an array of attributes that are used to create the label of an item
Parameter | Type | Description |
---|---|---|
item | undefined |
Returns the parent item (or query) for the given item
Parameter | Type | Description |
---|---|---|
item | undefined | The item to find the parent of |
Returns a reference to the JSON Schema
Will retrieve or create a store using the given options (the same options that are passed to JsonRestStore constructor. Returns a JsonRestStore instance
Parameter | Type | Description |
---|---|---|
options | undefined | See the JsonRestStore constructor |
Class | undefined | Constructor to use (for creating stores from JsonRestStore subclasses). This is optional and defaults to JsonRestStore. |
Gets the value of an item's 'property'
Parameter | Type | Description |
---|---|---|
item | Object | The item to get the value from |
property | String | property to look up value for |
defaultValue | value |
Optional the default value |
Gets the value of an item's 'property' and returns it. If this value is an array it is just returned, if not, the value is added to an array and that is returned.
Parameter | Type | Description |
---|---|---|
item | Object | |
property | String | property to look up value for |
Checks to see if item has attribute
Parameter | Type | Description |
---|---|---|
item | Object | |
attribute | String |
returns true if the item is marked as dirty.
Parameter | Type | Description |
---|---|---|
item | undefined |
Checks to see if a passed 'item' really belongs to this JsonRestStore.
Parameter | Type | Description |
---|---|---|
item | Object | The value to test for being an item |
anyStore | Boolean | If true, this will return true if the value is an item for any JsonRestStore, not just this instance |
Checks to see if the item is loaded.
Parameter | Type | Description |
---|---|---|
item | object |
Loads an item and calls the callback handler. Note, that this will call the callback handler even if the item is loaded. Consequently, you can use loadItem to ensure that an item is loaded is situations when the item may or may not be loaded yet. If you access a value directly through property access, you can use this to load a lazy value as well (doesn't need to be an item).
Parameter | Type | Description |
---|---|---|
args | undefined |
store.loadItem({ item: item, // this item may or may not be loaded onItem: function(item){ // do something with the item } });
adds a new item to the store at the specified point. Takes two parameters, data, and options.
Parameter | Type | Description |
---|---|---|
data | Object | The data to be added in as an item. |
parentInfo | undefined |
returns any modified data to its original state prior to a save();
Parameter | Type | Description |
---|---|---|
kwArgs | undefined |
|
Saves the dirty data using REST Ajax methods. See dojo/data/api/Write for API.
Parameter | Type | Description |
---|---|---|
kwArgs | undefined |
|
sets 'attribute' on 'item' to 'value'
Parameter | Type | Description |
---|---|---|
item | undefined | |
attribute | undefined | |
value | undefined |
sets 'attribute' on 'item' to 'value' value must be an array.
Parameter | Type | Description |
---|---|---|
item | undefined | |
attribute | undefined | |
values | undefined |
unsets 'attribute' on 'item'
Parameter | Type | Description |
---|---|---|
item | undefined | |
attribute | undefined |
store.loadItem({ item: item, // this item may or may not be loaded onItem: function(item){ // do something with the item } });
store.loadItem({ item: item, // this item may or may not be loaded onItem: function(item){ // do something with the item } });
store.loadItem({ item: item, // this item may or may not be loaded onItem: function(item){ // do something with the item } });