[Laszlo-checkins] r9381 - openlaszlo/trunk/WEB-INF/lps/lfc/data

bargull@openlaszlo.org bargull at openlaszlo.org
Thu May 29 13:20:44 PDT 2008


Author: bargull
Date: 2008-05-29 13:20:41 -0700 (Thu, 29 May 2008)
New Revision: 9381

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
Log:
Change 20080529-bargull-CHQ by bargull at dell--p4--2-53 on 2008-05-29 21:29:48
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: fix constrained xpaths for replication

New Features:

Bugs Fixed: LPP-5353

Technical Reviewer: hminsky
QA Reviewer: (pending)
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
Constrained datapaths/xpaths work again in swf7-8, dhtml. To get this working in swf9, we need to consider to change how constraint-methods are compiled. I'll create a new JIRA for this issue. 
    

Tests:
Attached at bugreport



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2008-05-29 20:19:21 UTC (rev 9380)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2008-05-29 20:20:41 UTC (rev 9381)
@@ -77,7 +77,7 @@
   * name, so that it can be referred to the same way the non-replicated view
   * would have been. 
   */
-class LzReplicationManager extends LzDatapath {
+dynamic class LzReplicationManager extends LzDatapath {
 
 /** @access private */
 override function $lzc$set_datapath(v) { this.setXPath(v); }
@@ -275,30 +275,64 @@
     var hadxpathconstraint:Boolean = false;
     var ia:Object = view._instanceAttrs;
     var oa:Object = odp._instanceAttrs;
-    if (ia && 'datapath' in ia && ia.datapath instanceof LzConstraintExpr) {
+    if (ia && 'datapath' in ia && ia.datapath is LzConstraintExpr) {
         // <view datapath="${ ... }"/>
         hadxpathconstraint = true;
         // we need to mask this constraint
         // NOTE: [2008-02-07 ptw] Why?  Why can't this just execute as
         // a constraint on the clone via the normal mechanism?
-        this.cloneAttrs = new LzInheritedHash(this.cloneAttrs);
-        this.cloneAttrs.datapath = LzNode._ignoreAttribute;
         // but, we want the constraint to apply to this object instead
         this.__LZpreventXPathUpdate = true;
+        var methodName:String = ia.datapath.methodName;
+        if ($swf9) {
+            //FIXME: cannot copy a method in swf9, because 'this' is bound!
+            this[methodName] = function (ignore) {};
+        } else {
+            this[methodName] = view[methodName];
+        }
+        if (ia.datapath is LzAlwaysExpr) {
+            var dependencyName:String = ia.datapath.dependenciesName;
+            if ($swf9) {
+                //FIXME: cannot copy a method in swf9, because 'this' is bound!
+                this[dependencyName] = function () {return [];};
+            } else {
+                this[dependencyName] = view[dependencyName];
+            }
+        }
         // NOTE: [2008-02-07 ptw] The method had better be available
         // on the clone (which means we really want a clone class here
         // to instantiate, rather than an instance to clone).
         this.applyConstraintExpr(ia.datapath);
         this.__LZpreventXPathUpdate = false;
-    } else if (oa && 'xpath' in oa && oa.xpath instanceof LzConstraintExpr){
+    } else if (oa && 'xpath' in oa && oa.xpath is LzConstraintExpr){
         //<view><datapath xpath="${ ... }"/>
         hadxpathconstraint = true;
         //we want the constraint to apply to this object instead
         this.__LZpreventXPathUpdate = true;
+        // we need to have an intermediate node, so relative constraints 
+        // like "xpath='${this.immediateparent.parent.anyproperty}'" 
+        // work for a replication-manager 
+        var refObj:LzRefNode = new LzRefNode(this);
+        var methodName:String = oa.xpath.methodName;
+        if ($swf9) {
+            //FIXME: cannot copy a method in swf9, because 'this' is bound!
+            refObj[methodName] = function (ignore) {};
+        } else {
+            refObj[methodName] = odp[methodName];
+        }
+        if (oa.xpath is LzAlwaysExpr) {
+            var dependencyName:String = oa.xpath.dependenciesName;
+            if ($swf9) {
+                //FIXME: cannot copy a method in swf9, because 'this' is bound!
+                refObj[dependencyName] = function () {return [];};
+            } else {
+                refObj[dependencyName] = odp[dependencyName];
+            }
+        }
         // NOTE: [2008-02-07 ptw] The method had better be available
         // on the clone (which means the compiler really has to move
         // it from the datapath subnode to the clone class).
-        this.applyConstraintExpr(oa.xpath);
+        refObj.applyConstraintExpr(oa.xpath);
         this.__LZpreventXPathUpdate = false;
     }
 
@@ -330,6 +364,7 @@
         //make sure that the original view and datapath don't get their xpath 
         //set by a constraint..
         if ( hadxpathconstraint ){
+            //FIXME: breaks in swf9!
             odp.setXPath =  LzReplicationManager.__LZemptyFuntion;
         }
         this.clones.push ( view );
@@ -868,3 +903,20 @@
 
 } // End of LzReplicationManager
 
+/** @access private */
+dynamic class LzRefNode extends LzNode {
+    /**
+      * @access private
+      */
+    function LzRefNode (parent:LzNode, attrs:Object? = null, children:Array? = null, instcall:Boolean = false) {
+        super(parent, attrs, children, instcall);
+    }
+    
+    /**
+      * @access private
+      */
+    function $lzc$set_xpath (v) :void {
+        // this.parent is the LzReplicationManager!
+        this.parent.$lzc$set_xpath(v);
+    }
+}



More information about the Laszlo-checkins mailing list