PDA

View Full Version : LZNode.getNodeName() method?


tspratt
01-26-2004, 11:27 AM
I want to walk down the LZNode tree, which I can using the LZNode.subNodes array.

But the subnodes are not usually <node>s, but are some subclass like <view>,<script>, etc.

I would like something analagous to the LZDataElement.nodeName property, or the LzDatapointer.getNodeName() method.

Is there any such functionality available?

vfunshteyn
02-06-2004, 04:45 PM
I think this is similar to what you want to do: http://www.mylaszlo.com/lps/max/treecontrol/treecontrol.lzx?lzt=html

tspratt
02-06-2004, 05:48 PM
that does not really help. It is just a data driven tree.

My problem is working with the LzNode "tree", that is, the client side, in-memory object structure that is the result of compiled lzx code.

In truth, I have worked around this, and the workaround is actually the better solution anyway.

Thanks again.
Tracy

vfunshteyn
02-06-2004, 06:02 PM
Originally posted by tspratt
that does not really help. It is just a data driven tree.

My problem is working with the LzNode "tree", that is, the client side, in-memory object structure that is the result of compiled lzx code.

Tracy

If you look at the source code of that app, it loads a specified URL as a general XML data structure into a dataset, which is then traversed using the LZX data API. Since any LZX app is also an XML document, you can call ds.setURL('<app name>.lzx?lzt=xml'), where ds is the name of the dataset that will hold your app.

tspratt
02-09-2004, 01:04 PM
I'm working strictly client-side, and need to work with the in-memory object tree.

So if i had:
<canvas ..
&nbsp;&nbsp;<view1 ..>
&nbsp;&nbsp;<view2...>
&nbsp;&nbsp;&nbsp;&nbsp;<text..>
&nbsp;&nbsp;&nbsp;&nbsp;<inputtext..>
&nbsp;&nbsp;&nbsp;&nbsp;<button...>
&nbsp;&nbsp;</view2>
</canvas>
...
(in memory, remember, the above does not exist anywhere as lzx source code.)

I want to do (in psuedo-code)
For Each subNode in view2.subNodes
if subNode.nodeName = 'inputtext' then ...
next

I think this is going to need to be a feature request.

Thanks!
Tracy

Grig
02-20-2004, 11:15 AM
In cases like this I usually:

Make each node responsible for itself

-or-

Make a dataset that represents the views which then instantiates the nodes I want.

-or-

Create a reporting mechanism for each view that builds it's own array of pointers to objects.

rsilvergun
09-16-2010, 07:09 PM
See my post here:

http://forum.openlaszlo.org/showthread.php?t=639&highlight=global+array

Long and short is give your nodes a custom attribute (I made mine 'type='CharacterBox' so you can identify them, then you can identify them with this.subnodes[i].type == 'CharacterBox' (or whatever). :)