PDA

View Full Version : Is this the right way (was: Setting up dowloads)


rajs1
10-15-2004, 03:30 AM
After much "to ing" and "fro ing", I have got the download scenario to work this way.

I would appreciate if you could comment on whether this is the best way to do it (or if this is just one way to skin the cat).


<canvas width="450" height="485" bgcolor="#eaeaea">
<dataset name="downloads">
<app1>
<result id="1" platform="Win 98/2000/XP" downloadurl="http://localhost:8080/lps-2.2/my-apps/rl.exe" size="25MB"/>
<result id="1" platform="Unix/Linux" downloadurl="http://localhost:8080/lps-2.2/my-apps/rl.sh" size="11MB"/>
</app1>
</dataset>
<view id="downloadbuttonsview">
<simplelayout axis="y" spacing="8"/>
<text>App Downloads</text>
<grid datapath="downloads:/app1" width="300" height="100">
<gridcolumn width="250">Platform
<text datapath="@platform" />
</gridcolumn>
<gridcolumn width="50">Size
<text datapath="@size" />
</gridcolumn>
<method event="onselect">
<![CDATA[
var sel = this.getSelection();
var dp = sel[0];
var url = dp.p.attributes.downloadurl;
Debug.write( url );
LzBrowser.loadURL( url );
]]>
</method>
</grid>
</view>
</canvas>



By the way, when I deploy I would replace


<app1>
<result id="1" platform="Win 98/2000/XP" downloadurl="http://localhost:8080/lps-2.2/my-apps/rl.exe" size="25MB"/>
<result id="1" platform="Unix/Linux" downloadurl="http://localhost:8080/lps-2.2/my-apps/rl.sh" size="11MB"/>
</app1>


with



<dataset name="downloads" request="true" src="http://localhost:8080/lps-2.2/my-apps/Downloads.xml"/>


where Downloads.xml contains the above data.

I have tried it and it works.

Ok, code brevity has been sacrificed by stating


var sel = this.getSelection();
var dp = sel[0];
var url = dp.p.attributes.downloadurl;


But this way I can come back years later and still understand the code.

:-P

Your thoughts would be appreciated.

Cheers
-raj