Name

datapath (LzDatapath) — The binder between data and nodes.

Synopsis

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

Usage

<view>
   <datapath xpath="xpath" sortorder="ascending"/>
 </view>
<view datapath="xpath" />

Description

Datapaths are used to merge data hierarchies with the hierarchy of an OpenLaszlo application. This is done using the the XPath syntax supported by LzDatapointer. When a node is given a datapath attribute, a datapath with the given value as its XPath is created. If the datapath retrieves a node (i.e. it doesn't terminate in an attribute getter or a () operator) then the node is mapped to that data context and all child nodes will implicitly share the datacontext, but no further action is taken. If the datapath retrieves data, rather than just a node, a few extra things happen. First, the node's data property is set and the node's ondata event is sent. Second, the node's applyData method is called with the data as the argument. In cases where a datapath matches more than one data node, the view with the matching datapath is replicated once for each data node that matches, and a LzReplicationManager takes over the view's spot in its parent.

A node can only have one datapath, and datapaths always have the name datapath. Additional options available on datapath such as pooling and replication are specified by writing the datapath tag as a separate node.

Example 6. Mapping data to views using datapaths

 
<canvas height="120">
   <dataset name="testdata">
     <Monday temp="Hi 48"> Partly Cloudly </Monday>
     <Tuesday temp="Hi 60"> Showers Likely </Tuesday>
     <Wednesday temp="Hi 63"> Chance Showers </Wednesday>
     <Thursday temp="Hi 58"> Mostly Sunny </Thursday>
     <Friday temp="Hi 50"> Clear and Cold </Friday>
   </dataset>
   <simplelayout spacing="5"/>
   <view datapath="testdata:/*">
     <view>
       <simplelayout axis="x"/>
       <text />
       <text />
       <text />
     </view>
   </view>
 </canvas>

Superclass Chain

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

Known Subclasses

Known Direct Subclasses: LzReplicationManager

Details

Properties (8)

datacontrolsvisibility
<attribute name="datacontrolsvisibility" type="boolean" />
public var datacontrolsvisibility : Boolean = true;
This attribute is deprecated, and should not be used. Developers should use a view's visible property to control visibility.
_dpevents
<attribute name="_dpevents" />
private var _dpevents;
these are the events that datapaths publish. This is used by the replication manager to copy and delegates that are registered when it replaces the original datapath
__LZisclone
<attribute name="__LZisclone" />
private var __LZisclone = false;
__LZtakeDPSlot
<attribute name="__LZtakeDPSlot" />
private var __LZtakeDPSlot = true;
pooling
<attribute name="pooling" type="boolean" />
public var pooling : Boolean;
This attribute applies to datapaths which match multiple nodes and force replication. See the section on Pooling in the Guide for information about the use of this attribute.
replication
<attribute name="replication" type="string" />
public var replication : String;
Determines whether to use normal or lazy replication, if the datapath matches more than one node. See the section on Replication in the Guide for information about the use of this attribute.
sortorder
<attribute name="sortorder" type="expression" />
public var sortorder : String|Function;
The order to use to sort the dataset if replication occurs. One of ascending or descending to use built in dictionary sort, or a function which compares two strings and returns 1 if the strings are in order, 0 if they are the same, and -1 if they are out of order. To change this attribute, call the setOrder or setComparator method.
sortpath
<attribute name="sortpath" type="string" />
public var sortpath : String;
An XPath to use to obtain the sort key for sorting if replication occurs. To change this attribute, call the setOrder method.

Setters (1)

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.

__LZmanager

Methods (21)

construct()
<method name="construct" args="v, args" />
private function construct(v, args);
destroy()
<method name="destroy" args="recur" />
private function destroy(recur);
Removes the datapath from its parent
__LZApplyData()
<method name="__LZApplyData" args="force" />
private function __LZApplyData(force);
__LZApplyDataOnInit()
<method name="__LZApplyDataOnInit" />
private function __LZApplyDataOnInit();
__LZcheckChange()
<method name="__LZcheckChange" args="chgpkg" />
private function __LZcheckChange(chgpkg);
__LZgetLast()
<method name="__LZgetLast" />
private function __LZgetLast();
__LZgetPosition()
<method name="__LZgetPosition" />
private function __LZgetPosition();
__LZHandleDocChange()
<method name="__LZHandleDocChange" args="who" />
private function __LZHandleDocChange(who);
__LZHandleMultiNodes()
<method name="__LZHandleMultiNodes" args="nodes" />
private function __LZHandleMultiNodes(nodes);
__LZsendUpdate()
<method name="__LZsendUpdate" args="upd, upp" />
private function __LZsendUpdate(upd, upp);
__LZsetCloneManager()
<method name="__LZsetCloneManager" args="m" />
private function __LZsetCloneManager(m);
__LZsetTracking()
<method name="__LZsetTracking" args="who, additive, needscheck" />
private function __LZsetTracking(who, additive : Boolean, needscheck : Boolean);
Overrides LzDatapointer.__LZsetTracking to handle the additive case
retrieveData()
<method name="retrieveData" />
private function retrieveData();
setClonePointer()
<method name="setClonePointer" args="p" />
private function setClonePointer(p);
Called by the clone manager to point the datapath to the right node
setComparator()
<method name="setComparator" args="comparator" />
public function setComparator(comparator);
Sets the comparator for the sort used by the replication manager.
setDataContext()
<method name="setDataContext" args="p, implicit" />
private function setDataContext(p, implicit);
setNodes()
<method name="setNodes" args="nodes" />
public function setNodes(nodes);
Normally, replication is started when a datapath xpath binding returns multiple nodes. This function overides that behavior and forces replication, and replicates over the list of nodes supplied to this function. Note that once this function is called, the replication manager is no longer actively bound to the data it replicates over by its xpath (if it had one); henceforth the replication set can *only* be controlled by calling setNodes.
setOrder()
<method name="setOrder" args="xpath, comparator" />
public function setOrder(xpath : String, comparator);
Orders the replicated nodes based on the value of the path passed in.
setSelected()
<method name="setSelected" args="torf" />
private function setSelected(torf);
toString()
<method name="toString" />
private function toString();
updateData()
<method name="updateData" />
public function updateData();
This method is used to transfer any values that may have been edited in a datamapped UI control back to the dataset. If the current datapath's xpath ends in a terminal selector (an attribute, text(), or name() expression), then the datapath attempts to call its parent's updateData method. If this method is defined, the datapath sets the data element's attribute, text, or name, respectively, to updateData's return value. The method then calls any other updateData on any datapaths which depend on this one for context. In short, to make datamapping work both ways for a given UI control, define a updateData method that returns the value for the data mapped to the node. This is already done for the base LzInputText class, but not for any other LFC classes.

Prototype Properties (1)

rerunxpath
<attribute name="rerunxpath" />
public var rerunxpath = true;
By default, this is false for instances of datapointer, and true for instances of datapath.

LZX Synopsis

<class name="LzDatapath" extends=" LzDatapointer ">
  <attribute name=" datacontrolsvisibility " type="boolean" />
  <attribute name=" _dpevents " />
  <attribute name=" __LZisclone " />
  <attribute name=" __LZtakeDPSlot " />
  <attribute name=" pooling " type="boolean" />
  <attribute name=" replication " type="string" />
  <attribute name=" sortorder " type="expression" />
  <attribute name=" sortpath " type="string" />
  <method name=" construct " args="v, args" />
  <method name=" destroy " args="recur" />
  <method name=" __LZApplyData " args="force" />
  <method name=" __LZApplyDataOnInit " />
  <method name=" __LZcheckChange " args="chgpkg" />
  <method name=" __LZgetLast " />
  <method name=" __LZgetPosition " />
  <method name=" __LZHandleDocChange " args="who" />
  <method name=" __LZHandleMultiNodes " args="nodes" />
  <method name=" __LZsendUpdate " args="upd, upp" />
  <method name=" __LZsetCloneManager " args="m" />
  <method name=" __LZsetTracking " args="who, additive, needscheck" />
  <method name=" retrieveData " />
  <method name=" setClonePointer " args="p" />
  <method name=" setComparator " args="comparator" />
  <method name=" setDataContext " args="p, implicit" />
  <method name=" setNodes " args="nodes" />
  <method name=" setOrder " args="xpath, comparator" />
  <method name=" setSelected " args="torf" />
  <method name=" toString " />
  <method name=" updateData " />
</class>

JavaScript Synopsis

public LzDatapath extends  LzDatapointer  {
  public var datacontrolsvisibility  : Boolean = true;
  private var _dpevents ;
  private var __LZisclone  = false;
  private var __LZtakeDPSlot  = true;
  public var pooling  : Boolean;
  public var replication  : String;
  public var sortorder  : String|Function;
  public var sortpath  : String;
  prototype private function construct (v, args);
  prototype private function destroy (recur);
  prototype private function __LZApplyData (force);
  prototype private function __LZApplyDataOnInit ();
  prototype private function __LZcheckChange (chgpkg);
  prototype private function __LZgetLast ();
  prototype private function __LZgetPosition ();
  prototype private function __LZHandleDocChange (who);
  prototype private function __LZHandleMultiNodes (nodes);
  prototype private function __LZsendUpdate (upd, upp);
  prototype private function __LZsetCloneManager (m);
  prototype private function __LZsetTracking (who, additive : Boolean, needscheck : Boolean);
  prototype public var rerunxpath  = true;
  prototype private function retrieveData ();
  prototype private function setClonePointer (p);
  prototype public function setComparator (comparator);
  prototype private function setDataContext (p, implicit);
  prototype public function setNodes (nodes);
  prototype public function setOrder (xpath : String, comparator);
  prototype private function setSelected (torf);
  prototype private function toString ();
  prototype public function updateData ();
}