PDA

View Full Version : retrieving db records on the fly


spinnergy
02-05-2003, 10:19 AM
I see no method for specifying a server side script in which to load data into the application. Flash allows you to do this with ASP, JSP, PHP, etc.

How can I do this in LZX???

hqm
02-05-2003, 10:27 AM
I am not sure I understand your question, but the datasource lets you specify a URL to fetch data from. As long as that URL returns XML data, it will be parsed and loaded into the Laszlo app in a dataset.

In this example, there is a servlet which returns an XML document, but the URL could point to any URL which
returns XML; a script, a static file, a php file, .asp, etc.


<canvas width="1000" height="800" debug="true">
<!-- setup HTTP datasource -->
<dataset name="xml" autorequest="true"
src="http://www.beartronics.com:8080/examples/servlet/JDBCTest"/>
<view>
<view fontstyle="bold">
<simplelayout axis="x" spacing="4"/>
<text width="100" name="name" label="name" />
<text width="40" name="age" label="age" />
<text width="200" name="job" label="job" />
</view>

<view datapath="xml:/sqldata/row">
<text bgcolor="#ffcccc" width="100" name="name" datapath="name/text()" />
<text bgcolor="#ffcccc" width="40" name="age" datapath="age/text()" />
<text bgcolor="#ffcccc" width="200" name="job" datapath="job/text()" />
<simplelayout axis="x" spacing="4"/>
</view>
<simplelayout axis="y" spacing="4"/>
</view>
</canvas>


See my example in http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=41

antun
02-05-2003, 10:37 AM
Hey spinnergy

You use the <dataset>, just like with other data, except that you give it an http src attribute:


<dataset name="myData"
src="http://www.myServer.com/cgi-bin/myXMLDoc.cgi?return=addresses" />


Have a look here:

http://www.laszlosystems.com/developers/learn/documentation/tutorials/data.php#http

The server side script can be anything you want, provided that it returns valid XML. The weather app is a very good, simple example of reading XML data over HTTP.

Take care,

Antun

spinnergy
02-05-2003, 10:40 AM
That is a relief!

Now, can you tell me if it is possible for me to send UI data to the server? I am asking for something similar to the way I do it in flash with the LoadVars object

myData = new LoadVars()

myData.userName = "scott"
myData.email = "sblanchard@octigon.com"

myData.sendAndLoad(myScript.asp)

antun
02-05-2003, 11:04 AM
Here's the object you want:

http://www.laszlosystems.com/developers/learn/documentation/lzxref/LzHTTPDataset.php#api

You still do the <dataset> tag as usual, but then you'd do stuff like:


<dataset name="myData" />

<script>
myData.setQueryString({email: 'my@email.com'});
myData.doQuery();
</script>


-Antun