Table of Contents
The instantiation of LzNode
objects such as
LzView
and LzLayout
is a
multi-phase procedure, but in general, you do not need to know the
details of the instantiation of view objects; they "just work". In
rare cases, you will need to understand the details of the process.
Parts of the process can be deferred to speed startup of an
application.
This chapter assumes you are familar with classes and objects. In the
descriptions below, we distinguish between creation, by
which we mean storage for the object is allocated and constant
properties assigned — a process that cannot be customized — and
initialization, by which we mean the instantiation of
children and the application of computed attributes, which can be
customized (by overriding the init()
method). These
two processes together are referred to as instantiation.
At a high level, the initialization of a LzNode
,
the calling of its init()
method, and sending of the
oninit()
event is under the control of its
initstage
attribute, as follows:
immediate
Initialization happens immediately as the last stage of
instantiation
.
early
Initialization happens right after the view and its children
have been created
.
normal
Initialization happens when the parent is
initialized
.
late
Initialization happens during idle time. To check whether the
view has been initialized, check the isinited
property. Force initialization using the
completeInstantiation()
method.
defer
Initialization will not happen unless explicitly requested by
calling the completeInstantation()
method.
When a node is instantiated, its
attributes are the attributes explicitly given in the object, plus any
attributes that the class specifies. Similarly, its children will be
the childen explicitly given in the object, plus any children that are
specified in the class. The class construct()
method
is called, with these attributes and the parent view.
The steps happen in the following sequence:
A single dictionary is created which combines the attributes of the instance with the attributes of the class
A single array is created which combines the children of the instance with the children of the class
construct(
is called.
args
, parent
)
is a dictionary of your attributes (does not
include expressions, such args
width="${parent.width}"
),
is the lexical parent. This method can only be
declared in a class, not in an instance. You can modify the
arguments or the parent before calling
parent
super.construct
.
Any <handler name="
for the class or
event handlers (e.g. onclick in the tag) for the class are created
for the instance
...
">
Attributes with when="immediately"
values are applied
Attributes with no setters are set
Special LFC attributes are set
Attributes with setters (<attribute name="foo"
value="0" setter="setfoo(foo)"
/>
). setfoo(0)
will be called before
initialization and before children are instantiated, but after you
have a parent and the attributes mentioned above applied)
createChildren()
is called with an
array of children with the superclass' children first (deepest
first). There are two options for how children are created:
synchronously and asynchronously. When whichever method is chosen
completes, __LZinstantiationDone
will be called on this
instance.
No other code can run until all the children for this instance are created
intstage="immediate"
new
or any
trailing args are omitted, e.g. classname
(parent
, args
, children
, false)new classname(
parent
,
args
)
Children for this
instance will be put on the LzInstantiator
queue and
created later.
After the children have been created, initialization will happen if:
otherwise initialization will be triggered by this instance's
immediateparent
being initialized.
Initialization
Copyright © 2002-2007 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.