PDA

View Full Version : Datapointer Type Problem?


k-billy
04-23-2004, 05:15 PM
I am sending in different datapointers to the same method. I call the serialize method on the datapointers, and get different result.

The code in the method is the following, where rootParent is the pointer passed to the method:

var root = rootParent.dupePointer();
root.setXPath("root");
Debug.Write("rootParent: " + rootParent.serialize());
Debug.Write("root: " + root.serialize());
Debug.Write("rootParent: " + rootParent.toString());
Debug.Write("root: " + root.toString());
var what = root.xpathQuery("el/hints/_what/sv/text()");

So, the first time the method is called, the output is:
´string#0| rootParent: <dsEditManagerBuffer><root ref="root/el" id="root">....
´string#1| root: <root ref="root/el" id="root">....
rootParent: Datapointer named null
root: Datapointer named null

The second time the method is called, the ouput is:
rootParent: <UtilLibrary_SaveDataset><root ref="root/el" id="root">....
root: <root ref="root/el" id="root">....
rootParent: Datapointer named null
root: Datapointer named null

This seems to be some 'really' strange behaviour. Where is 'string#0' pattern coming from in the first example? Is this a type problem? In the first example, our xpath query for the 'what' paramater works. It doesn't in the second. We are using Laszlo version 2.1.1. and the canvas is set to version 1.1.

antun
04-26-2004, 08:50 AM
Can you post some code that will allow me to replicate this? (i.e. with the data?)

Also, have you tried renaming root to something else. I think root might be a reserved word.

-Antun

k-billy
04-26-2004, 01:46 PM
I modified the Laszlo Reference 'Dataset' example to the following code:

<canvas height="600" width="800" debug="true" >
<debug y="100" />
<dataset type="http" name="weatherdata"
src="http://www.laszlosystems.com/cgi-pub/weather.cgi"/> <view>
<inputtext width="90" name="t">zip</inputtext>
<button> submit
<method event="onclick"> var d = canvas.datasets.weatherdata;
debug.write("sending request for weather data.");
d.setQueryString( { zip : parent.t.getText() } );
d.doRequest();
</method>
</button>
<datapointer xpath="weatherdata:/weather">
<method event="ondata">
var duplicate_pointer = this.dupePointer();
canvas.printPointer(duplicate_pointer);
duplicate_pointer.selectChild();
while( duplicate_pointer.selectNext() ){
canvas.printPointer(duplicate_pointer);
Debug.write("duplicatePointer: " + duplicate_pointer.serialize() );
}
</method>
</datapointer>
<simplelayout axis="x" />
</view>
<method name="printPointer" args="ptr">
debug.write("ptr: " + ptr.serialize());
</method>
</canvas>

There is a method called printPointer(). The first call to the method will print with the <<string#0 pre-pended to the debug statement. After that (in the while loop), non of the calls to the method result in this behaviour. This example seems to suggest that the position of the datapointer may be what causes this.