lz.node
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.
Name (CSS property) | Type (tag) | Type (js) | Default | Category | ||||||
---|---|---|---|---|---|---|---|---|---|---|
classroot
|
lz.node | 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
|
lz.node | readonly | ||||||||
If this node is replicated due to data replication, the LzReplicationManager which controls this node. | ||||||||||
data
|
expression | Object | read/write | |||||||
The data context for the node | ||||||||||
datapath
|
string | String | read/write | |||||||
A shorthand version of <datapath> , specifies the data source for this node and its children.
You write a string to datapath ; reading datapath will yield a lz.datapath .
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".
|
||||||||||
defaultplacement
|
token | String | initialize-only | |||||||
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
|
token | String | initialize-only | |||||||
A unique identifier for this element. Can be used as a global variable name in JavaScript code. | ||||||||||
ignoreplacement
|
Boolean | "false" | initialize-only | |||||||
Overrides placement attribute (and defaultplacement in lexical parent). See the LzNode.determinePlacement method. Defaults to false. | ||||||||||
immediateparent
|
lz.node | 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. | ||||||||||
inited
|
boolean | readonly | ||||||||
Indicates that a node 's init
method has been called. True when init has been
called and the oninit event has been sent. The
execution of the init method is under control of
the initstage attribute.
|
||||||||||
initstage
|
"early" | "normal" | "late" | "immediate" | "defer" | String | "normal" | initialize-only | ||||||
The execution of a node 's init method and
sending of the oninit event is under the control
of its initstage attribute, as follows:
|
||||||||||
name
|
token | String | initialize-only | |||||||
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
|
Number | readonly | ||||||||
The depth of this node in the overall node hierarchy | ||||||||||
options
|
css | Object | initialize-only | |||||||
A CSS declaration of property:
value pairs that modify the
interaction of this node with controllers such as replicators and
layouts.
For example, setting options="ignorelayout: true" on
a view will cause the view to not be controlled by any layout.
|
||||||||||
parent
|
lz.node | 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
|
string | String | initialize-only | |||||||
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.
|
||||||||||
styleclass
|
string | String | read/write | |||||||
A space-separated list of CSS classes that can be used in a stylesheet to select this node. For example: <
The first selector applies to the first swatch; the second to the second; and all three selectors apply to the third swatch, with the latter taking precedence over the former. The final swatch has no styleclass and so uses the default value. |
||||||||||
subnodes
|
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. | ||||||||||
transition
|
string | String | read/write | |||||||
Allows node attributes to be automatically animated when set. A string of transitions, according to the css3 transition spec http://dev.w3.org/csswg/css3-transitions/#the-transition-shorthand-property- e.g. 'x 2s'. Note that transition-delay is not currently supported. [transition-property || transition-duration || transition-timing-function || transition-delay [, [transition-property || transition-duration || transition-timing-function || transition-delay]]* |
Methods
animate() |
---|
Parameter Name | Type | Description |
---|---|---|
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 |
applyConstraintMethod() |
---|
Parameter Name | Type | Description |
---|---|---|
constraintMethodName | String | The name of the method that will be invoked when any of the dependencies changes. Typically this method 'constrains' an attribute to a computation on the dependent attributes. E.g. `function constrain_foo () { this.setAttribute( 'foo' , this.x + myfriend.width ) }`. This method _must_ be a method on the instance to which you are applying the constraint. |
dependencies | 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() |
---|
text()
or
@attribute
when the data it matches is
changed.
childOf() |
---|
Parameter Name | Type | Description |
---|---|---|
node | lz.node | The node to test to see if it is somewhere above this one in the node hierarchy |
ignore | Boolean | Not used by LzNode, but see LzDataNodeMixin |
completeInstantiation() |
---|
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() |
---|
construct
method of a node is called as part of
the process of constructing a node. It is called after
attributes with constant initial values of the class have been filled in, but
before any attributes that have setters or have been constrained
have been applied.
This is the method to override if you need to initialize instances
of an LZX class as they are constructed. If you override this
method, you must call the superclass method (super.construct(parent,
args)
. 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:
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.
placement
attribute, if that
exists; or
defaultplacement
attribute,
if that exists; or
view.immediateparent = view.parent
),
and the next steps are skipped.
determinePlacement
, and the result is taken as the
view's placement view.
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.
Parameter Name | Type | Description |
---|---|---|
parent | lz.node | The node that encloses this node in source, or the node to which to attach this node. |
args | Object | A dictionary of attribute initializations for attributes that have setters or that have been supplied by the instance declaration. In general, your construct method should not modify this dictionary. It may delete a value from the dictionary to indicate that it has been handled by the construct method (and should not be further processed). |
createChildren() |
---|
Parameter Name | Type | Description |
---|---|---|
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() |
---|
Parameter Name | Type | Description |
---|---|---|
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. |
type | String | The type of the attribute |
destroy() |
---|
determinePlacement() |
---|
Note | |
---|---|
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. |
Parameter Name | Type | Description |
---|---|---|
aSub | lz.node | The new subnode |
placement | String | The placement attribute for the new subnode |
args | dictionary | The initialization args for the new subnode |
getOption() |
---|
options
attribute for
nodes created from LZX, or from the dictionary passed as the
options
attribute to the node constructor from
script. Individual options may also be added or updated at
runtime using setOption
.
Returns | Type | Description |
---|---|---|
any | The value for that option (or undefined, if the option has not been set) |
getUID() |
---|
init() |
---|
oninit
is sent, and the
inited
attribute will be
true
.
lookupSourceLocator() |
---|
Returns | Type | Description |
---|---|---|
any | Either the corresponding LzNode or undefined if the source locator is unknown |
releaseConstraint() |
---|
Parameter Name | Type | Description |
---|---|---|
attr | String | The name of the attribute to release the constraint from |
releaseConstraintMethod() |
---|
searchImmediateSubnodes() |
---|
Parameter Name | Type | Description |
---|---|---|
prop | String | The attribute name to search for |
val | any | The value of the attribute. |
searchSubnodes() |
---|
Parameter Name | Type | Description |
---|---|---|
prop | String | The attribute name to search for |
val | any | The value of the attribute. |
Returns | Type | Description |
---|---|---|
lz.node | A pointer to the first subnode with the given property or null if none is found |
setOption() |
---|
Note | |
---|---|
Options are used primarily for modifying the interaction of this node with controllers and replicators. Whether or not changing an option at runtime will affect a particular controller or replicator interaction is documented with each controller or replicator. |
setSelected() |
---|
Parameter Name | Type | Description |
---|---|---|
sel | boolean | true when this node was selected, false when it lost selection |
updateData() |
---|
Events
Copyright © 2002-2010 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.