PDA

View Full Version : dataset from a dataset


chalko
10-03-2003, 01:42 PM
I am trying to use a dataset to retrieve the url for the src of a second dataset, but it doesnt work.
Where am I going wrong

<canvas width="580" height="260" >
<resource name="g" src="grad_blk_up.swf"/>
<resource name="poweredby" src="powered_laszlo.swf"/>
<resource name="link" src="link.swf" />
<include href="lz/tabslider.lzx"/>


<dataset name="rollData"
autorequest="true"
type="http"
src="$once{'http://topicexchange.com/user/api?c=list_blogrolls&amp;email='+email+'&amp;f=xml'}"
>
</dataset>

<datapointer id="mydp"
rerunxpath="true"
xpath="rollData:/blogrolls/roll[1]" />
<dataset name="opmldata"
autorequest="true"
type="http" src="${mydp.getXPath('/blogrolls/roll[1]/@opml')}"
/>


<view name="myTable" width="500">
<simplelayout axis="y" />
<text width="${parent.width}">hello</text>
<text datapath="rollData:/blogrolls/roll[1]/@title" width="${parent.width}" />
<text datapath="rollData:/blogrolls/roll[1]/@opml" width="${parent.width}"/>
<text text="${email}" width="${parent.width}"/>
<text name="output" text="${mydp.getXPath('/blogrolls/roll[1]/@opml')}" width="${parent.width}"/>
<text width="${parent.width}">done</text>
<text datapath="opmldata:/opml/body/outline/@text" width="${parent.width}"/>
</view>

</canvas>

antun
10-03-2003, 02:33 PM
What you've got to understand is that data requests are asynchronous in Laszlo: Since autorequest was set to true both your rollData and opmldata datasets, they both sent out their requests as soon as they were initialized.

What you needed was for the opmldata <dataset> to wait until the rollData <dataset>'s response had returned, and the data was in place, before it set its src and made its own request.

Here's what I did:


<dataset name="rollData"
autorequest="true"
type="http"
src="$once{'http://topicexchange.com/user/api?c=list_blogrolls&amp;email='+email+'&amp;f=xml'}"
>
</dataset>

<datapointer id="mydp"
rerunxpath="true"
xpath="rollData:/blogrolls/roll[1]">
<method event="ondata">
this.urlToUse = this.getXPath('/blogrolls/roll[1]/@opml');
debug.write("DOING REQUEST NOW");
opmldata.setURL( this.urlToUse );
opmldata.doRequest();
</method>
</datapointer>

<dataset name="opmldata"
autorequest="false"
type="http" />


I've highlighted the important part. Basically you set the src of the opmldata <dataset> when the data returns to the rollData <dataset>, which is when the ondata event gets sent.

Does that clear things up?

-Antun

chalko
10-07-2003, 08:35 PM
Thank you.
Worked great.