Class YAHOO.widget.DataSource

Object

   |

   +--YAHOO.widget.DataSource

Direct Known Subclasses:
YAHOO.widget.DS_XHR, YAHOO.widget.DS_JSArray, YAHOO.widget.DS_JSFunction

class YAHOO.widget.DataSource

Field Summary [top]

Object cacheFlushEvent
Fired when the local cache is flushed. 
Object cacheQueryEvent
Fired when a query is made to the local cache. 
Object dataErrorEvent
Fired when an error is encountered with the live data source. 
constant ERROR_DATANULL
Error message for null data responses. 
constant ERROR_DATAPARSE
Error message for data responses with parsing errors. 
Object getCachedResultsEvent
Fired when data is retrieved from the local cache. 
Object getResultsEvent
Fired when data is retrieved from the live data source. 
number maxCacheEntries
Max size of the local cache. 
Object queryEvent
Fired when a query is made to the live data source. 
boolean queryMatchCase
Data source query case-sensitivity matching. 
boolean queryMatchContains
Use this to equate cache matching with the type of matching done by your live data source. 
boolean queryMatchSubset
Data source query subset matching. 

Constructor Summary [top]

YAHOO.widget.DataSource
Class providing encapsulation of a data source. 

Method Summary [top]

void doQuery (<object> oCallbackFn, <string> sQuery, <object> oParent)
Abstract method implemented by subclasses to make a query to the live data source. 
void flushCache ()
Flushes cache. 
void getResults (<object> oCallbackFn, <string> sQuery, <object> oParent)
Retrieves query results, first checking the local cache, then making the query request to the live data source as defined by the function doQuery. 
string toString ()
Public accessor to the unique name of the data source instance. 

Field Detail [top]

cacheFlushEvent

Object   cacheFlushEvent
Fired when the local cache is flushed. Subscribers receive the following array :
- args[0] The data source instance

cacheQueryEvent

Object   cacheQueryEvent
Fired when a query is made to the local cache. Subscribers receive the following array:
- args[0] The data source instance - args[1] The requesting object - args[2] The query string

dataErrorEvent

Object   dataErrorEvent
Fired when an error is encountered with the live data source. Subscribers receive the following array:
- args[0] The data source instance - args[1] The requesting object - args[2] The query string - args[3] Error message string

ERROR_DATANULL

constant   ERROR_DATANULL
Error message for null data responses.

ERROR_DATAPARSE

constant   ERROR_DATAPARSE
Error message for data responses with parsing errors.

getCachedResultsEvent

Object   getCachedResultsEvent
Fired when data is retrieved from the local cache. Subscribers receive the following array :
- args[0] The data source instance - args[1] The requesting object - args[2] The query string - args[3] Array of result objects

getResultsEvent

Object   getResultsEvent
Fired when data is retrieved from the live data source. Subscribers receive the following array:
- args[0] The data source instance - args[1] The requesting object - args[2] The query string - args[3] Array of result objects

maxCacheEntries

number   maxCacheEntries
Max size of the local cache. Set to 0 to turn off caching. Caching is useful to reduce the number of server connections. Recommended only for data sources that return comprehensive results for queries or when stale data is not an issue. Default: 15.

queryEvent

Object   queryEvent
Fired when a query is made to the live data source. Subscribers receive the following array:
- args[0] The data source instance - args[1] The requesting object - args[2] The query string

queryMatchCase

boolean   queryMatchCase
Data source query case-sensitivity matching. If caching is on and queryMatchCase is true, queries will only return results for case-sensitive matches. Default: false.

queryMatchContains

boolean   queryMatchContains
Use this to equate cache matching with the type of matching done by your live data source. If caching is on and queryMatchContains is true, the cache returns results that "contain" the query string. By default, queryMatchContains is set to false, meaning the cache only returns results that "start with" the query string. Default: false.

queryMatchSubset

boolean   queryMatchSubset
Data source query subset matching. If caching is on and queryMatchSubset is true, substrings of queries will return matching cached results. For instance, if the first query is for "abc" susequent queries that start with "abc", like "abcd", will be queried against the cache, and not the live data source. Recommended only for data sources that return comprehensive results for queries with very few characters. Default: false.

Constructor Detail [top]

YAHOO.widget.DataSource

YAHOO.widget.DataSource ()
Class providing encapsulation of a data source.

Method Detail [top]

doQuery

void doQuery (<object> oCallbackFn, <string> sQuery, <object> oParent)
Abstract method implemented by subclasses to make a query to the live data source. Must call the callback function with the response returned from the query. Populates cache (if enabled).
Parameters:
oCallbackFn - Callback function implemented by oParent to which to return results
sQuery - Query string
oParent - The object instance that has requested data

flushCache

void flushCache ()
Flushes cache.

getResults

void getResults (<object> oCallbackFn, <string> sQuery, <object> oParent)
Retrieves query results, first checking the local cache, then making the query request to the live data source as defined by the function doQuery.
Parameters:
oCallbackFn - Callback function defined by oParent object to which to return results
sQuery - Query string
oParent - The object instance that has requested data

toString

string toString ()
Public accessor to the unique name of the data source instance.
Returns:
Unique name of the data source instance