Name

node (LzNode) — The base class for all Laszlo classes.

Synopsis

LZX: node
JavaScript: LzNode
Type: Class
Access: public
Topic: LZX.Basics
Declared in: WEB-INF/lps/lfc/core/LzNode.lzs

Description

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.

Superclass Chain

node (LzNode)

Known Subclasses

Known Direct Subclasses: animatorgroup (LzAnimatorGroup), command (LzCommand), LzContextMenu (as2), LzContextMenu (dhtml), LzContextMenuItem (as2), LzContextMenuItem (dhtml), datapointer (LzDatapointer), dataset (LzDataset), datasource (LzDatasource), layout (LzLayout), script (LzScript), state (LzState), class (LzUserClass), view (LzView)

Details

Static Properties (1)

UIDs
static public var UIDs = 0.0;

Initial Attributes (1)

Initial Attributes are given as attributes in LZX but are not generally available as properties in JavaScript.

ignoreplacement
<attribute name="ignoreplacement" />
Overrides placement attribute (and defaultplacement in lexical parent). See the LzNode.determinePlacement method. Defaults to false.

Properties (19)

children
<attribute name="children" />
public var children = null;
classroot
<attribute name="classroot" type="lzNode" />
public var classroot : LzNode;
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
<attribute name="cloneManager" type="lzNode" />
public var cloneManager : LzNode = null;
If this node is replicated due to data replication, the LzReplicationManager which controls this node.
datapath
<attribute name="datapath" type="string" />
public var datapath : String = null;
Specifies the data source for this node and its children. If the value begins with an identifier followed by a colon, the identifier names a dataset, and the portion of the string after the colon is an XPath description of a portion of the data. Otherwise the entire attribute value is an XPath description of the data, relative to the data source of this node's parent element. Examples: "mydata:", "mydata:/a/b", "/a/b".
defaultattrs
<attribute name="defaultattrs" value="{ ... }" />
public var defaultattrs = { ... };
defaultplacement
<attribute name="defaultplacement" type="string" />
public var defaultplacement : String = null;
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.
dependencies
<attribute name="dependencies" />
public var dependencies = null;
doneClassRoot
<attribute name="doneClassRoot" />
public var doneClassRoot = false;
id
<attribute name="id" type="xsd:ID" />
public final var id : String = null;
A unique identifier for this element. Can be used as a global variable name in JavaScript code.
immediateparent
<attribute name="immediateparent" type="lzNode" />
public var immediateparent : LzNode = null;
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
<attribute name="initstage" type=""early" | "normal" | "late" | "immediate" | "defer"" value=""normal"" />
public final var initstage : String = null;
The execution of a node's init method and sending of the oninit event is under the control of its initstage attribute, as follows:
immediate
The init method is called immediately as the last stage 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 the parent is initialized.
late
The init method is called during idle time. To check whether init has been called, check the isinited property. Force calling init using the completeInstantiation method.
defer
The init method will not be called unless explicitly requested by the completeInstantiation method.
isinited
<attribute name="isinited" type="boolean" />
public read-only var isinited : boolean = false;
Indicates that a node's init method has been called. The execution of the init method is under control of the initstage attribute.
name
<attribute name="name" type="string" />
public final var name : String = null;
The name for this subnode. If given, then this node's parent and immediate parent will store a pointer to this node as the given name value.
nodeLevel
<attribute name="nodeLevel" type="number" />
public var nodeLevel : Number;
The depth of this node in the overall node hierarchy
parent
<attribute name="parent" />
public var parent;
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
<attribute name="placement" type="string" />
public final var placement : String = null;
Instructions to this element's container about where it should go within its container's internal hierarchy. See the LzNode.determinePlacement method. Defaults to the container itself.
setters
<attribute name="setters" value="{ ... }" />
public var setters = { ... };
sourceLocatorTable
<attribute name="sourceLocatorTable" value="{ ... }" />
public var sourceLocatorTable = { ... };
subnodes
<attribute name="subnodes" type="array" />
public var subnodes : Array = null;
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 (24)

