Warning: Use of undefined constant Symbol - assumed 'Symbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215 Warning: Use of undefined constant JavaScriptSymbol - assumed 'JavaScriptSymbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215

dojox/data/JsonRestStore.js

  • Provides:

    • dojox.data.JsonRestStore
  • Requires:

    • dojox.rpc.JsonRest in common
    • dojox.data.ServiceStore in common
  • dojox.data.JsonRestStore

    • type
      Function
    • chains:
      • dojox.data.ServiceStore: (prototype)
      • dojox.data.ServiceStore: (call)
    • parameters:
      • options: (typeof Keyword)
        arguments
        
        The *schema* parameter
        This is a schema object for this store. This should be JSON Schema format.
        
        The *service* parameter
        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
        The function should also have the following methods:
        put(id,value) - puts the value at the given id
        post(id,value) - posts (appends) the value at the given id
        delete(id) - deletes the value corresponding to the given id
        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* parameter
        This 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* parameter
        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.
        
        The *syncMode* parameter
        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
    • summary
      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.
      
      
      Write API Support
      
      
      Notifcation Support
    • description
      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.
      GET - Retrieve an object or array/result set, this can be by id (like /table/1) or with a
      query (like /table/?name=foo).
      PUT - This should modify a object, the URL will correspond to the id (like /table/1), and the body will
      provide the modified object
      POST - This should create a new object. The URL will correspond to the target store (like /table/)
      and the body should be the properties of the new object. The server's response should include a
      Location header that indicates the id of the newly created object. This id will be used for subsequent
      PUT and DELETE requests. JsonRestStore also includes a Content-Location header that indicates
      the temporary randomly generated id used by client, and this location is used for subsequent
      PUT/DELETEs if no Location header is provided by the server or if a modification is sent prior
      to receiving a response from the server.
      DELETE - This should delete an object by id.
      These articles include more detailed information on using the JsonRestStore:
      http://www.sitepen.com/blog/2008/06/13/restful-json-dojo-data/
      http://blog.medryx.org/2008/07/24/jsonreststore-overview/
    • example
      A JsonRestStore takes a REST service or a URL and uses it the remote communication for a
      read/write dojo.data implementation. A JsonRestStore can be created with a simple URL like:
      	new JsonRestStore({target:"/MyData/"});
    • example
      To use a JsonRestStore with a service, you should create a
      service with a REST transport. This can be configured with an SMD:
      	{
      		services: {
      			jsonRestStore: {
      				transport: "REST",
      				envelope: "URL",
      				target: "store.php",
      				contentType:"application/json",
      				parameters: [
      					{name: "location", type: "string", optional: true}
      				]
      			}
      		}
      	}
      The SMD can then be used to create service, and the service can be passed to a JsonRestStore. For example:
      	var myServices = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.tests.resources", "test.smd"));
      	var jsonStore = new dojox.data.JsonRestStore({service:myServices.jsonRestStore});
    • example
      The JsonRestStore also supports lazy loading. References can be made to objects that have not been loaded.
      For example if a service returned:
      	{"name":"Example","lazyLoadedObject":{"$ref":"obj2"}}
      And this object has accessed using the dojo.data API:
      	var obj = jsonStore.getValue(myObject,"lazyLoadedObject");
      The object would automatically be requested from the server (with an object id of "obj2").
  • dojox.data.JsonRestStore.constructor

    • constructor - constructor
    • type
      Function
    • parameters:
      • options: (typeof Keyword)
        arguments
        
        The *schema* parameter
        This is a schema object for this store. This should be JSON Schema format.
        
        The *service* parameter
        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
        The function should also have the following methods:
        put(id,value) - puts the value at the given id
        post(id,value) - posts (appends) the value at the given id
        delete(id) - deletes the value corresponding to the given id
        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* parameter
        This 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* parameter
        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.
        
        The *syncMode* parameter
        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
    • summary
      JsonRestStore is a Dojo Data store interface to JSON HTTP/REST web
      storage services that support read and write through GET, PUT, POST, and DELETE.
    • description
      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.
      GET - Retrieve an object or array/result set, this can be by id (like /table/1) or with a
      query (like /table/?name=foo).
      PUT - This should modify a object, the URL will correspond to the id (like /table/1), and the body will
      provide the modified object
      POST - This should create a new object. The URL will correspond to the target store (like /table/)
      and the body should be the properties of the new object. The server's response should include a
      Location header that indicates the id of the newly created object. This id will be used for subsequent
      PUT and DELETE requests. JsonRestStore also includes a Content-Location header that indicates
      the temporary randomly generated id used by client, and this location is used for subsequent
      PUT/DELETEs if no Location header is provided by the server or if a modification is sent prior
      to receiving a response from the server.
      DELETE - This should delete an object by id.
      These articles include more detailed information on using the JsonRestStore:
      http://www.sitepen.com/blog/2008/06/13/restful-json-dojo-data/
      http://blog.medryx.org/2008/07/24/jsonreststore-overview/
    • example
      A JsonRestStore takes a REST service or a URL and uses it the remote communication for a
      read/write dojo.data implementation. A JsonRestStore can be created with a simple URL like:
      	new JsonRestStore({target:"/MyData/"});
    • example
      To use a JsonRestStore with a service, you should create a
      service with a REST transport. This can be configured with an SMD:
      	{
      		services: {
      			jsonRestStore: {
      				transport: "REST",
      				envelope: "URL",
      				target: "store.php",
      				contentType:"application/json",
      				parameters: [
      					{name: "location", type: "string", optional: true}
      				]
      			}
      		}
      	}
      The SMD can then be used to create service, and the service can be passed to a JsonRestStore. For example:
      	var myServices = new dojox.rpc.Service(dojo.moduleUrl("dojox.rpc.tests.resources", "test.smd"));
      	var jsonStore = new dojox.data.JsonRestStore({service:myServices.jsonRestStore});
    • example
      The JsonRestStore also supports lazy loading. References can be made to objects that have not been loaded.
      For example if a service returned:
      	{"name":"Example","lazyLoadedObject":{"$ref":"obj2"}}
      And this object has accessed using the dojo.data API:
      	var obj = jsonStore.getValue(myObject,"lazyLoadedObject");
      The object would automatically be requested from the server (with an object id of "obj2").
  • dojox.data.JsonRestStore.loadReferencedSchema

    • type
      Object
  • dojox.data.JsonRestStore.idAsRef

    • type
      bool
  • dojox.data.JsonRestStore.referenceIntegrity

    • type
      Object
  • dojox.data.JsonRestStore.target

    • type
      String
  • dojox.data.JsonRestStore.allowNoTrailingSlash

    • type
      bool
  • dojox.data.JsonRestStore.newItem

    • parameters:
      • data: (typeof object)
        The data to be added in as an item.
      • parentInfo
    • summary
      adds a new item to the store at the specified point.
      Takes two parameters, data, and options.
    • type
      Function
  • dojox.data.JsonRestStore.deleteItem

    • parameters:
      • item: (typeof item)
        to delete
    • summary
      deletes item and any references to that item from the store.
    • type
      Function
  • dojox.data.JsonRestStore.changing

    • parameters:
      • item
      • _deleting
    • summary
      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.
    • type
      Function
  • dojox.data.JsonRestStore.setValue

    • parameters:
      • item
      • attribute
      • value
    • summary
      sets 'attribute' on 'item' to 'value'
    • type
      Function
  • dojox.data.JsonRestStore.setValues

    • parameters:
      • item
      • attribute
      • values
    • summary
      sets 'attribute' on 'item' to 'value' value
      must be an array.
    • type
      Function
  • dojox.data.JsonRestStore.unsetAttribute

    • parameters:
      • item
      • attribute
    • summary
      unsets 'attribute' on 'item'
    • type
      Function
  • dojox.data.JsonRestStore.save

    • parameters:
      • kwArgs
    • summary
      Saves the dirty data using REST Ajax methods. See dojo.data.api.Write for API.
      
      kwArgs.global:
      This will cause the save to commit the dirty data for all
      JsonRestStores as a single transaction.
      
      kwArgs.revertOnError
      This will cause the changes to be reverted if there is an
      error on the save. By default a revert is executed unless
      a value of false is provide for this parameter.
      
      kwArgs.incrementalUpdates
      For items that have been updated, if this is enabled, the server will be sent a POST request
      with a JSON object containing the changed properties. By default this is
      not enabled, and a PUT is used to deliver an update, and will include a full
      serialization of all the properties of the item/object.
      If this is true, the POST request body will consist of a JSON object with
      only the changed properties. The incrementalUpdates parameter may also
      be a function, in which case it will be called with the updated and previous objects
      and an object update representation can be returned.
      
      kwArgs.alwaysPostNewItems
      If this is true, new items will always be sent with a POST request. By default
      this is not enabled, and the JsonRestStore will send a POST request if
      the item does not include its identifier (expecting server assigned location/
      identifier), and will send a PUT request if the item does include its identifier
      (the PUT will be sent to the URI corresponding to the provided identifier).
    • type
      Function
  • dojox.data.JsonRestStore.serverVersion

  • dojox.data.JsonRestStore.revert

    • parameters:
      • kwArgs
    • type
      Function
  • dojox.data.JsonRestStore.isDirty

    • parameters:
      • item
    • type
      Function
  • dojox.data.JsonRestStore.isItem

    • parameters:
      • item: (typeof object)
        The value to test for being an item
      • anyStore: (typeof boolean)
        If true, this will return true if the value is an item for any JsonRestStore,
        not just this instance
    • summary
      Checks to see if a passed 'item'
      really belongs to this JsonRestStore.
    • type
      Function
  • dojox.data.JsonRestStore._doQuery

    • parameters:
      • args
    • returns
      don't change anything, and deal with the stupid post-commit lint complaints
    • type
      Function
  • dojox.data.JsonRestStore._processResults

    • parameters:
      • results
      • deferred
    • type
      Function
  • dojox.data.JsonRestStore.getConstructor

    • summary
      Gets the constructor for objects from this store
    • type
      Function
  • dojox.data.JsonRestStore.getIdentity

    • parameters:
      • item
    • returns
      String
    • type
      Function
  • dojox.data.JsonRestStore.fetchItemByIdentity

    • parameters:
      • args
    • type
      Function
  • dojox.data.JsonRestStore.onSet

    • type
      Function
  • dojox.data.JsonRestStore.onNew

    • type
      Function
  • dojox.data.JsonRestStore.onDelete

    • type
      Function
  • dojox.data.JsonRestStore.getFeatures

    • summary
      return the store feature set
    • type
      Function
  • dojox.data.JsonRestStore.getParent

    • parameters:
      • item: (typeof The)
        item to find the parent of
    • summary
      Returns the parent item (or query) for the given item
    • type
      Function
  • dojox.data.JsonRestStore.idAttribute

    • type
      String
  • dojox.data.JsonRestStore.service

    • type
      Object
  • dojox.data.JsonRestStore.schema

    • type
      Object
  • dojox.data.JsonRestStore.service._schema

    • type
      Object
  • dojox.data.JsonRestStore.service._store

    • type
      Object
  • dojox.data.JsonRestStore.service.idAsRef

  • dojox.data.JsonRestStore.schema._idAttr

  • dojox.data.JsonRestStore._constructor

    • parameters:
      • data
    • type
      Function
  • dojox.data.JsonRestStore._constructor.prototype

  • dojox.data.JsonRestStore._index

  • dojox.data.JsonRestStore.getStore

    • parameters:
      • options: (typeof See)
        the JsonRestStore constructor
      • Class: (typeof Constructor)
        to use (for creating stores from JsonRestStore subclasses).
        This is optional and defaults to JsonRestStore.
    • summary
      Will retrieve or create a store using the given options (the same options
      that are passed to JsonRestStore constructor. Returns a JsonRestStore instance
    • type
      Function
  • dojox.data._getStoreForItem

    • parameters:
      • item
    • type
      Function
  • dojox.json.ref._useRefs

    • type
      Object
  • dojox.data

    • type
      Object
  • dojox

    • type
      Object