Name

dataset (LzDataset) — An in-memory xml-style data hierarchy.

Synopsis

LZX: dataset
JavaScript: LzDataset
Type: Class
Access: public
Topic: LFC.Data
Declared in: WEB-INF/lps/lfc/data/LzDataset.lzs

Description

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 ???, 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 (LzDatapointer) 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 SWF7 and SWF8 runtime 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 8. 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>

In addition to any fields documented in the section below, these fields are also available: String querystring: A string to be appended to the request that the dataset makes.

Superclass Chain

node (LzNode) » dataset (LzDataset)

Known Subclasses

Details

Static Properties (1)

anonDatasourceNum
static public var anonDatasourceNum = 0.0;

Initial Attributes (5)

Initial Attributes are given as attributes in LZX but are not generally available as properties in JavaScript.

port
<attribute name="port" type="deprecated" />
querytype
<attribute name="querytype" />
secureport
<attribute name="secureport" />
src
<attribute name="src" />
timeout
<attribute name="timeout" />

Properties (13)

acceptencodings
<attribute name="acceptencodings" type="boolean" />
public var acceptencodings : Boolean = false;
When true, the server will accept encoded responses for this request. Encoded responses require more work for the LPS (encoding the response) and client (decoding the response) in trade for lower network bandwidth usage.
autorequest
<attribute name="autorequest" />
public var autorequest = false;
cacheable
<attribute name="cacheable" type="boolean" />
public var cacheable : Boolean = false;
When true, the server will attempt to cache response (defaults to false). There are security concerns when this field is true. When this field is true, you will usually want the getresponseheaders field to be false.
getresponseheaders
<attribute name="getresponseheaders" type="boolean" />
public var getresponseheaders : Boolean = false;
When true, the server will encode and send the HTTP response headers along with the data (defaults to false). This does not work for SOLO applications; in SOLO applications the call returns empty.
headers
<attribute name="headers" />
public var headers = null;
nodeType
<attribute name="nodeType" />
public var nodeType;
nsprefix
<attribute name="nsprefix" type="boolean" />
public var nsprefix : Boolean = false;
When true, the server will preserve namespace prefixes on data node names and attribute names
params
<attribute name="params" type="lzParam" />
public var params : LzParam = null;
An LzParams object which holds query key-value pairs.
proxied
<attribute name="proxied" />
public var proxied = null;
querystring
<attribute name="querystring" type="string" />
public var querystring : String = null;
A string to be appended to the request that the dataset makes.
responseheaders
<attribute name="responseheaders" />
public var responseheaders = null;
timeout
<attribute name="timeout" />
public var timeout = 30000;
trimwhitespace
<attribute name="trimwhitespace" type="boolean" />
public final var trimwhitespace : Boolean = false;
When true, the server will trim whitespace in the XML data (defaults to false).

Setters (5)

Setters for virtual properties, to be used with setAttribute. A setter may or may not have a corresponding getter method; consult the Methods list in this section.

autorequest
data
initialdata
request
src
The source for requests made by this dataset.

Methods (36)

