1

I have a following code snippet which gives the expected result in OL 3.3 and in OL 4.9.

When i integrate the code with my OL4.9 application, for some reason, i am getting 'parts' as null in Openlaszlo 4.9. I cannot figure out the reason. Is the following code correct?

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>
karthick
  • 11,998
  • 6
  • 56
  • 88

1 Answers1

1

This might be an 4.9 only problem. I tested with the flex4.6 branch, and here is my output.

flex4.6 branch, swf11 runtime:

_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 branch, DHTML runtime

_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"/>» 

What is the output you are seeing with 4.9? I don't have 4.9 installed here for testing.

raju-bitter
  • 8,906
  • 4
  • 42
  • 53
  • I am getting the same output in 4.9 compiler. But when i integrate the same with my main code i was facing the problem. I found what is the issue. I have a line like this 'dslogin.setAttribute('childNodes',new Array(loginResponse));' in between the dp.setPointer(node) and var parts = dp.xpathQuery('tracker'); I removed that line and placed after the tracker line and it started working. – karthick Sep 08 '12 at 11:46
  • As a standalone code it is working. And i don't understand after moving this line 'dslogin.setAttribute('childNodes',new Array(loginResponse));' below this line var parts = dp.xpathQuery('tracker'); i got the desired output. – karthick Sep 08 '12 at 11:49