animate()
<method name="animate" args="prop, to, duration, isRelative, moreargs" />
public function animate(prop : String, to : Number, duration : Number, isRelative : Boolean, moreargs : Object) : LzAnimator;
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.
applyConstraint()
<method name="applyConstraint" args="prop, cfunc, dep" />
public function applyConstraint(prop : String, cfunc : Function, dep : Array);
Applies a constraint for the given attribute.
applyData()
<method name="applyData" args="data" />
public function applyData(data : String);
Called on any node that is declared with a datapath that matches a terminal selector, such as text() or @attribute when the data it matches is changed.
childOf()
<method name="childOf" args="node" />
public function childOf(node : LzNode) : Boolean;
Tests whether the given node is a parent (or grand-parent, etc.) of this node.
completeInstantiation()
<method name="completeInstantiation" />
public function 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()
<method name="construct" args="parent, args" />
public function construct(parent : LzNode, args : Object);
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:
  • First, if the view has an ignoreplacement attribute with a true value, then the view will be placed directly under its lexical parent in all cases. The next steps are skipped.
  • Second, the placement view name is determined from the first of the following that matches:
  • Third, if there is no placement view name, the subview is placed within its lexical parent (that is, view.immediateparent = view.parent), and the next steps are skipped.
  • Fourth, the placement view name is looked up within the lexical parent by calling determinePlacement, and the result is taken as the view's placement view.
  • If this new placement view is a subview and it has a defaultplacement attribute, determinePlacement is called again. This process is repeated until no defaultplacement attribute is found to ensure that all placement directives are correctly followed.
createChildren()
<method name="createChildren" args="carr" />
protected function createChildren(carr : Array);
This function is used to instantiate subnodes. LzNodes may override or extend this method to change the meaning of attached subnodes.
dataBindAttribute()
<method name="dataBindAttribute" args="attr, path" />
public function dataBindAttribute(attr : String, path : String);
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.
destroy()
<method name="destroy" args="recursiveCall" />
public function destroy(recursiveCall : Boolean);
Deletes the node and all the subnodes.
determinePlacement()
<method name="determinePlacement" args="aSub, placement, args" />
protected function determinePlacement(aSub : LzNode, placement : String, args : dictionary);
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.
getAttribute()
<method name="getAttribute" args="prop" />
public function getAttribute(prop : String) : any;
returns the value for a property
getOption()
<method name="getOption" args="key" />
public function getOption(key : String) : any;
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
getUID()
<method name="getUID" />
public function getUID() : String;
Returns the unique ID of the node.
init()
<method name="init" />
public function init();
Called at the same time that the node sends its oninit event -- usually when the node's siblings are instantiated, and always after the node's children are instantiated.
initialize()
<method name="initialize" args="parent, attrs, children, instcall" />
public function initialize(parent : LzNode, attrs : Object, children : Object, instcall : Boolean);
lookupSourceLocator()
<method name="lookupSourceLocator" args="sourceLocator" />
public function lookupSourceLocator(sourceLocator : String) : any;
Translate a source locator to the corresponding node
__LZinstantiationDone()
<method name="__LZinstantiationDone" />
protected function __LZinstantiationDone();
Called when the node's subnodes have finished instantiating. If this node's parent is inited, this method clears the queue of nodes awaiting init.
searchImmediateSubnodes()
<method name="searchImmediateSubnodes" args="prop, val" />
public function searchImmediateSubnodes(prop : String, val : any) : LzNode;
Searches immediate subnodes for the given value of the given property.
searchSubnodes()
<method name="searchSubnodes" args="prop, val" />
public function searchSubnodes(prop : String, val : any) : LzNode;
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.
setAttribute()
<method name="setAttribute" args="prop, val" />
public function setAttribute(prop : String, val : any);
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.
setDatapath()
<method name="setDatapath" args="dp" />
public function setDatapath(dp : String);
Sets the datacontext for the node to the xpath given as an argument
setID()
<method name="setID" args="id" />
protected function setID(id : String);
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')
setName()
<method name="setName" args="name" />
protected function setName(name : String);
Sets the name of the node.
setOption()
<method name="setOption" args="key, val" />
public function setOption(key : String, val : any);
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)

Events (5)

onclonenumber
<attribute name="onclonenumber" />
public event onclonenumber;
onconstruct
<attribute name="onconstruct" />
public event onconstruct;
This is the first event a node sends, right at the end of the instantiation process, but before any subnodes have been created or references resolved
ondata
<attribute name="ondata" />
public event ondata;
The ondata script is executed when the data selected by a view's datapath changes.
ondestroy
<attribute name="ondestroy" />
public event ondestroy;
oninit
<attribute name="oninit" />
public event oninit;
This event is sent right before a node becomes active -- e.g. before a view displays, or before a layout affects its subviews.

LZX Synopsis

