<dataset>
An in-memory xml-style data hierarchy.
A <dataset> tag defines a
local dataset. The name of the dataset is used in the datapath
attribute of a view.
The src attribute of the <dataset> element specifies whether the data is compiled into the
application or fetched at runtime:
- If the src attribute is a URL, the value of
the dataset is the XML data that a request to the URL named by the
src attribute returns when the application is run.
- If the src
attribute is a pathname, the value of the dataset is the content of
the XML file that the pathname refers to, and is compiled into the
application.
- If the src attribute is not present, the value of the
dataset is the content of the
<dataset> element.
All data in an OpenLazlo application is contained within one or more datasets. A given dataset usually represents a single
conceptual set that may or may not be modified or reloaded during the execution of the application.
The data within a dataset is accessed using a datapointer or a instance of one of its subclasses.
Datasets can represent
- local data (i.e. data which is static after compile time), or
- http-data (data which is returned as XML over HTTP)
If a dataset is not explictly contained within in a lz.DataProvider, it will make an instance of datasource and be contained inside that. A dataset can be populated or re-poplulated at runtime
by calling doRequest on the dataset. The result of the request is then returned to the application and the dataset's
ondata
event is run. Any <datapointer> that is bound to the dataset will also run its
ondata
event at this time as well.
See the Developers's Guide for more discussion of data and datasets.
Datasets in SOLO applications. Datasets are implemented differently in proxied and SOLO applications, with slight differences in functionality. For example,
in SOLO applications in the SWF8 and SWF9 runtimes is it not possible to retrieve http response headers. Also, white space
may be handled differently. See the Developer's Guide.
The example below makes a request of the cgi script on Laszlo's website that serves up weather information in xml form.
Example 25. Making a request using a dataset
<canvas height="250" width="800" debug="true">
<debug y="100"/>
<dataset type="http" name="weatherdata" src="http://www.laszlosystems.com/cgi-pub/weather.cgi"/>
<view>
<inputtext width="90" name="t">zip</inputtext>
<button> submit
<handler name="onclick"> var d = canvas.datasets.weatherdata;
Debug.write("sending request for weather data.");
d.setQueryString({zip : parent.t.getText()});
d.doRequest();
</handler>
</button>
<datapointer xpath="weatherdata:/weather">
<handler name="ondata">
var duplicate_pointer = this.dupePointer();
duplicate_pointer.selectChild();
while (duplicate_pointer.selectNext()){
Debug.write(duplicate_pointer.serialize());
}
</handler>
</datapointer>
<simplelayout axis="x"/>
</view>
</canvas>
Attributes inherited from <node>
classroot, cloneManager, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, subnodes
Methods
-
-
Stops the load of the dataset's current request
-
| clearRequestHeaderParams() |
|---|
-
dataset.clearRequestHeaderParams();
Clears all request header parameters which were set from
setHeader
-
-
dataset.doRequest(ignore);
Does a request immediately using the current values. If autorequest is true,
this method is called automatically when values change.
-
-
dataset.getAllResponseHeaders();
Returns all response headers as an object of name/value pairs, or false
if there were none.
-
-
dataset.getErrorString();
Returns an error string if there was an error, or
undefined if there was none.
-
-
Returns the number of miliseconds it took to load the dataset's request
-
-
Returns an lz.Param object holding any set request parameters for the
dataset.
-
-
Returns a datapointer pointing to the root of the dataset.
-
-
dataset.getQueryString();
Returns the querystring attribute of the dataset, if there is one
-
-
dataset.getRequestHeaderParams();
Retrieves the lz.Param object which represents the headers sent with
the dataset's last request
-
-
dataset.getResponseHeader(name : String);
Returns the value for the specified response header, or
null
if there was no header with that name.
-
-
Return the src attribute of the dataset, if one was given.
-
-
dataset.setHeader(k : String, val : String);
Sets a header for the next request
-
-
dataset.setPostBody(str : String);
![[Caution]](images/caution.png) |
This method is deprecated |
| Use setAttribute('postbody', ...) instead. |
Sets the raw content of a POST body.
This replaces the old "lzpostbody" convention for passing raw POST data.
-
-
dataset.setProxyRequests(val : String);
![[Caution]](images/caution.png) |
This method is deprecated |
| Use setAttribute('proxied', ...) instead. |
Sets whether or not the dataset makes its request directly to the target server
or via the LPS server proxy.
-
-
dataset.setQueryParam(key : String, val : String);
Sets a named query parameter to the given value. The query parameters are
sent with every request. The key 'lzpostbody' has a specific interpretation,
see setQueryType() for details.
-
-
dataset.setQueryParams(obj : Object);
Sets multiple query parameters from using the keys in the argument as keys
and the values of those keys as values. This method can also be used to
clear the query params, by passing null to it.
-
-
dataset.setQueryString(s : String);
Sets the querystring parameter of the dataset to the given
string. If an object is given instead of a string, the object will be
automatically converted to a string and used instead. The dataset's
querystring will be pre-pended to any request made for the dataset.
-
-
dataset.setQueryType(reqtype : String);
![[Caution]](images/caution.png) |
This method is deprecated |
| Use setAttribute('querytype', ...) instead. |
Sets the query type of for the datasource to one of "POST" or "GET"
by calling the method of the same name on this dataset's datasource.
Note that this controls how the LPS server makes a request of the backend, as well
as how the client communicates with the LPS
-
-
dataset.setRequest(b : Boolean);
![[Caution]](images/caution.png) |
This method is deprecated |
| Use setAttribute('request', ...) instead. |
Sets whether or not the dataset makes its request upon initialization
-
-
dataset.setSrc(src : String);
![[Caution]](images/caution.png) |
This method is deprecated |
| Use setAttribute('src', ...) instead. |
Sets the src attribute of the data request.
Methods inherited from <node>
animate, applyConstraint, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getAttribute, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setData, setDatapath, setOption, setSelected, updateData
Class Methods
-
-
lz.dataset.queryStringToTable(query);
Produce a hash table of key-value pairs.
In the case of a duplicated key, creates an array of values.