DataStore.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. // wrapped by build app
  2. define("dojox/wire/ml/DataStore", ["dijit","dojo","dojox","dojo/require!dijit/_Widget,dojox/wire/_base"], function(dijit,dojo,dojox){
  3. dojo.provide("dojox.wire.ml.DataStore");
  4. dojo.require("dijit._Widget");
  5. dojo.require("dojox.wire._base");
  6. dojo.declare("dojox.wire.ml.DataStore", dijit._Widget, {
  7. // summary:
  8. // A widget for a data store
  9. // description:
  10. // This widget represents a data store of 'storeClass' attribute.
  11. // storeClass:
  12. // A class name of a data store
  13. storeClass: "",
  14. postCreate: function(){
  15. // summary:
  16. // Call _createStore()
  17. // description:
  18. // See _createStore().
  19. this.store = this._createStore();
  20. },
  21. _createStore: function(){
  22. // summary:
  23. // Create a data store
  24. // desription:
  25. // A data store of 'storeClass' is created with arguments
  26. // specified with attributes.
  27. // returns:
  28. // A data store
  29. if(!this.storeClass){
  30. return null; //null
  31. }
  32. var storeClass = dojox.wire._getClass(this.storeClass);
  33. if(!storeClass){
  34. return null; //null
  35. }
  36. var args = {};
  37. var attributes = this.domNode.attributes;
  38. for(var i = 0; i < attributes.length; i++){
  39. var a = attributes.item(i);
  40. if(a.specified && !this[a.nodeName]){
  41. args[a.nodeName] = a.nodeValue;
  42. }
  43. }
  44. return new storeClass(args); //Object
  45. },
  46. getFeatures: function(){
  47. // summary:
  48. // Call getFeatures() method of a data store
  49. // description:
  50. // See dojo.data.api.Read.getFeatures().
  51. // returns:
  52. // A features object
  53. return this.store.getFeatures(); //Object
  54. },
  55. fetch: function(/*Object*/request){
  56. // summary:
  57. // Call fetch() method of a data store
  58. // description:
  59. // See dojo.data.api.Read.fetch().
  60. // request:
  61. // A request object
  62. // returns:
  63. // A request object
  64. return this.store.fetch(request); //Object
  65. },
  66. save: function(/*Object*/args){
  67. // summary:
  68. // Call save() method of a data store
  69. // description:
  70. // See dojo.data.api.Write.save().
  71. // args:
  72. // A save arguments object
  73. this.store.save(args);
  74. },
  75. newItem: function(/*Object*/args){
  76. // summary:
  77. // Call newItem() method of a data store
  78. // description:
  79. // See dojo.data.api.Write.newItem().
  80. // args:
  81. // A new item arguments object
  82. // returns:
  83. // A new item
  84. return this.store.newItem(args); //Object
  85. },
  86. deleteItem: function(/*Object*/item){
  87. // summary:
  88. // Call deleteItem() method of a data store
  89. // description:
  90. // See dojo.data.api.Write.deleteItem().
  91. // returns:
  92. // A boolean
  93. return this.store.deleteItem(item); //Boolean
  94. },
  95. revert: function(){
  96. // summary:
  97. // Call revert() method of a data store
  98. // description:
  99. // See dojo.data.api.Write.revert().
  100. // returns:
  101. // A boolean
  102. return this.store.revert(); //Boolean
  103. }
  104. });
  105. });