PDA

View Full Version : <image> tag, displaying dynamic image data


lyndonwong
06-21-2003, 06:02 PM
Hi Laszlo Team,

I need a little assistance! The following LZX script causes a compile error:

<image name="radarscan" width="173" height="130" stretches="both" datapath="@src"/>

In the otherwise working "Humble Weather App" source code below:

-------------------------------------
<!-- TEST OF LASZLO WEATHER DATA CGI DATASOURCE -->


<canvas>
<dataset type="http" name="weatherdata"
src="http://www.laszlosystems.com/cgi-pub/weather.cgi"/>
<window x="30" y="50" width="300" height="200">
<simplelayout axis="y" />
<text> Lyndon's Humble Weather App </text>
<view>
<simplelayout axis="x" />
<windowtext width="90" valign="bottom" name="t">zip</windowtext>
<button> submit
<method event="onclick">
var d = canvas.datasets.weatherdata;
d.setQueryString( { zip : parent.t.getText() } );
d.doRequest();
</method>
</button>
</view>


<view width="300" name="WeatherReport" datapath="weatherdata:/weather[1]/current">
<simplelayout axis="y" />
<text datapath="where/text()" />
<text datapath="station/text()" />
<text datapath="when/text()" />
<text datapath="desc/text()" />
<text datapath="temp/text()" />
</view>

<view name="RadarImage" datapath="weatherdata:/weather[1]/radar">

<text datapath="@src" />

<!-- FOLLOWING IMAGE TAG CAUSES COMPILE ERROR: 6-20-2003 LYNDON -->
<image name="radarscan" width="173" height="130" stretches="both" datapath="@src"/>

</view>
</window>

</canvas>

-------------------------------------

Can you help me understand what I'm doing wrong? I borrowed the above approach from weather.lzx source code.

Is there a simple alternative approach using the <resource> tag and extracting the URL from the Weather XML data?

Thx,

LW

antun
06-21-2003, 11:45 PM
There's no <image> tag in LZX - unless you defined a custom image class somewhere. You need to set a view's resource:


<view resource="..." />



Is there a simple alternative approach using the <resource> tag and extracting the URL from the Weather XML data?


You have to use the ondata event of a view to set the source of the view at runtime to achieve what you want. Something like:


<view name="radarscan" width="173" height="130" stretches="both" datapath="@src">
<method event="ondata">
this.setSource( data );
</method>
</view>


At least I think "data" is the special variable you can use.

Let me know if that works.

-Antun

tachometry_nik
07-24-2007, 10:23 AM
This is really close. The data keyword does work as the current pointer, but the setSrc didn't work for me (I assume this is because the view object doesn't have a src attribute). If I used the more formal setAttribute method to set the the resource attribute it worked perfectly.

Using antun's example:

<view name="radarscan" width="173" height="130" stretches="both" datapath="@src">
<method event="ondata">
this.setAttribute("resource", data );
</method>
</view>

That should work!

-Nik

Evangelus
07-24-2007, 04:02 PM
The method is setSource() ...

krishbal
11-06-2007, 11:09 AM
Hi All
I have to show a lzx window with a image.
where the image is a Chart and created dynamically thru a 3rd party library and streamed and servlet.
I know the URL that need to requested to get the image.
for eg: http://myapp/module/ChartProducer.do?chartId=XXX