databinding-$7.lzx
<canvas width="100%" height="300">
<debug fontsize="12"/>
<include href="lztest/xmlequals.lzx"/>
<view layout="axis: y">
<dataset name="ds" src="http://..."/>
<text datapath="this.ds:/record/text()"/>
</view>
<class name="myclass" layout="axis: y">
<dataset name="ds" src="http://..."/>
<text datapath="this.ds:/record/text()"/>
</class>
<myclass/>
<myclass/>
<dataset name="gdata" src="resources/testdata.xml"/>
<simplelayout spacing="2"/>
<view name="nodatanoname" layout="axis: y" bgcolor="#cccccc">
<handler name="onclick">
Debug.debug("%w", this.localdata);
</handler>
<dataset/>
<text>empty local dataset with no name</text>
</view>
<view name="nodata" layout="axis: y" bgcolor="#cccccc">
<handler name="onclick">
Debug.debug("%w", this.lds);
</handler>
<dataset name="lds"/>
<text>empty local dataset</text>
</view>
<view name="somedata" layout="axis: y" bgcolor="#cccccc">
<handler name="onclick">
Debug.debug("%w", this.lds);
</handler>
<dataset name="lds">
<foo>bar</foo>
</dataset>
<text>local dataset</text>
<handler reference="lds" name="oninit">
Debug.debug("somedata test data loaded %w", this);
if (this.lds.serialize() != '<lds><foo>bar</foo></lds>') {
Debug.error("somedata serialized data does not match expected value");
}
</handler>
</view>
<view name="filedata" layout="axis: y" bgcolor="#cccccc">
<handler name="onclick">
Debug.debug("%w", this.lds);
</handler>
<dataset name="lds" src="resources/testdata.xml"/>
<text>local dataset compiled in from external file</text>
<handler reference="lds" name="oninit">
Debug.debug("filedata test data loaded %w", this);
if (! xmlstringequals(this.lds.serialize(), '<lds><persons><person id="1"><firstName>Dan</firstName><lastName>McGowan</lastName><modifyDate>3/25/05</modifyDate><address code="ML" id="1"><line1>2210 North 184th Street</line1><line2/><city>Shoreline</city></address></person><person id="2"><firstName>Barry</firstName><lastName>Bonds</lastName><modifyDate>3/25/05</modifyDate></person><person id="3"><firstName>Jeff</firstName><lastName>Beck</lastName><modifyDate>3/25/05</modifyDate></person></persons></lds>')) {
Debug.error("filedata serialized data does not match expected value");
}
</handler>
</view>
<view name="remotedata" layout="axis: y" bgcolor="#cccccc">
<handler name="onclick">
Debug.debug("%w", this.lds);
</handler>
<dataset name="lds" src="resources/testdata.xml" type="http" request="true"/>
<text>local dataset loaded at runtime</text>
<text datapath="local:parent.lds:/persons/person/firstName/text()" onclick="Debug.debug('%w', this.datapath)"/>
<handler reference="lds" name="ondata">
Debug.debug("remotedata test data loaded %w", this);
if (! xmlstringequals(this.lds.serialize(), '<lds><persons><person id="1"><firstName>Dan</firstName><lastName>McGowan</lastName><modifyDate>3/25/05</modifyDate><address id="1" code="ML"><line1>2210 North 184th Street</line1><line2/><city>Shoreline</city></address></person><person id="2"><firstName>Barry</firstName><lastName>Bonds</lastName><modifyDate>3/25/05</modifyDate></person><person id="3"><firstName>Jeff</firstName><lastName>Beck</lastName><modifyDate>3/25/05</modifyDate></person></persons></lds>')) {
Debug.error("remotedata serialized data does not match expected value");
}
</handler>
</view>
<view name="remotedatarelative" layout="axis: y" bgcolor="#cccccc" datapath="local:lds:/persons/" visible="true">
<handler name="onclick">
Debug.debug("%w", this.lds);
this.datapath.setXPath(this.datapath.xpath);
</handler>
<dataset name="lds" src="resources/testdata.xml" type="http" request="true"/>
<text>local dataset loaded at runtime and relative datapath - datapath doesn't resolve because dataset doesn't exist yet. click to reparse xpath</text>
<text datapath="person/firstName/text()" onclick="Debug.debug('%w', this.datapath)"/>
</view>
<class name="localdatatest">
<dataset/>
<view datapath="local:classroot:/">
<simplelayout/>
<handler name="onclick">
this.datapath.addNode('child', 'Click to remove this node', {});
</handler>
<text>Click to add a node to my local dataset</text>
<text x="10" datapath="child/text()" onclick="this.datapath.deleteNode();"/>
</view>
</class>
<class name="redlocaldatatest" extends="localdatatest" bgcolor="red"/>
<localdatatest/>
<localdatatest/>
<redlocaldatatest/>
</canvas>
Cross References
Includes
Classes
Named Instances