我有以下代码片段,它在 OL 3.3 和 OL 4.9 中给出了预期的结果。
当我将代码与我的 OL4.9 应用程序集成时,出于某种原因,我在 Openlaszlo 4.9 中将“部件”设置为空。我无法弄清楚原因。下面的代码是否正确?
OL3.3
<canvas>
<attribute name="result" />
<attribute name="dp" value="$once{new LzDatapointer()}" />
<handler name="onresult">
_populateList();
</handler>
<method name="_populateList">
var node = LzDataNode.stringToLzData(result);
Debug.write('_populateList' , node);
dp.setPointer(node);
Debug.write('_populateList dp' , dp);
var parts = dp.xpathQuery('tracker');
Debug.write("parts::" , parts);
var partsArray = new Array();
if ( parts instanceof LzDataNode ) {
partsArray[0] = parts;
}
else if ( parts instanceof Array ) {
partsArray = parts;
}
</method>
<button name="sample">Click Me
<handler name="onclick"><![CDATA[
canvas.setAttribute('result','<root><child1/><child2><sub/><sub/></child2><tracker sequence_number="1" next="NULL"/></root> ');
]]></handler>
</button>
</canvas>
OL4.9
<canvas>
<attribute name="result" />
<attribute name="dp" value="$once{new lz.datapointer()}" />
<handler name="onresult">
_populateList();
</handler>
<method name="_populateList" >
var node = lz.DataElement.stringToLzData(result);
Debug.write('_populateList' , node);
dp.setPointer(node);
Debug.write('_populateList dp' , dp);
var parts = dp.xpathQuery('tracker');
Debug.write("parts::" , parts);
var partsArray = new Array();
if ( parts instanceof lz.DataElement ) {
partsArray[0] = parts;
}
else if ( parts instanceof Array ) {
partsArray = parts;
}
</method>
<button name="sample">Click Me
<handler name="onclick"><![CDATA[
canvas.setAttribute('result','<root><child1/><child2><sub/><sub/></child2><tracker sequence_number="1" next="NULL"/></root> ');
]]></handler>
</button>
</canvas>