PDA

View Full Version : Using file: URLs for Media and Dataset Requests


antun
11-06-2003, 01:14 PM
If you use setSource() to set the art asset of a view at runtime, you should be aware that the LPS server has to make an HTTP request for that resource. This can be avoided by using the file: prefix in the URL. Naturally this will only work for images saved within the same webapp as the LPS:


<canvas debug="true">

<simplelayout axis="y" spacing="10" />

<view name="foo" />

<button>
<method event="onclick">
foo.setSource( "file:compass.png" );
</method>
</button>

</canvas>


The client will still make the request to the LPS at run-time, so the image can still be downloaded at run-time, but it saves the LPS the work of doing the second request, thus improving performance.

This can be done with dataset declarations too, and you can still call the doRequest() method, however only the flat XML file will be returned. (i.e. you can't call a JSP this way).

Enjoy!


Thanks to iconfactory (http://www.iconfactory.com/) for the resource.

ygreen
10-12-2005, 03:54 PM
We've been using this trick to avoid making HTTP requests from our Laszlo apps for some time but ever since we up-reved the LPS runtime from 2.2.1 to 3.0.2 view.setSource() doesn't seem to like this anymore.

Our sites SAN holds all of the data we are trying to display via the LZX app but the problem is that when I feed it a path starting with "file://" it prepends the full URL to the script attempting this call and then appends the file path, i.e. (my development machine)

imgurl = file://e:\apps\dev\snapcat\webapps\ROOT\dm1\lr\testdata\U pload_full1\3243672Xpic1lr.jpg
data source error for http://snapfish:80/lps/lzx/snapfishlzx/src/slideshow///e:\apps\dev\snapcat\webapps\ROOT\dm1\lr\testdata\U pload_full1\3243672Xpic1lr.jpg: HTTP Status code: 404:Not Found

This obviously isn't right since this is not a valid URL for anyone. We've got a release coming up and I don't have the luxury of waiting until it ends up on our staging environment to debug it on a near-live environment. Has the functionality of view.setSource() changed with respect to handling file:// paths? I'm at a loss and none of the documentation mentiones anything about this.

csekk
05-21-2006, 06:57 AM
how can i use this in SOLO mode?