我有一个以下代码片段,它在OL 3.3和OL 4.9中提供了预期的结果。
当我将代码与我的OL4.9应用程序集成时,出于某种原因,我在Openlaszlo 4.9中将'parts'作为null。我无法弄清楚原因。以下代码是否正确?
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>
答案 0 :(得分:1)
这可能是4.9唯一的问题。我测试了flex4.6分支,这是我的输出。
flex4.6分支,swf11运行时:
_populateList «LzDataElement#0| <root><child1/><child2><sub/><sub/></child2><tracker sequence_number="1" next="NULL"/></root>»
_populateList dp «<datapointer>#1| <root><child1/><child2><sub/><sub/></child2><tracker sequence_number="1" next="NULL"/></root>»
parts:: «LzDataElement#2| <tracker sequence_number="1" next="NULL"/>»
flex4.6分支,DHTML运行时
_populateList «LzDataElement#0| <root><child1/><child2><sub/><sub/></child2><tracker sequence_number="1" next="NULL"/></root>»
_populateList dp «<datapointer>#1| <root><child1/><child2><sub/><sub/></child2><tracker sequence_number="1" next="NULL"/></root>»
parts:: «LzDataElement#2| <tracker sequence_number="1" next="NULL"/>»
您在4.9中看到的输出是什么?我没有在这里安装4.9进行测试。