Name

LzReplicationManager — The controller for views replicated by data.

Synopsis

JavaScript: LzReplicationManager
Type: Class
Access: public
Topic: LFC.Data
Declared in: WEB-INF/lps/lfc/data/LzReplicationManager.lzs

Description

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 LzReplicationManager) 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

<pre> <view name="replView" datapath="somedata:/*"> </pre>

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 highlited 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 
     
     <attribute name="cnum" value="0"/>
 
   </button>
   <view name="replView" datapath="somedata:/*">
     <text datapath="name()"/>
   </view>
 </canvas>
 

Development Note

A replication manager controls the replication of views as a result of multiple matches to a datapath's xpath. When a datapath matches more than one node, it immediate halts its own processing and creates a replication manager to take over management of that datapath. If the view that contained the datapath being replicated was named, the replication manager assumes that name, so that it can be referred to the same way the non-replicated view would have been.

Superclass Chain

node (LzNode) » datapointer (LzDatapointer) » datapath (LzDatapath) » LzReplicationManager

Known Subclasses

Known Direct Subclasses: LzLazyReplicationManager

Details

Static Methods (1)

__LZemptyFuntion()
static private function __LZemptyFuntion();

Properties (11)

asyncnew
public var asyncnew = true;
checkDependentContexts
public var checkDependentContexts = null;
clones
public var clones : [LzNode];
The LzNodes which this LzReplicationManager has created.
datacontrolsvisibility
public var datacontrolsvisibility = false;
handleModify
public var handleModify = null;
__LZdataoffset
private var __LZdataoffset = 0.0;
__LZpreventXPathUpdate
private var __LZpreventXPathUpdate = false;
__LZtakeDPSlot
private var __LZtakeDPSlot = false;
nodes
public var nodes;
The nodes that this replication manager will map to views
pooling
public var pooling = false;
If true, the replication manager will reuse views it has alreay created if the data changes if possible. If false, the replication manager will always destroy views whose data has changed and create new ones.
visible
public var visible = true;

Setters (3)

Setters for virtual properties, to be used with setAttribute. A setter may or may not have a corresponding getter method; consult the Methods list in this section.

datapath
sortorder
sortpath

Methods (31)

ascDict()
private function ascDict(a, b);
construct()
private function construct(odp, args);
constructWithArgs()
private function constructWithArgs(args);
descDict()
private function descDict(a, b);
destroyClone()
private function destroyClone(v);
detachClone()
private function detachClone(cl);
getCloneForNode()
public function getCloneForNode(p : LzDataElement) : LzView;
Returns a clone which is mapped to the given data node.
getCloneNumber()
public function getCloneNumber(n : Number) : LzView;
Retuns a pointer to the nth clone controlled by the replication manager
getContext()
private function getContext(chgpkg);
getNewClone()
private function getNewClone(forceNew);
getNodeOffset()
private function getNodeOffset(p);
handleDeletedNode()
private function handleDeletedNode(c);
__LZadjustVisibleClones()
private function __LZadjustVisibleClones(lastnodes, newnodes);
__LZcheckChange()
private function __LZcheckChange(chgpkg);
__LZdiffArrays()
private function __LZdiffArrays(a, b);
returns the index at which the arrays differ
__LZHandleDocChange()
private function __LZHandleDocChange(who);
__LZHandleMultiNodes()
private function __LZHandleMultiNodes(n);
__LZHandleNoNodes()
private function __LZHandleNoNodes(n);
__LZHandleSingleNode()
private function __LZHandleSingleNode(n);
__LZneedsOpUpdate()
private function __LZneedsOpUpdate();
mergesort()
private function mergesort(arr, l, h);
orderf()
private function orderf(a, b);
poolClone()
private function poolClone();
reattachClone()
private function reattachClone(cl);
setComparator()
private function setComparator(comparator);
Sets the comparator for the sort used by the replication manager.
setDatapath()
public function setDatapath(xp : String);
This is an alias for the replication manager's setXPath method, but it is provided for compatibility with the view API, since replication managers take over the slot that a named replicated view occupied in the parent. (See comment on the class as a whole, above.)
setOrder()
private function setOrder(xpath : String, comparator);
Orders the replicated nodes based on the value of the path passed in.
setVisible()
public function setVisible(vis : Boolean);
Sets the visibility of all the clones controlled by the replication manager
setXPath()
private function setXPath(xp);
toString()
private function toString();
updateData()
private function updateData(a, b);

Events (3)

onclones
public event onclones;
onnodes
public event onnodes;
onvisible
public event onvisible;

JavaScript Synopsis

public LzReplicationManager extends  LzDatapath  {
  static private function __LZemptyFuntion ();
  public var asyncnew  = true;
  public var checkDependentContexts  = null;
  public var clones  : [LzNode];
  public var datacontrolsvisibility  = false;
  public var handleModify  = null;
  private var __LZdataoffset  = 0.0;
  private var __LZpreventXPathUpdate  = false;
  private var __LZtakeDPSlot  = false;
  public var nodes ;
  public var pooling  = false;
  public var visible  = true;
  prototype private function ascDict (a, b);
  prototype private function construct (odp, args);
  prototype private function constructWithArgs (args);
  prototype private function descDict (a, b);
  prototype private function destroyClone (v);
  prototype private function detachClone (cl);
  prototype public function getCloneForNode (p : LzDataElement) : LzView;
  prototype public function getCloneNumber (n : Number) : LzView;
  prototype private function getContext (chgpkg);
  prototype private function getNewClone (forceNew);
  prototype private function getNodeOffset (p);
  prototype private function handleDeletedNode (c);
  prototype private function __LZadjustVisibleClones (lastnodes, newnodes);
  prototype private function __LZcheckChange (chgpkg);
  prototype private function __LZdiffArrays (a, b);
  prototype private function __LZHandleDocChange (who);
  prototype private function __LZHandleMultiNodes (n);
  prototype private function __LZHandleNoNodes (n);
  prototype private function __LZHandleSingleNode (n);
  prototype private function __LZneedsOpUpdate ();
  prototype private function mergesort (arr, l, h);
  prototype public event onclones ;
  prototype public event onnodes ;
  prototype public event onvisible ;
  prototype private function orderf (a, b);
  prototype private function poolClone ();
  prototype private function reattachClone (cl);
  prototype private function setComparator (comparator);
  prototype public function setDatapath (xp : String);
  prototype private function setOrder (xpath : String, comparator);
  prototype public function setVisible (vis : Boolean);
  prototype private function setXPath (xp);
  prototype private function toString ();
  prototype private function updateData (a, b);
}