ds.JsonDataSource Extends goog.ds.JsDataSource
Data source whose backing is a JSON-like service, in which retreiving the resource specified by URL with the additional parameter callback. The resource retreived is executable JavaScript that makes a call to the named function with a JavaScript object literal as the only parameter. Example URI could be: http://www.google.com/data/search?q=monkey&callback=mycb which might return the JS: mycb({searchresults: [{uri: 'http://www.monkey.com', title: 'Site About Monkeys'}]}); TODO(user): Evaluate using goog.net.Jsonp here. A URI of an empty string will mean that no request is made and the data source will be a data source with no child nodes

Inheritance

Constructor

goog.ds.JsonDataSource(urinameopt_callbackParamName)

Parameters

uri : string | goog.Uri
URI for the request.
name : string
Name of the datasource.
opt_callbackParamName : string=
The parameter name that is used to specify the callback. Defaults to 'callback'.

Instance Methods

Public Protected Private
getLoadState() goog.ds.LoadState
Gets the state of the backing data for this node
Returns: goog.ds.LoadState  The state.
code »
load()
Load or reload the backing data for this node. Fires the JsonDataSource
code »
receiveData(obj)
Receives data from a Json request
Arguments:
obj : Object
The JSON data.
code »
createChildNodes_(opt_force)
Creates the DataNodeList with the child nodes for this element. Allows for only building list as needed.
Arguments:
opt_force : boolean=
Whether to force recreating child nodes, defaults to false.
code »
get()
No description.
code »
getChildNode(nameopt_canCreate) goog.ds.DataNode
Gets a named child node of the current node
Arguments:
name : string
The node name.
opt_canCreate : boolean=
If true, can create child node.
Returns: goog.ds.DataNode  The child node, or null if no node of this name exists.
code »
getChildNodeValue(name) Object
Gets the value of a child node
Arguments:
name : string
The node name.
Returns: Object  The value of the node, or null if no value or the child node doesn't exist.
code »
getChildNodes()
TODO(user) revisit lazy creation.
code »
getDataName() string
Get the name of the node relative to the parent node
Returns: string  The name of the node.
code »
getDataPath() string
Gets the a qualified data path to this node
Returns: string  The data path.
code »
getLoadState() goog.ds.LoadState
Gets the state of the backing data for this node TODO(user) Discuss null value handling
Returns: goog.ds.LoadState  The state.
code »
isList() boolean
Whether the value of this node is a homogeneous list of data
Returns: boolean  True if a list.
code »
load()
Load or reload the backing data for this node
code »
set(value)
Set the value of the node
Arguments:
value : *
The new value of the node.
code »
setChildNode(namevalue) Object
Sets a named child node of the current node. If value is null, removes the child node.
Arguments:
name : string
The node name.
value : Object
The value to set, can be DataNode, object, property, or null.
Returns: Object  The child node, if set.
code »
setDataName(dataName)
Setthe name of the node relative to the parent node
Arguments:
dataName : string
The name of the node.
code »
setIsList_(isList)
Set this data source to use list semantics. List data sources: - Are assumed to have child nodes of all of the same type of data - Fire data changes on the root node of the list whenever children are added or removed
Arguments:
isList : ?boolean
True to use list semantics.
code »
setRoot(root)
Sets the root JS object
Arguments:
root : Object
The root JS object. Can be null.
code »
get(var_args) *
Get the value of the node
Arguments:
var_args : ?...
Do not check arity of arguments, because some subclasses require args.
Returns: *  The value of the node, or null if no value.
code »
getChildNode(nameopt_canCreate) goog.ds.DataNode
Gets a named child node of the current node
Arguments:
name : string
The node name.
opt_canCreate : boolean=
Whether to create a child node if it does not exist.
Returns: goog.ds.DataNode  The child node, or null if no node of this name exists.
code »
getChildNodeValue(name) *
Gets the value of a child node
Arguments:
name : string
The node name.
Returns: *  The value of the node, or null if no value or the child node doesn't exist.
code »
getChildNodes(opt_selector) !goog.ds.DataNodeList
Gets all of the child nodes of the current node. Should return an empty DataNode list if no child nodes.
Arguments:
opt_selector : string=
String selector to choose child nodes.
Returns: !goog.ds.DataNodeList  The child nodes.
code »
getDataName() string
Get the name of the node relative to the parent node
Returns: string  The name of the node.
code »
getDataPath() string
Gets the a qualified data path to this node
Returns: string  The data path.
code »
getLoadState() goog.ds.LoadState
Gets the state of the backing data for this node
Returns: goog.ds.LoadState  The state.
code »
isList() boolean
Whether the value of this node is a homogeneous list of data
Returns: boolean  True if a list.
code »
set(value)
Set the value of the node
Arguments:
value : *
The new value of the node.
code »
setChildNode(namevalue) Object
Sets a named child node of the current node.
Arguments:
name : string
The node name.
value : Object
The value to set, can be DataNode, object, property, or null. If value is null, removes the child node.
Returns: Object  The child node, if the node was set.
code »
setDataName(name)
Set the name of the node relative to the parent node
Arguments:
name : string
The name of the node.
code »

Instance Properties

callbackParamName_ :
This is the callback parameter name that is added to the uri.
Code »
constructor :
No description.
Code »
loadState_ :
No description.
Code »
uri_ : goog.Uri
No description.
Code »
dataName_ :
No description.
Code »
parent_ :
No description.
Code »
root_ :
The root JS object. Can be null.
Code »
load :
Load or reload the backing data for this node
Code »

Static Properties

goog.ds.JsonDataSource.superClass_ :
No description.
Code »

Package ds

Package Reference