lyndonwong
10-26-2003, 03:49 PM
Hi Antun,
I'm trying to modify pWeather_widget to start up with a weather report for a default Zip Code defined in the external parameters XML file. Can you help me understand why the following code does not work as intended? I tried numerous placements of oninit="this.getWeather()" to no avail.
thx,
Lyndon
p.s. -- forgive lack of tag indentation, i couldn't figure out how to preserve indents (see other post). Attempted code edit in RED text.
--------------------------------
<canvas width="184" height="204" debug='false'>
<!-- RESOURCES -->
<font name="serif" src="timmonsr.ttf" />
<font name="san" src="helmetr.ttf" />
<!-- Check for pWeather_url value or use default -->
<script>
if (typeof(pWeather_url) == 'undefined') pWeather_url='pWeather_parameters.xml';
</script>
<!-- pWeather XML FILE set to parameter defined above -->
<dataset name="pWeather_parameters" type="http" autorequest="true" src="${pWeather_url}" />
<!-- XML datasource for U.S. weather, provided by Laszlo Systems -->
<dataset type="http" name="weatherdata" src="http://www.laszlosystems.com/cgi-pub/weather.cgi" />
<!-- APP INTERFACE -->
<!-- Widget border created via two nested views -->
<view x="3" y="3" width="180" height="200" bgcolor="gray" >
<view width="178" height="198" x="1" y="1" bgcolor="white" datapath="pWeather_parameters:/parameters/" >
<simplelayout axis="y" />
<text x="6" y="2" height="22" font="san" fontsize="14" width="170" fgcolor='${parseInt(parent.colorValue.text)}' datapath='titleText/text()' />
<!-- Query user for input of a U.S. zip code, and submit data request via HTTP Get (default) -->
<view x="8" y="1" font="san" fontsize="12" oninit="this.getWeather()">
<simplelayout axis="x" />
<windowtext width="90" valign="bottom" name="inputField" datapath='zipCode/text()'></windowtext>
<method name="getWeather" >
var data = canvas.datasets.weatherdata;
data.setQueryString({ zip : parent.inputField.getText() });
data.doRequest();
</method>
<button width='70'> Enter ZIP
<method event="onclick">
var data = canvas.datasets.weatherdata;
data.setQueryString({ zip : parent.inputField.getText() });
data.doRequest();
</method>
</button>
</view>
<view height="12"></view>
<!-- Display formatting for returned weather report -->
<view x="6" width="170" clip="true" font="serif" fontsize="12" name="WeatherReport" datapath="weatherdata:/weather[1]/current" >
<simplelayout axis="y" />
<text fgcolor="black" fontsize="14" width="166" datapath="where/text()" />
<text fgcolor="black" fontsize="14" width="166" datapath="desc/text()" />
<text fgcolor="green" fontsize="24" width="166" datapath="temp/text()" />
<text fgcolor="gray" width="166" datapath="station/text()" />
<text fgcolor="gray" width="166" datapath="when/text()" />
</view>
<!-- EXTRACTED PARAMETERS FROM: pWeather_parameters.xml -->
<text name='colorValue' fontsize="12" width="170" fgcolor='white' datapath='titleColor/text()' />
</view>
</view>
</canvas>
-------------------------------------------------
pWeather_parameters.xml file below:
<parameters>
<titleText>Weather Report</titleText>
<titleColor>0x008000</titleColor>
<zipCode>94107</zipCode>
</parameters>
I'm trying to modify pWeather_widget to start up with a weather report for a default Zip Code defined in the external parameters XML file. Can you help me understand why the following code does not work as intended? I tried numerous placements of oninit="this.getWeather()" to no avail.
thx,
Lyndon
p.s. -- forgive lack of tag indentation, i couldn't figure out how to preserve indents (see other post). Attempted code edit in RED text.
--------------------------------
<canvas width="184" height="204" debug='false'>
<!-- RESOURCES -->
<font name="serif" src="timmonsr.ttf" />
<font name="san" src="helmetr.ttf" />
<!-- Check for pWeather_url value or use default -->
<script>
if (typeof(pWeather_url) == 'undefined') pWeather_url='pWeather_parameters.xml';
</script>
<!-- pWeather XML FILE set to parameter defined above -->
<dataset name="pWeather_parameters" type="http" autorequest="true" src="${pWeather_url}" />
<!-- XML datasource for U.S. weather, provided by Laszlo Systems -->
<dataset type="http" name="weatherdata" src="http://www.laszlosystems.com/cgi-pub/weather.cgi" />
<!-- APP INTERFACE -->
<!-- Widget border created via two nested views -->
<view x="3" y="3" width="180" height="200" bgcolor="gray" >
<view width="178" height="198" x="1" y="1" bgcolor="white" datapath="pWeather_parameters:/parameters/" >
<simplelayout axis="y" />
<text x="6" y="2" height="22" font="san" fontsize="14" width="170" fgcolor='${parseInt(parent.colorValue.text)}' datapath='titleText/text()' />
<!-- Query user for input of a U.S. zip code, and submit data request via HTTP Get (default) -->
<view x="8" y="1" font="san" fontsize="12" oninit="this.getWeather()">
<simplelayout axis="x" />
<windowtext width="90" valign="bottom" name="inputField" datapath='zipCode/text()'></windowtext>
<method name="getWeather" >
var data = canvas.datasets.weatherdata;
data.setQueryString({ zip : parent.inputField.getText() });
data.doRequest();
</method>
<button width='70'> Enter ZIP
<method event="onclick">
var data = canvas.datasets.weatherdata;
data.setQueryString({ zip : parent.inputField.getText() });
data.doRequest();
</method>
</button>
</view>
<view height="12"></view>
<!-- Display formatting for returned weather report -->
<view x="6" width="170" clip="true" font="serif" fontsize="12" name="WeatherReport" datapath="weatherdata:/weather[1]/current" >
<simplelayout axis="y" />
<text fgcolor="black" fontsize="14" width="166" datapath="where/text()" />
<text fgcolor="black" fontsize="14" width="166" datapath="desc/text()" />
<text fgcolor="green" fontsize="24" width="166" datapath="temp/text()" />
<text fgcolor="gray" width="166" datapath="station/text()" />
<text fgcolor="gray" width="166" datapath="when/text()" />
</view>
<!-- EXTRACTED PARAMETERS FROM: pWeather_parameters.xml -->
<text name='colorValue' fontsize="12" width="170" fgcolor='white' datapath='titleColor/text()' />
</view>
</view>
</canvas>
-------------------------------------------------
pWeather_parameters.xml file below:
<parameters>
<titleText>Weather Report</titleText>
<titleColor>0x008000</titleColor>
<zipCode>94107</zipCode>
</parameters>