When a view's datapath matches more than one data node, one instance
of the view is created for each match. The replicated views are
referred to as clones. When this happens, a
replication manager (or a subclass of
lz.ReplicationManager
) is created to manage the
clones. Replication managers are never directly instantiated —
they are created when a datapath makes multiple matches.
If the replicated view was named, the clone manager takes over the named spot in the parent. The example below demonstrates this, and shows how to reference individual clones.
In the example that follows, a view, called
replView
is bound to a dataset
somedata
. For each matching node in the dataset, a
new view is created. These views contain the text of the dataset. In
other words, the single line
<view name="replView" datapath="somedata:/*">
causes the creation of five views (because there were five elements
in the dataset that matched the selection criteria). These "cloned"
views are numbered successively, starting with zero. The highlighted
section of the code below shows how to use the
getCloneNumber
method to access each replicated
view.
<canvas
height
="140
">
<dataset
name
="somedata
">
<one
/> <two
/> <three
/> <four
/> <five
/>
</dataset
>
<simplelayout
/>
<button
onclick
="moveClone()
">
Move clone
<method
name
="moveClone
">
var nextClone = replView.getCloneNumber(this.cnum++);
if (nextClone == null) {
this.cnum = 0;
var nextClone = replView.getCloneNumber(this.cnum++);
}
nextClone.setAttribute('x', nextClone.x + 10);
</method
>
<attribute
name
="cnum
" value
="0
"/>
</button
>
<view
name
="replView
" datapath
="somedata:/*
">
<text
datapath
="name()
"/>
</view
>
</canvas
>
Name (CSS property) | Type (tag) | Type (js) | Default | Category |
---|---|---|---|---|
clones
|
[lz.node] | read/write | ||
The views which this LzReplicationManager has created. | ||||
nodes
|
[*] | read/write | ||
The data that this replication manager will map to views | ||||
visible
|
boolean | Boolean | true | initialize-only |
Globally controls the visibility of the clones this replication manager creates. |
classroot, cloneManager, data, datapath, defaultplacement, id, ignoreplacement, immediateparent, inited, initstage, name, nodeLevel, options, parent, placement, styleclass, subnodes, transition
Methods
addNode, addNodeFromPointer, comparePointer, deleteNode, deleteNodeAttribute, dupePointer, getDataset, getNodeAttribute, getNodeAttributes, getNodeCount, getNodeName, getNodeText, getNodeType, getXPathIndex, isValid, selectChild, selectNext, selectParent, selectPrev, serialize, setFromPointer, setNodeAttribute, setNodeName, setNodeText, setPointer, setXPath, xpathQuery
animate, applyConstraintMethod, applyData, childOf, completeInstantiation, construct, createChildren, dataBindAttribute, destroy, determinePlacement, getOption, getUID, init, lookupSourceLocator, releaseConstraint, releaseConstraintMethod, searchImmediateSubnodes, searchSubnodes, setOption, setSelected, updateData
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.