datasource-local.js revision 3cd3e1a007f7fd6874030808f97ef48e3a950b40
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * The DataSource utility provides a common configurable interface for widgets to
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * access a variety of data, from JavaScript arrays to online database servers.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @module datasource
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * Base class for the YUI DataSource utility.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @class DataSource.Local
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @extends Base
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @constructor
9df1de8309feb43d162df756c9290ce3afab802aDirk HoganDSLocal = function() {
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan DSLocal.superclass.constructor.apply(this, arguments);
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan /////////////////////////////////////////////////////////////////////////////
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan // DataSource static properties
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan /////////////////////////////////////////////////////////////////////////////
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * Class name.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @property NAME
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @type String
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @value "DataSource.Local"
564945e59b60a40c3b9458177b2ff63e2947686cPeter Major /////////////////////////////////////////////////////////////////////////////
954d71f34d584a7bcc51a5df9933427542081d62Dirk Hogan // DataSource Attributes
954d71f34d584a7bcc51a5df9933427542081d62Dirk Hogan /////////////////////////////////////////////////////////////////////////////
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @attribute source
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @description Pointer to live data.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @type MIXED
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @default null
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * Global transaction counter.
addc51736ee961d7b52d048021139920d4364671Neil Madden * @property DataSource._tId
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @type Number
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan * @default 0
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan * Executes a given callback. The third param determines whether to execute
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan * @method DataSource.issueCallback
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan * @param callback {Object} The callback object.
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan * @param params {Array} params to be passed to the callback method
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan * @param error {Boolean} whether an error occurred
6057736124e265febf1603affd1ec9be4428d99dDirk Hogan issueCallback: function (e) {
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan callbackFunc = (e.error && e.callback.failure) || e.callback.success;
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * Internal init() handler.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @method initializer
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @param config {Object} Config object.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * Internal destroy() handler.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @method destructor
9d406c6b25ce9f6bf266b077443e723b95962914Dirk Hogan destructor: function() {
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * This method creates all the events for this module.
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * @method _initEvents
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * Fired when a data request is received.
56f76965098d6cc3ae531ce0a73bda588abdf1d3Dirk Hogan * @event request
56f76965098d6cc3ae531ce0a73bda588abdf1d3Dirk Hogan * @param e {Event.Facade} Event Facade.
56f76965098d6cc3ae531ce0a73bda588abdf1d3Dirk Hogan * @param o {Object} Object with the following properties:
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * <dt>tId (Number)</dt> <dd>Unique transaction ID.</dd>
9df1de8309feb43d162df756c9290ce3afab802aDirk Hogan * <dt>request (Object)</dt> <dd>The request.</dd>
_defRequestFn: function(e) {
if(e.error) {
_defDataFn: function(e) {
response = {
_defResponseFn: function(e) {
return tId;