PDA

View Full Version : Replication with lzDataElement


carlos.goncalve
10-21-2004, 03:09 PM
Hi,

I have a lzDataElement that has the follow structure:

<QueryCategoriesResponse>
<QueryCategoriesResult>
<CategoryInfo>
<Id></Id>
<Name></Name>
</CategoryInfo>
<CategoryInfo>
<Id></Id>
<Name></Name>
</CategoryInfo>
.
.
.
</QueryCategoriesResult>
</QueryCategoriesResponse>

I and have to bind the CategoryInfo node with this view:

<view id="vwCategories">
<text />
<text />
</view>

where the text nodes must be replicate for each CategoryInfo node in the lzDataElement. The first must show the contents of the Id node and the second, the name node. How do I do this data binding without a dataset ? I donīt have any dataset in my app since this lzDataElement is returned by a remotecall (soap).

Tks in advance,
Carlos.

marcovth
10-21-2004, 03:14 PM
It seems to me we have a similar question, and
I still haven't figure it out.

There doesn't seem to be a loop or repeater tag.

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=1286

- Marco.

carlos.goncalve
10-25-2004, 10:53 AM
Could be like this:

<view id="vwCategories">
<datapath xpath="CategoryInfo"/>
<text text="$path{'Name/text()'}">
<attribute name="id" value="$path{'Id/text()'}" />
</text>
</view>

The remotecall that return the data:

<remotecall name="rQueryCategories" funcname="QueryCategories">
<method event="ondata" args="value">
debug.Inspect(value);
//call the code below
</method>
</remotecall>

And in the ondata event of the remotecall:

//value is a LzDataElement passed to the ondata
//event - returned by the remotecall
var pointer = new LzDatapointer();
pointer.setPointer(value.getFirstChild());
vwCategories.datapath.setPointer(pointer.xPathQuer y("CategoryInfo"));

But this is a little confused and cumbersome for binding a lot of controls. Itīs better always use a dataset:


<dataset name="dsCategories" />

<remotecall name="rQueryCategories" funcname="QueryCategories"
dataobject="dsCategories">
<method event="ondata" args="value">
debug.Inspect(value);
//call the code below
</method>
</remotecall>

And bind the controls with an xpath expression:

<view id="vwCategories" datapath="dsCategories:/QueryResult/CategoryInfo">
<text text="$path{'Name/text()'}">
<attribute name="id" value="$path{'Id/text()'}" />
</text>
</view>

ows
10-28-2004, 02:19 PM
Yes, carlos.goncalve is correct: the datapath attribute can handle repetition, so there is no need for a separate repeater tag.

For an example of how this works, take a look at the Data section of the Laszlo Explorer (http://www.laszlosystems.com/lps/laszlo-in-ten-minutes/).

One thing we like about this approach is that it makes it easy to go from a static interface:

<text text="static text"/>

to an interface that is bound against a single data element:

<text datapath="dset:/contact/@phone"/>

to one that is bound against as many elements as are present (the same user interface code as above, but with a different dataset).