The LzNode Class

The LzNode class is the ultimate parent of all LZX classes. It defines attributes, methods, and events that are inherited by all LZX objects. Here is the LzNode class’s constructor:

LzNode(parent, args)

Here, parent is the parent of the new LzNode object and args is a collection of attribute name/value pairs that are to be applied to the new object.

The more important child classes of LzNode are shown in Figure 1.7.

Figure 1.7. The more important subclasses of LzNode


These classes will be discussed in Chapter 2 and subsequent chapters.

We will now examine the attributes and methods of the LzNode class. Table 1.1 lists the attributes of the LzNode class. You will use this as a reference, so don’t worry if you do not understand them the first time you read this. For now, bear in mind there are two important attributes that identify an LzNode object: id and name. The id attribute must be unique throughout the application and provides a convenient way of referencing an object. The name attribute must be unique within a context and you must qualify its parents to reference it.

Table 1.1. The attributes of the LzNode class
NameUsageTypeDefaultAccessibility
classrootJS onlyLzNode read-only
 Description. A reference to the instance of the class tag in which this node is defined. This is a convenient shortcut to access a node from another node nested deep in the node hierarchy. For example, instead of writing parent.parent.parent.aMethod, you can use classroot.aMethod.
cloneManagerJS onlyLzNode read-only
 Description. The LzReplicationManager that controls this node upon replication.
datapathTag and JSLzDataPath read-only
 Description. A pointer to the LzDataPath object attached to this node, if one exists.
defaultplacementTag and JSstring read-only
 Description. A non-null value forces this node to run its determinePlacement method for any subnodes of this node. If a subnode has a different placement attribute, determinePlacement will be invoked with that value.
idTag and JSstring read-only
 Description. A global identifier for this node that must be unique throughout the whole application. Compare it with the name attribute that must be unique only in a context.
ignoreAttributeJS onlyboolean read-only
 Description. Setting an argument attribute to this value in the construct routine of a subclass of LzNode will prevent further processing of the attribute.
immediateparentJS onlyLzNode read-only
 Description. The immediate parent of this node. immediateparent is different from the parent attribute in that when a class uses placement or defaultplacement to assign a subnode a specific place. For instance, you always use immediateparent to obtain the mouse position of a view.
initstageTag only normalFinal
 Description. Determines the execution of the init method. The valid values are as follows:

immediate. The init method is called immediately as the last phase of instantiation.

early. The init method is called immediately after the view and its children have been instantiated.

normal. The init method is called when this node’s parent is initialized.

late. The init method is called during idle time. After the init method is called, the isinited property is set to true.

defer. The init method will not be called unless specifically invoked by the completeInstantiation method.
nameTag and JSstring read-only
 Description. An identifier for this node that must be unique within a context. Compare with the id attribute that must be unique throughout the application.
nodeLevelJS onlynumber read-only
 Description. The depth of this node in the node hierarchy.
onconstructJS onlyscript event handler
 Description. The event handler for the construct event, which is triggered at the end of the instantiation process but before any subnode is created or any reference resolved.
oninitTag onlyscript event handler
 Description. This event handler is called after the element’s subelements have been initialized. This handler is only called once.
parentJS onlyLzNode read-only
 Description. The parent of this node. If this node is created by using the tag, the parent is the tag enclosing the tag.
placementTag onlyString final
 Description. Defines the placement of this node within its container’s internal hierarchy.
subnodesJS onlyarray read-only
 Description. An array of all subnodes.

Note

JS in the Usage column in Table 1.1 indicates Javascript.


Here are the methods of the LzNode class

animate(property, to, duration, isRelative, args)

Animates a property. The parameters are as follows.

  • property. Specifies the property to animate.

  • to. The end value of the animation.

  • duration. The duration of the animation in milliseconds.

  • isRelative. Specifies if the value of the to argument is applied relative to the current value.

  • args. A dictionary of attributes to pass to the LzAnimator constructor. See Chapter 7, “Animation” for a complete discussion of animation.

applyConstraint(property, cFunction, dep)

Applies a constraint to the specified attribute. The arguments are as follows.

  • property. The attribute to which this constraint is to be applied.

  • cFunction. The function that specifies the constraint.

  • dep. An array of attribute pairs on which the constraint depends.

applyData(data)

Invoked on this LzNode if its datapath matches a terminal selector, such as text() or @attribute when the matching data changes.

childOf(node)

Tests if the specified node is a parent (either direct or indirect) of this node. Returns either true or false.

completeInstantiation()

Ensures this node’s children have been created and this node initialized.

construct(parent, args)

This method is the first method to be called when this LzNode is constructed. If you override this method, you must call super.construct(parent, args).

The arguments are as follows.

  • parent. The parent of this node, i.e. the node to which to attach this node.

  • args. A dictionary of attribute name/value pairs used to initialize this node.

createChildren(children)

Instantiates the subnodes. The argument children is an array of children.

dataBindAttribute(attribute, path)

Binds the named attribute to the specified path, relative to this node’s datapath. This method is called when the $path{} constraint is present. The arguments are as follows.

  • attr. The name of the attribute to bind to the specified path.

  • path. The xpath to which to bind the attribute.

destroy(recursive)

Deletes the node and all the subnodes. The recursive argument is either true or false and is for internal use only.

determinePlacement(subnode, placement, args)

Returns the immediate parent of the specified subnode, which must be a direct or an indirect child of this node. The arguments are

  • subnode. The subnode whose immediate parent is to be determined.

  • placement. The placement attribute for the returned subnode.

  • args. A dictionary of attribute name/value pairs for the returned subnode.

getAttribute(attribute)

Returns the value of the specified attribute.

getOption(key)

Returns the value of the specified key.

getUID()

Returns this node’s unique identifier.

init()

This method is invoked when the oninit event is raised.

lookupSourceLocator(sourceLocator)

Returns the LzNode that matches the sourceLocator argument. If no match was found, returns undefined.

searchSubnodes(attribute, value)

Returns the subnode that matches the specified attribute and value.

setAttribute(attribute, value)

Assigned the specified value to the specified attribute.

setDatapath(xpath)

Sets the datacontext for the node to the specified xpath.

setID(id)

Assigns the specified identifier to this node.

setName(name)

Sets the name of this node.

setOption(key, value)

Sets the specified key with the specified value.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset