Node(LzNode)

出自OpenFace

跳转到: 导航, 搜索

目录

<node>

The base class for all Laszlo classes. JavaScript: LzNode The LzNode class provides the basic interface for OpenLaszlo objects: parent/child hierarchy, setters, interaction with the instantiator, and reference resolution. New nodes (and subclasses thereof) can be created by new-ing the class, like this: var mynode= new LzNode( parent , args ); where parent is the parent for the new node, and args is an Object whose name/value pairs are attributes to be set on the new node.

Attributes

Name      Usage      Type(Tag)     Type(JS)     Default      Category

id       Tag & JS     ID      String                  readonly

        A global identifer for this node. If given, a pointer to this node with the given value will be placed in the global namespace


name    Tag & JS     token      String             readonly

      The name for this subnode. If given, then this node's parent and immediate parent will use store a pointer to this node as the given name value


oninit    Tag only   script                     eventhandler

       The oninit script is executed once, after the element's children, if any, have been initialized.



parent    JS only     LzNode                       readonly

      Reference to the node that was passed as this node's ancestor in the constructor. If this node was created by declaring it in a tag, the parent will be its lexical parent. Its lexical parent is the tag that encloses it. Allow a null parent so that nodes can be garbage collected when they are no longer needed. See also, immediateparent.


subnodes     JS only     Array                           readonly

         An array of all of the LzNodes which consider this LzNode their parent. This list is similar to the subviews list, but it contains all the children of this node, not just the view children.


Methods

applyConstraint()

LzNode.applyConstraint(prop, cfunc, dep) Applies a constraint for the given attribute.

Parameters Name Type Desc prop String The attribute to be constrained to the value of the expression cfunc Function The function that sets the attribute to the value. E.g. function () { this.setAttribute( 'foo' , someOtherFunction() ) } dep Array An array of (reference, attribute) pairs that the constraint depends on. For instance, if the constraint depends on my x and my friend's width, the dependencies array would look like this: [ this, "x" , myfriend, "width" ]


destroy()

LzNode.destroy(recursiveCall) Deletes the node and all the subnodes.

Parameters Name Type Desc recursiveCall Boolean internal use only


getAttribute()

LzNode.getAttribute(prop) returns the value for a property

Parameters Name Type Desc prop String a string specifying the key of attribute to return. Returns Type Desc any value of named property


init()

LzNode.init() Called at the same time that the node sends its oninit event -- usually when the nodes siblings are instantiated, and always after the node's children are instantiated.


setAttribute()

LzNode.setAttribute(prop, val) Sets the named attribute to the given value. If there is no setter for the property, this[ prop ] is set to the value, and the event this [ "on"+prop ] is sent.

Parameters Name Type Desc prop String A string naming the key of attribute to set val any The value for that attribute



Events

Name                       Description

ondata                        None

oninit                        None