<class name="LzNode">
  <attribute name=" children " />
  <attribute name=" classroot " type="lzNode" />
  <attribute name=" cloneManager " type="lzNode" />
  <attribute name=" datapath " type="string" />
  <attribute name=" defaultattrs " value="{ ... }" />
  <attribute name=" defaultplacement " type="string" />
  <attribute name=" dependencies " />
  <attribute name=" doneClassRoot " />
  <attribute name=" id " type="xsd:ID" />
  <attribute name=" immediateparent " type="lzNode" />
  <attribute name=" initstage " type=""early" | "normal" | "late" | "immediate" | "defer"" value=""normal"" />
  <attribute name=" isinited " type="boolean" />
  <attribute name=" name " type="string" />
  <attribute name=" nodeLevel " type="number" />
  <attribute name=" parent " />
  <attribute name=" placement " type="string" />
  <attribute name=" setters " value="{ ... }" />
  <attribute name=" sourceLocatorTable " value="{ ... }" />
  <attribute name=" subnodes " type="array" />
  <method name=" animate " args="prop, to, duration, isRelative, moreargs" />
  <method name=" applyConstraint " args="prop, cfunc, dep" />
  <method name=" applyData " args="data" />
  <method name=" childOf " args="node" />
  <method name=" completeInstantiation " />
  <method name=" construct " args="parent, args" />
  <method name=" createChildren " args="carr" />
  <method name=" dataBindAttribute " args="attr, path" />
  <method name=" destroy " args="recursiveCall" />
  <method name=" determinePlacement " args="aSub, placement, args" />
  <method name=" getAttribute " args="prop" />
  <method name=" getOption " args="key" />
  <method name=" getUID " />
  <method name=" init " />
  <method name=" initialize " args="parent, attrs, children, instcall" />
  <method name=" lookupSourceLocator " args="sourceLocator" />
  <method name=" __LZinstantiationDone " />
  <event name=" onclonenumber " />
  <event name=" onconstruct " />
  <event name=" ondata " />
  <event name=" ondestroy " />
  <event name=" oninit " />
  <method name=" searchImmediateSubnodes " args="prop, val" />
  <method name=" searchSubnodes " args="prop, val" />
  <method name=" setAttribute " args="prop, val" />
  <method name=" setDatapath " args="dp" />
  <method name=" setID " args="id" />
  <method name=" setName " args="name" />
  <method name=" setOption " args="key, val" />
</class>

JavaScript Synopsis

public LzNode {
  static public var UIDs  = 0.0;
  public var children  = null;
  public var classroot  : LzNode;
  public var cloneManager  : LzNode = null;
  public var datapath  : String = null;
  public var defaultattrs  = { ... };
  public var defaultplacement  : String = null;
  public var dependencies  = null;
  public var doneClassRoot  = false;
  public final var id  : String = null;
  public var immediateparent  : LzNode = null;
  public final var initstage  : String = null;
  public read-only var isinited  : boolean = false;
  public final var name  : String = null;
  public var nodeLevel  : Number;
  public var parent ;
  public final var placement  : String = null;
  public var setters  = { ... };
  public var sourceLocatorTable  = { ... };
  public var subnodes  : Array = null;
  prototype public function animate (prop : String, to : Number, duration : Number, isRelative : Boolean, moreargs : Object) : LzAnimator;
  prototype public function applyConstraint (prop : String, cfunc : Function, dep : Array);
  prototype public function applyData (data : String);
  prototype public function childOf (node : LzNode) : Boolean;
  prototype public function completeInstantiation ();
  prototype public function construct (parent : LzNode, args : Object);
  prototype protected function createChildren (carr : Array);
  prototype public function dataBindAttribute (attr : String, path : String);
  prototype public function destroy (recursiveCall : Boolean);
  prototype protected function determinePlacement (aSub : LzNode, placement : String, args : dictionary);
  prototype public function getAttribute (prop : String) : any;
  prototype public function getOption (key : String) : any;
  prototype public function getUID () : String;
  prototype public function init ();
  prototype public function initialize (parent : LzNode, attrs : Object, children : Object, instcall : Boolean);
  prototype public function lookupSourceLocator (sourceLocator : String) : any;
  prototype protected function __LZinstantiationDone ();
  prototype public event onclonenumber ;
  prototype public event onconstruct ;
  prototype public event ondata ;
  prototype public event ondestroy ;
  prototype public event oninit ;
  prototype public function searchImmediateSubnodes (prop : String, val : any) : LzNode;
  prototype public function searchSubnodes (prop : String, val : any) : LzNode;
  prototype public function setAttribute (prop : String, val : any);
  prototype public function setDatapath (dp : String);
  prototype protected function setID (id : String);
  prototype protected function setName (name : String);
  prototype public function setOption (key : String, val : any);
}