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:
<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
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 12. Making a request using a dataset
<canvas
height
="250
" 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.debug("sending request for weather data.");
d.setQueryString({zip : parent.t.text});
d.doRequest();
</handler
>
</button
>
<datapointer
xpath
="weatherdata:/weather
">
<handler
name
="ondata
">
var duplicate_pointer = this.dupePointer();
duplicate_pointer.selectChild();
while (duplicate_pointer.selectNext()){
Debug.debug("%w", duplicate_pointer.serialize());
}
</handler
>
</datapointer
>
<simplelayout
axis
="x
"/>
</view
>
</canvas
>
Name (CSS property) | Type (tag) | Type (js) | Default | Category |
---|---|---|---|---|
acceptencodings
|
boolean | Boolean | readonly | |
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
|
boolean | Boolean | false | read/write |
If true, changes to src or querystring attributes cause doRequest() to be called automatically. If false, doRequest() must be called manually when src or querystring attributes change. | ||||
cacheable
|
boolean | Boolean | false | readonly |
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. | ||||
clientcacheable
|
Boolean | false | read/write | |
When true, data responses can be cached by the client (browser). When false, a unique valued argument will be added to the request string in the format '__lzbc__=1204685840777' to defeat the browser's cache. | ||||
dataprovider
|
expression | any | read/write | |
Holds a pointer to the DataProvider which handles data load requests for this dataset. Default value is canvas.defaultdataprovider | ||||
getresponseheaders
|
boolean | Boolean | read/write | |
When true, the proxy server (if making a proxied request) will encode and
send the HTTP response headers along with the data (defaults to false).
Due to a lack of a native API to get this information, SOLO SWF applications
will always return an empty set.
When making a proxied request,
getresponseheaders must be true in
order for the response headers to be retrieved via the
getResponseHeader or
getAllResponseHeaders methods.
|
||||
multirequest
|
Boolean | false | read/write | |
Create a new data request object for each request. | ||||
nsprefix
|
boolean | Boolean | false | readonly |
When true, the server will preserve namespace prefixes on data node names and attribute names | ||||
params
|
lz.params | read/write | ||
An lz.Param object which holds query key-value pairs. | ||||
postbody
|
string | String | read/write | |
Used to send a string as the entire body of a POST request. For a POST request, setting postbody to a non-null string value will send that string as the complete body of the POST request. In this case any other query parameters that have been set via setQueryParam dataset will be ignored. The behavior of a GET request with a non-null postbody is not defined. Note, the swf8 runtime is forced to XML-quote the postbody, due to limitations in the Flash 8 player API. This restriction is not present in later swf runtimes, or in the DHTML runtime. | ||||
proxied
|
inheritableBoolean | "inherit" | read/write | |
Sets whether or not the dataset makes its request directly to the target server or via the server proxy. Inherits value from canvas.proxied flag. | ||||
proxyurl
|
string | String | read/write | |
The URL of the proxy server, for proxied requests | ||||
querystring
|
string | String | readonly | |
A string to be appended to the request that the dataset makes. | ||||
querytype
|
get|post|GET|POST | String | read/write | |
HTTP request method. Value must be one of "GET" or "POST". | ||||
rawdata
|
String | null | read/write | |
Holds raw data response string from data source | ||||
request
|
boolean | Boolean | false | read/write |
If true, the datset will make a request upon initialization | ||||
secureport
|
integer | uint | 443 | read/write |
TCP port number to use for secure (HTTPS) requests | ||||
src
|
string | String | read/write | |
The source for requests made by this dataset. The value can be a pathname or an absolute or relative URL. If the value is a URL (starts with "http:"), the dataset will be configured to load its data at runtime. Otherwise, the data is included inline into the application at compile time. | ||||
timeout
|
Number | Number | read/write | |
The numer of milliseconds to wait before the request times out, and an ontimeout event is sent. | ||||
trimwhitespace
|
boolean | Boolean | initialize-only | |
When true, the server will trim whitespace in the XML data (defaults to false). | ||||
type
|
http|soap | String | readonly | |
When set to "http" or "soap", the dataset interprets it's src attribute as a URL to be loaded at runtime. If the "src" attribute is set to a URL (e.g., starts with "http:") then the type attribute implicitly becomes "http". |
classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
Methods
abort() |
---|
clearRequestHeaderParams() |
---|
doRequest() |
---|
getAllResponseHeaders() |
---|
getErrorString() |
---|
getLoadTime() |
---|
getParams() |
---|
getPointer() |
---|
getQueryString() |
---|
getRequestHeaderParams() |
---|
getResponseHeader() |
---|
getSrc() |
---|
setHeader() |
---|
setQueryParam() |
---|
Parameter Name | Type | Description |
---|---|---|
key | String | The name of the parameter |
val | String | The value for the parameter |
setQueryParams() |
---|
Parameter Name | Type | Description |
---|---|---|
obj | Object | An object whose keys are keys of parameters and whose values are those parameters' values. Passing a value of null to this method clears the query parameters. The key 'lzpostbody' has a specific interpretation, see setQueryType() for details. |
setQueryString() |
---|
Parameter Name | Type | Description |
---|---|---|
s | String | A string to be appended to any query made on behalf of this dataset. |
appendChild, getAttr, getElementsByTagName, getFirstChild, getLastChild, handleDocumentChange, hasAttr, hasChildNodes, insertBefore, removeAttr, removeChild, replaceChild, setAttr
childOf, cloneNode, getNextSibling, getOffset, getParent, getPreviousSibling, getUserData, serialize, setUserData
animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData
Class Methods
Events
Name | Description |
---|---|
onerror
|
Sent when the dataset's request results in an error. |
ontimeout
|
Sent when the request made by the dataset times out. |
onattributes, onchildNode, onchildNodes, onDocumentChange, onnodeName, onownerDocument, onparentNode
Copyright © 2002-2010 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.