The base class for all Laszlo classes.
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 |
| class | Tag only | token | final | ||
|
The CSS class of a node |
|||||
|
|
|||||
| classroot | JS only | LzNode | readonly | ||
a reference to the node that is an instance
of the <class> where this node is defined.
Members of state subclasses do not define classroot.
This is convenient to use when you want to access an attribute of the
class in a method or event handler that is nested deep in the node
hierarchy. For example, to set the bgcolor of the class object,
instead of
parent.parent.parent.setAttribute(bgcolor, 0xFFFFFF)
you can simply use classroot.setAttribute(bgcolor, 0xFFFFFF). |
|||||
|
|
|||||
| cloneManager | JS only | LzNode | readonly | ||
| If this node is replicated due to data replication, the LzReplicationManager which controls this node. | |||||
|
|
|||||
| datapath | Tag & JS | string | LzDatapath | readonly | |
| A pointer to the LzDatapath attached to this node, if there is one. | |||||
|
|
|||||
| defaultplacement | Tag & JS | string | String | readonly | |
| An attribute used in container classes. If set to a non-null value, this forces this node to run its determinePlacement method for any node whose parent is this node. If the subnode has its own placement attribute, determinePlacement will be called with that value, otherwise it will be called with this value. Note that a class's defaultplacement attribute only applies to children in subclasses or in instances, not to the children of the class itself. This means that if a class and its subclass both define a defaultplacement attribute, the attribute will be set to one value before the subclass children are created and to a different one after they are created. See the determinePlacement method. | |||||
|
|
|||||
| 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 | |||||
|
|
|||||
| ignoreAttribute | JS only | Boolean | readonly | ||
| Setting an argument attribute to this value in the construct routine of a subclass of LzNode will prevent further processing of the attribute | |||||
|
|
|||||
| ignoreplacement | Tag only | boolean | final | ||
|
Overrides placement attribute (and defaultplacement in lexical parent). See
the |
|||||
|
|
|||||
| immediateparent | JS only | LzNode | readonly | ||
| Reference to this nodes's parent in the node hierarchy. This will be different from "parent" when a class uses placement or defaultplacement to assign a subnode a specific place. For example, always use immediateparent to get a mouse position in your views coordinate system. | |||||
|
|
|||||
| initstage | Tag only | early | normal | late | immediate | defer | normal | final | |
|
The execution of a
|
|||||
|
|
|||||
| 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 | |||||
|
|
|||||
| nodeLevel | JS only | Number | readonly | ||
| The depth of this node in the overall node hierarchy | |||||
|
|
|||||
| onconstruct | JS only | Script | eventhandler | ||
| This script will be run right at the end of the instantiation process, but before any subnodes have been created or references resolved | |||||
|
|
|||||
| 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. | |||||
|
|
|||||
| placement | Tag only | string | final | ||
|
Instructions to this element's container about where it should go
within the its container's internal hierarchy. See
the |
|||||
|
|
|||||
| 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. | |||||
|
|
|||||
| animate() | ||
| LzNode.animate(prop, to, duration, isRelative, moreargs) | ||
|
animate is the simplest way to animate a property of a node. This method creates an animator which will change the value of the given property over the given duration. The result of this call is an LzAnimator object. Note that the animation is asynchronous -- that is, code that follows this call will be executed before the animation finishes. Calling this method with a duration of 0 does not create an animator, but instead just calls setAttribute. |
||
| Parameters | ||
| Name | Type | Desc |
| prop | String | a string specifying the property to animate. public properties are: x, y, width, height, rotation, alpha |
| to | Number | the end value of the animation |
| duration | Number | the duration of the animation |
| isRelative | Boolean | is the animator applied to the property relatively or not |
| moreargs | Object | A dictionary of attributes to pass to the LzAnimator constructor |
| Returns | ||
| Type | Desc | |
| LzAnimator | a reference to the animator that was added | |
|
|
||
| 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" ] |
|
|
||
| applyData() | ||
| LzNode.applyData(data) | ||
|
Called on any node that is declared with a datapath that matches a
terminal selector, such as |
||
| Parameters | ||
| Name | Type | Desc |
| data | String | a string representing the matching data |
|
|
||
| childOf() | ||
| LzNode.childOf(node) | ||
|
Tests whether the given node is a parent (or grand-parent, etc.) of this node. |
||
| Parameters | ||
| Name | Type | Desc |
| node | LzNode | The node to test to see if it is somewhere above this one in the node hierarchy |
| Returns | ||
| Type | Desc | |
| Boolean | true if this node is a child of the given node. | |
|
|
||
| completeInstantiation() | ||
| LzNode.completeInstantiation() | ||
|
Ensures that the children of this node have been created, and this node has been inited. The LFC does this automatically for nodes with initstage other than "late" or "defer". Call this function to force instantiation to complete synchronously for nodes with initstage="late", and to force it to happen at all for nodes with initstage="defer". |
||
|
|
| construct() | ||
| LzNode.construct(parent, args) | ||
|
The construct() method of a node is called as early as possible -- before any arguments have been applied. This is the method to override in lieu of writing a class constructor for your LZX class. If you override this method, you must call the superclass method or your results will be extremely unpredictable. Note that construct can only be overriden within a subclass definition, not within a customized instance. The construct method is also responsible for placing the newly-built view into the appropriate place within its lexical parent's view hierarchy. The process for this is as follows:
|
||
| Parameters | ||
| Name | Type | Desc |
| parent | LzNode | The node that encloses this node in source, or the node to which to attach this node. |
| args | Object | A dictionary of initialization arguments that should be applied to the instance. This contains any arguments that are default arguments written in the class definition. |
|
|
||
| createChildren() | ||
| LzNode.createChildren(carr) | ||
|
This function is used to instantiate subnodes. LzNodes may override or extend this method to change the meaning of attached subnodes. |
||
| Parameters | ||
| Name | Type | Desc |
| carr | Array | an array of children where the structure of each child [c] takes the form: c.name = a string containing the name of the child -- usually its constructor c.args = a dictionary of attributes and values to be passed to the constructor of that child c.children = an array of children for the new child |
|
|
||
| dataBindAttribute() | ||
| LzNode.dataBindAttribute(attr, path) | ||
|
Binds the named attribute to the given path, relative to this node's datapath. This is the method that is called when the $path{} constraint is used. Note that the binding is two-way -- changing the value of the attribute will update the data. |
||
| Parameters | ||
| Name | Type | Desc |
| attr | String | The name of the attribute to bind to the given path. |
| path | String | The xpath (relative to this node's datapath) to which to bind the attribute. |
|
|
||
| destroy() | ||
| LzNode.destroy(recursiveCall) | ||
|
Deletes the node and all the subnodes. |
||
| Parameters | ||
| Name | Type | Desc |
| recursiveCall | Boolean | internal use only |
|
|
||
| determinePlacement() | ||
| LzNode.determinePlacement(aSub, placement, args) | ||
|
Determines the immediateparent for a subnode whose parent is this node. This method will only be called for subnodes which have a placement attribute, or for all subnodes if this node has a non-null defaultplacement. The placement attribute of a subnode overrides a parent's defaultplacement. This method looks for a subnode with the name given in the placement parameter, and returns that node. If no such named node exists, it returns 'this'. A subclass might implement this method to cause the "placement" parameter to have a different behavior or additional effects. Note that this function is not currently designed to be called by anyone but LzNode.construct. Do not expect to be able to 'place' a view properly after it has been constructed. |
||
| Parameters | ||
| Name | Type | Desc |
| aSub | LzNode | The new subnode |
| placement | String | The placement attribute for the new subnode |
| args | dictionary | The initialization args for the new subnode |
| Returns | ||
| Type | Desc | |
| LzNode | the node which will be the immediateparent of aSub | |
|
|
||
| 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 | |
|
|
||
| getOption() | ||
| LzNode.getOption(key) | ||
|
Returns the value for an option (set with the options= attribute) for nodes created from LZX, or from the dictionary passed as the options attribute to the node constructor from script |
||
| Parameters | ||
| Name | Type | Desc |
| key | String | The option to retrieve |
| Returns | ||
| Type | Desc | |
| any | The value for that option (or undefined, if the option has not been set) | |
|
|
||
| getUID() | ||
| LzNode.getUID() | ||
|
Returns the unique ID of the node. |
||
| Returns | ||
| Type | Desc | |
| String | A string representing a unique ID for the node. | |
|
|
||
| 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. |
||
|
|
| lookupSourceLocator() | ||
| LzNode.lookupSourceLocator(sourceLocator) | ||
|
Translate a source locator to the corresponding node |
||
| Parameters | ||
| Name | Type | Desc |
| sourceLocator | String | the locator to translate |
| Returns | ||
| Type | Desc | |
| any | Either the corresponding LzNode or undefined if the source locator is unknown | |
|
|
||
| searchImmediateSubnodes() | ||
| LzNode.searchImmediateSubnodes(prop, val) | ||
|
Searches immediate subnodes for the given value of the given property. |
||
| Parameters | ||
| Name | Type | Desc |
| prop | String | The attribute name to search for |
| val | any | The value of the attribute. |
| Returns | ||
| Type | Desc | |
| LzNode | The a pointer to subnode with the given property | |
|
|
||
| searchSubnodes() | ||
| LzNode.searchSubnodes(prop, val) | ||
|
Searches subnodes for the given value of the given property. Note that in this release, searchSubnodes actually searches only subviews (and thus is identical to LzView.searchSubiews). This bug will be fixed in a future release. |
||
| Parameters | ||
| Name | Type | Desc |
| prop | String | The attribute name to search for |
| val | any | The value of the attribute. |
| Returns | ||
| Type | Desc | |
| LzNode | The a pointer to subnode with the given property | |
|
|
||
| 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 |
|
|
||
| setDatapath() | ||
| LzNode.setDatapath(dp) | ||
|
Sets the datacontext for the node to the xpath given as an argument |
||
| Parameters | ||
| Name | Type | Desc |
| dp | String | The string to use as the datapath. |
|
|
||
| setID() | ||
| LzNode.setID(id) | ||
|
Sets the id of the given to the string given. Nodes that have an id can be referred to using just the id. The id is in the global namespace, unlike names which need to be references in a specific context (e.g. 'parent.myname' or 'this.myname', vs. simply using 'myid') |
||
| Parameters | ||
| Name | Type | Desc |
| id | String | The id to use for this node. |
|
|
||
| setName() | ||
| LzNode.setName(name) | ||
|
Sets the name of the node. |
||
| Parameters | ||
| Name | Type | Desc |
| name | String | A string to use for the name of this node. |
|
|
||
| setOption() | ||
| LzNode.setOption(key, val) | ||
|
Sets the value for an option (also set with the options= attribute for nodes created from LZX, or from the dictionary passed as the options attribute to the node constructor from script) |
||
| Parameters | ||
| Name | Type | Desc |
| key | String | The option to retrieve |
| val | any | The value for the option. |
|
|
||
| Events | |
| Name | Description |
| onconstruct | None |
| ondata | None |
| oninit | None |
Copyright © 2002-2005 Laszlo Systems, Inc. All Rights Reserved. Unauthorized use, duplication or distribution is strictly prohibited. This is the proprietary information of Laszlo Systems, Inc. Use is subject to license terms.