abort()
<method name="abort" />
public function abort();
clearRequestHeaderParams()
<method name="clearRequestHeaderParams" />
protected function clearRequestHeaderParams();
Clears any request header parameters
construct()
<method name="construct" args="parent, args" />
private function construct(parent, args);
destroy()
<method name="destroy" args="recursiveCall" />
private function destroy(recursiveCall);
Extend LzNode.destroy: remove yourself from the 97 places you installed yourself (do we really need all these aliases?) and destroy your datasource node if you made one for yourself.
doRequest()
<method name="doRequest" />
public function doRequest();
Does a request immediately using the current values. If autorequest is true, this method is called automatically when values change.
getAllResponseHeaders()
<method name="getAllResponseHeaders" />
public function getAllResponseHeaders() : LzParam;
Returns all response headers as an object of name/value pairs, or false if there were none.
getContext()
<method name="getContext" />
private function getContext();
This is the shared interface with datapointer
getDataset()
<method name="getDataset" />
private function getDataset();
This is the shared interface with datapointer
getErrorString()
<method name="getErrorString" />
public function getErrorString() : String;
Returns an error string if there was an error, or false if there was none.
getLoadTime()
<method name="getLoadTime" />
public function getLoadTime() : Int;
Returns the number of miliseconds it took to load the dataset's request
getParams()
<method name="getParams" />
public function getParams() : LzParam;
Returns an LzParams object holding any set request parameters for the dataset.
getPointer()
<method name="getPointer" />
public function getPointer() : LzDatapointer;
Returns a datapointer pointing to the root of the dataset.
getQueryString()
<method name="getQueryString" />
public function getQueryString() : String;
Returns the querystring attribute of the dataset, if there is one
getRequestHeaderParams()
<method name="getRequestHeaderParams" />
public function getRequestHeaderParams() : LzParam;
Retrieves the LzParam object which represents the headers sent with the dataset's last request
getResponseHeader()
<method name="getResponseHeader" args="name" />
public function getResponseHeader(name : String) : String;
Returns the value for the specified response header, or false if there was no header with that name. If name is omitted, all response headers are returned as an object of name/value pairs.
getSrc()
<method name="getSrc" />
public function getSrc() : String;
Return the src attribute of the dataset, if one was given.
getStatusCode()
<method name="getStatusCode" />
public function getStatusCode();
Returns the status of the dataset's request. Always returns 200 since the server will respond with an error if the request fails.
gotError()
<method name="gotError" args="e" />
private function gotError(e);
Called when an error is received from the datasource.
gotRawData()
<method name="gotRawData" args="data" />
private function gotRawData(data);
Allows the datasource to determine how the raw data should be interpreted
gotTimeout()
<method name="gotTimeout" />
private function gotTimeout();
Called when a timeout is recieved from the datasource.
lockFromUpdate()
<method name="lockFromUpdate" args="who" />
private function lockFromUpdate(who);
setAutorequest()
<method name="setAutorequest" args="b" />
private function setAutorequest(b);
Turns autorequest on or off, depending on the value passed in. If true, changes to dataset request parameters cause new datasets to be automatically requested. If autorequest is false, doRequest() must be called manually after dataset request parameters are changed.
setData()
<method name="setData" args="data, headers" />
private function setData(data, headers);
Sets the data for the dataset
setHeader()
<method name="setHeader" args="k, val" />
public function setHeader(k : String, val : String);
Sets a header for the next request
setInitialData()
<method name="setInitialData" args="d" />
private function setInitialData(d);
setName()
<method name="setName" args="name" />
private function setName(name);
Sets the name of this datasource - used only by initializer
setProxyRequests()
<method name="setProxyRequests" args="val" />
public function setProxyRequests(val : String);
Sets whether or not the dataset makes its request directly to the target server or via the LPS server proxy.
setQueryParam()
<method name="setQueryParam" args="key, val" />
public function 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.
setQueryParams()
<method name="setQueryParams" args="o" />
public function setQueryParams(o : 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.
setQueryString()
<method name="setQueryString" args="s" />
public function setQueryString(s : String);
Sets the querystring parameter of the dataset to the given string. The dataset's querystring will be pre-pended to any request made for the dataset.
setQueryType()
<method name="setQueryType" args="reqtype" />
public function setQueryType(reqtype : Sring);
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
setRequest()
<method name="setRequest" args="b" />
public function setRequest(b : Boolean);
Sets whether or not the dataset makes its request upon initialization
setSrc()
<method name="setSrc" args="src" />
public function setSrc(src : String);
Sets the src attribute of the dataset's datasource.
setURL()
<method name="setURL" args="src" />
public function setURL(src);
toString()
<method name="toString" />
private function toString();
Get string representation
unlockFromUpdate()
<method name="unlockFromUpdate" args="who" />
private function unlockFromUpdate(who);

Events (3)

ondata
<attribute name="ondata" />
public event ondata;
onerror
<attribute name="onerror" />
public event onerror;
Sent when the dataset's request results in an error.
ontimeout
<attribute name="ontimeout" />
public event ontimeout;
Sent when the request made by the dataset times out.

Prototype Properties (1)

request
<attribute name="request" />
public var request;

LZX Synopsis

<class name="LzDataset" extends=" LzNode ">
  <attribute name=" acceptencodings " type="boolean" />
  <attribute name=" autorequest " />
  <attribute name=" cacheable " type="boolean" />
  <attribute name=" getresponseheaders " type="boolean" />
  <attribute name=" headers " />
  <attribute name=" nodeType " />
  <attribute name=" nsprefix " type="boolean" />
  <attribute name=" params " type="lzParam" />
  <attribute name=" proxied " />
  <attribute name=" querystring " type="string" />
  <attribute name=" responseheaders " />
  <attribute name=" timeout " />
  <attribute name=" trimwhitespace " type="boolean" />
  <method name=" abort " />
  <method name=" clearRequestHeaderParams " />
  <method name=" construct " args="parent, args" />
  <method name=" destroy " args="recursiveCall" />
  <method name=" doRequest " />
  <method name=" getAllResponseHeaders " />
  <method name=" getContext " />
  <method name=" getDataset " />
  <method name=" getErrorString " />
  <method name=" getLoadTime " />
  <method name=" getParams " />
  <method name=" getPointer " />
  <method name=" getQueryString " />
  <method name=" getRequestHeaderParams " />
  <method name=" getResponseHeader " args="name" />
  <method name=" getSrc " />
  <method name=" getStatusCode " />
  <method name=" gotError " args="e" />
  <method name=" gotRawData " args="data" />
  <method name=" gotTimeout " />
  <method name=" lockFromUpdate " args="who" />
  <event name=" ondata " />
  <event name=" onerror " />
  <event name=" ontimeout " />
  <method name=" setAutorequest " args="b" />
  <method name=" setData " args="data, headers" />
  <method name=" setHeader " args="k, val" />
  <method name=" setInitialData " args="d" />
  <method name=" setName " args="name" />
  <method name=" setProxyRequests " args="val" />
  <method name=" setQueryParam " args="key, val" />
  <method name=" setQueryParams " args="o" />
  <method name=" setQueryString " args="s" />
  <method name=" setQueryType " args="reqtype" />
  <method name=" setRequest " args="b" />
  <method name=" setSrc " args="src" />
  <method name=" setURL " args="src" />
  <method name=" toString " />
  <method name=" unlockFromUpdate " args="who" />
</class>

JavaScript Synopsis

public LzDataset extends  LzNode  {
  static public var anonDatasourceNum  = 0.0;
  public var acceptencodings  : Boolean = false;
  public var autorequest  = false;
  public var cacheable  : Boolean = false;
  public var getresponseheaders  : Boolean = false;
  public var headers  = null;
  public var nodeType ;
  public var nsprefix  : Boolean = false;
  public var params  : LzParam = null;
  public var proxied  = null;
  public var querystring  : String = null;
  public var responseheaders  = null;
  public var timeout  = 30000;
  public final var trimwhitespace  : Boolean = false;
  prototype public function abort ();
  prototype protected function clearRequestHeaderParams ();
  prototype private function construct (parent, args);
  prototype private function destroy (recursiveCall);
  prototype public function doRequest ();
  prototype public function getAllResponseHeaders () : LzParam;
  prototype private function getContext ();
  prototype private function getDataset ();
  prototype public function getErrorString () : String;
  prototype public function getLoadTime () : Int;
  prototype public function getParams () : LzParam;
  prototype public function getPointer () : LzDatapointer;
  prototype public function getQueryString () : String;
  prototype public function getRequestHeaderParams () : LzParam;
  prototype public function getResponseHeader (name : String) : String;
  prototype public function getSrc () : String;
  prototype public function getStatusCode ();
  prototype private function gotError (e);
  prototype private function gotRawData (data);
  prototype private function gotTimeout ();
  prototype private function lockFromUpdate (who);
  prototype public event ondata ;
  prototype public event onerror ;
  prototype public event ontimeout ;
  prototype public var request ;
  prototype private function setAutorequest (b);
  prototype private function setData (data, headers);
  prototype public function setHeader (k : String, val : String);
  prototype private function setInitialData (d);
  prototype private function setName (name);
  prototype public function setProxyRequests (val : String);
  prototype public function setQueryParam (key : String, val : String);
  prototype public function setQueryParams (o : Object);
  prototype public function setQueryString (s : String);
  prototype public function setQueryType (reqtype : Sring);
  prototype public function setRequest (b : Boolean);
  prototype public function setSrc (src : String);
  prototype public function setURL (src);
  prototype private function toString ();
  prototype private function unlockFromUpdate (who);
}