[Laszlo-checkins] r8804 - in openlaszlo/trunk: WEB-INF/lps/lfc/core WEB-INF/lps/lfc/data WEB-INF/lps/lfc/helpers WEB-INF/lps/lfc/views WEB-INF/lps/schema lps/components/lz

bargull@openlaszlo.org bargull at openlaszlo.org
Mon Apr 21 07:36:01 PDT 2008


Author: bargull
Date: 2008-04-21 07:35:50 -0700 (Mon, 21 Apr 2008)
New Revision: 8804

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/core/LzMiniNode.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataNode.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzDataSelectionManager.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs
   openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
   openlaszlo/trunk/lps/components/lz/gridtext.lzx
Log:
Change 20080419-bargull-8 by bargull at dell--p4--2-53 on 2008-04-19 01:56:01
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: data-binding and -selection broken

New Features:

Bugs Fixed: LPP-5819 - swf: dhtml : components: grid_example: Cannot edit text in the weather/contacts tab

Technical Reviewer: henry
QA Reviewer: promanik
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details:
part 1: The GridText
In the old days, a datapath (as an attribute) was marked with "_ignoreAttribute" when there was also a datapath (as a tag). This was done by LzFixTags, since rev. #5,735 this is made by "NodeModel#updateAttrs()" (see LPP-3482).
But in gridtext, the datapath (as an attribute) is a constraint, so in earlier releases it was stored in the "$refs"-object and therefore it wasn't smashed by LzFixTags.
Now, all instance-attributes come in one object, so there is no special "$refs" object anymore. That's why the constraint is removed at compile time.

part 2: updateData + setSelected
"updataData" and "setSelected" were kind of dynamic functions, now they're placed in LzNode to make swf9 happy. 
A couple of changes were necessary:

lfc.lzx - update schema:
Moved "setSelected" and "updataData" into LzNode.
Removed "updataData" from LzDatapath and LzInputText.

LzMiniNode.lzs:
Don't hoist "_selstate" up into LzMiniNode, moved to LzDatapath resp. LzDataNode and re-renamed to "sel". 

LzNode.lzs:
Added "setSelected" and "updataData" methods.

LzDataNode.lzs:
Re-added "sel" property.

LzDatapath.lzs:
Re-added "sel" property.
Updated "updataData", "setClonePointer" and "setSelected" methods.
Added new internal method "__LZupdateData", so we don't have to struggle with changing the updataData-API.

LzReplicationManager.lzs:
Moved code from "updataData" to "__LZupdateData".

LzDataAttrBind.lzs:
Mark "updataData" as overrriden.
Added "__LZupdateData" to mimic LzDatapath.

LzDatapointer.lzs:
Check for "nodeType".

LzDataSelectionManager.lzs:
Update doc-comment.

LzInputText.lzs:
Mark "updataData" as overrriden.

gridtext.lzx:
Uses now visibility to control visible-status.

LaszloView.lzs: (not part of the bug)
Added comment how to restore default cursor.


Tests:
ant runlzunit
ant lztest
alldata.lzx
testcases from bugreport
compile swf9



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/core/LzMiniNode.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/core/LzMiniNode.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/core/LzMiniNode.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -24,8 +24,6 @@
 
 /** @access private */
   var __LZdeleted:Boolean = false;
-/** @access private */
-  var _selstate; // Was also defined in LzDatapath
 
 /**
   * Sets the named attribute to the given value. If there is no setter for the

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -1654,8 +1654,6 @@
     if (this.ondata.ready) this.ondata.sendEvent(data);
   }
 
-
-// hack to create an 'abstract' method to hang the doc off of
 /**
   * Called on any node that is declared with a datapath that matches a
   * terminal selector, such as <code>text()</code> or
@@ -1667,8 +1665,34 @@
 function applyData ( data ){
 }
 
+/**
+  * see <method>LzDatapointer#updateData()</method>
+  * FIXME: [20080419 anba] doc: LPP-4259
+  * FIXME: [20080419 anba] return type: LPP-4077
+  * 
+  * @access protected
+  */
+function updateData () /* :String */ {
+    return void(0);
+}
 
 /**
+  * FIXME: [20080419 anba] document me!
+  * There is definitely a lack of documentation about selection
+  * i) if you use LzSelectionManager, you can decide the selection method, 
+  * see "sel" property on LzSelectionManager
+  * ii) but LzDataSelectionManager forces you to override "setSelected",
+  * see LzDatapath#setSelected(Boolean)
+  * -> that's way too confusing!
+  *
+  * @access protected
+  * @param boolean sel: true when this node was selected, false when it lost selection
+  */
+function setSelected (sel:Boolean) /* :void */ {
+}
+
+
+/**
   * A list of CSS property names and values that configure the
   * behavior of objects, such as data binding and view layouts, that
   * operate on this view.

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataAttrBind.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -76,23 +76,33 @@
     super.setDataContext( dc || this.pathparent, implicit );
 }
 
+/**
+  * @access private
+  */
+override function updateData() {
+    this.__LZupdateData();
+}
 
-
-function updateData (){
+/**
+  * @devnote: the function signature must match LzDatapath#__LZupdateData(Boolean)
+  * @access private
+  */
+function __LZupdateData (recursive:Boolean = false) :void {
     //this code is largely copied from LzDatapath, but it's slightly different
-    var dat = this.node[ this.setAttr ];
-    if ( this.data == dat ) return;
     var ppdo = this.parsedPath.operator;
-    if ( ppdo != null){
-        if ( ppdo =="nodeName" ){
-            this.setNodeName( dat );
-        } else  if ( ppdo =="__LZgetText" ){
-            this.setNodeText( dat );
-        } else  if ( ppdo =="attributes" ){
-            this.p.setAttrs( dat );
-        } else {
-            //remove the "attributes." from the operator
-            this.setNodeAttribute( ppdo.substring( 11 ) , dat );
+    if (ppdo != null) {
+        var dat = this.node[ this.setAttr ];
+        if (this.data != dat) {
+            if (ppdo == "nodeName") {
+                this.setNodeName( dat );
+            } else if (ppdo == "__LZgetText") {
+                this.setNodeText( dat );
+            } else if (ppdo == "attributes") {
+                this.p.setAttrs( dat );
+            } else {
+                //remove the "attributes." from the operator
+                this.setNodeAttribute( ppdo.substring( 11 ) , dat );
+            }
         }
     }
 }

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataNode.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataNode.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataNode.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -83,6 +83,8 @@
 var ownerDocument:*;
 /** @access private */
 var __LZo:* = -1;
+/** @access private */
+var sel:Boolean = false;
 
 /** An array of children of this node
   * @type LzDataNode

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapath.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -98,7 +98,7 @@
 /** @access private */
 var __LZdepChildren;
 /** @access private */
-// var _selstate; // Defined in LzMiniNode
+var sel:Boolean = false;
 
 
 /** Sent when the datapath's data changes.
@@ -431,11 +431,11 @@
   * datapath's <attribute>xpath</attribute> ends in a terminal selector
   * (an attribute, <code>text()</code>, or <code>name()</code>
   * expression), then the datapath attempts to call its parent's
-  * <method>updateData</method> method. If this method is defined, the
-  * datapath sets the data element's attribute, text, or name,
-  * respectively, to <method>updateData</method>'s return value. The
-  * method then calls any other <method>updateData</method> on any
-  * datapaths which depend on this one for context.
+  * <method>updateData</method> method. If this method returns a 
+  * non-undefined value, the datapath sets the data element's 
+  * attribute, text, or name, respectively, to <method>updateData</method>'s 
+  * return value. The method then calls any other <method>updateData</method> 
+  * 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 <method>updateData</method> method that returns
@@ -444,34 +444,44 @@
   * for any other LFC classes.
   *
   */
-function updateData( ){
+override function updateData() {
+    this.__LZupdateData();
+}
 
-    if ( !arguments[ 0 ] && this.p){
+/**
+  * @access private
+  */
+function __LZupdateData (recursive:Boolean = false) :void {
+    if (!recursive && this.p) {
         this.p.__LZlockFromUpdate( this );
     }
 
     var ppdo = this.parsedPath ? this.parsedPath.operator : null;
-    if ( this.immediateparent is LzDatapath && ppdo != null){
-        var dat = (this.immediateparent cast LzDatapath).updateData();
-        if ( ppdo =="nodeName" ){
-            this.setNodeName( dat );
-        } else  if ( ppdo =="__LZgetText" ){
-            this.setNodeText( dat );
-        } else  if ( ppdo =="attributes" ){
-            this.p.setAttrs( dat );
-        } else {
-            //remove the "attributes." from the operator
-            this.setNodeAttribute( ppdo.substring( 11 ) , dat );
+    if (ppdo != null) {
+        var dat = (this.immediateparent cast LzNode).updateData();
+        if (dat !== void(0)) {
+            if (ppdo == "nodeName") {
+                this.setNodeName( dat );
+            } else if (ppdo == "__LZgetText") {
+                this.setNodeText( dat );
+            } else if (ppdo == "attributes") {
+                this.p.setAttrs( dat );
+            } else {
+                //remove the "attributes." from the operator
+                this.setNodeAttribute( ppdo.substring( 11 ) , dat );
+            }
         }
     }
 
-    if (this.__LZdepChildren != null) {
-        for ( var i = 0; i < this.__LZdepChildren.length; i++ ){
-            this.__LZdepChildren[ i ].updateData( true );
+    var depChildren:Array = this.__LZdepChildren;
+    if (depChildren != null) {
+        for (var i:int = 0; i < depChildren.length; i++) {
+            //depChildren: Array of LzDatapath and LzDataAttrBind!
+            depChildren[ i ].__LZupdateData( true );
         }
     }
 
-    if ( !arguments[ 0 ] && this.p){
+    if (!recursive && this.p) {
         this.p.__LZunlockFromUpdate( this );
     }
 }
@@ -582,7 +592,7 @@
   * @access private
   */
 function setClonePointer( p ) {
-    //Debug.write("%s: for %w, was %w (dp._selstate=%w, p._selstate=%w)", arguments.callee, p, this.p, this._selstate, p._selstate);
+    //Debug.write("%s: for %w, was %w (dp.sel=%w, p.sel=%w)", arguments.callee, p, this.p, this.sel, p.sel);
     var pc = this.p !=p;
     this.p = p;
 
@@ -590,11 +600,9 @@
     //if ( pc || true ) {
     if ( pc ) {
 
-        if ( p && this._selstate != p._selstate ){
-            this._selstate = p._selstate || false;
-            if ( this.immediateparent is LzDatapath){
-                (this.immediateparent cast LzDatapath).setSelected( this._selstate );
-            }
+        if ( p && this.sel != p.sel ){
+            this.sel = p.sel || false;
+            (this.immediateparent cast LzNode).setSelected( this.sel );
         }
 
         this.__LZpchanged = true;
@@ -642,13 +650,11 @@
 /**
   * @access private
   */
-function setSelected( torf ){
-    this.p._selstate =  torf;
-    this._selstate = torf;
+override function setSelected (torf:Boolean) {
+    this.p.sel = torf;
+    this.sel = torf;
 
-    if ( this.immediateparent is LzDatapath){
-        (this.immediateparent cast LzDatapath).setSelected( torf );
-    }
+    (this.immediateparent cast LzNode).setSelected( torf );
 }
 
 /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDatapointer.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -888,7 +888,9 @@
         }
         return;
     }
-    return this.p.attributes;
+    if (this.p.nodeType != LzDataNode.TEXT_NODE) {
+        return this.p.attributes;
+    }
 }
 
 /**

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzReplicationManager.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -814,9 +814,17 @@
   * @access private
   */
 override function updateData () {
-    var l = this.clones.length; 
-    for ( var i = 0; i < l; i++ ){
-        this.clones[ i ].datapath.updateData( );
+    this.__LZupdateData();
+}
+
+/**
+  * @access private
+  */
+override function __LZupdateData (recursive:Boolean = false) :void {
+    var cls:Array = this.clones;
+    var len:int = cls.length; 
+    for (var i:int = 0; i < len; i++) {
+        cls[ i ].datapath.updateData();
     }
 }
 

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzDataSelectionManager.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzDataSelectionManager.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/helpers/LzDataSelectionManager.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -219,7 +219,7 @@
 
 /**
   * sets the selected attribute of the data, if there is a clone, it will
-  * call setselected on the clone
+  * call <method>setSelected(Boolean)</method> on the clone's datapath
   * @param LzDataElement p: the node we want to set
   * @param Boolean val: new value for selected
   * @access private

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloView.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -2537,7 +2537,7 @@
 /**
   * Sets the cursor to the given resource when the mouse is over this view
   * @param String cursor: The name of the resource to use as a cursor when it is over
-  * this view.
+  * this view. Or '' for default cursor.
   */
 function setCursor ( cursor ){
     this.sprite.setCursor(cursor);

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LzInputText.lzs	2008-04-21 14:35:50 UTC (rev 8804)
@@ -202,7 +202,7 @@
   * <code>LzDatapath.updateData</code> for more on this.
   * @access protected
   */
-function updateData (){
+override function updateData () {
     var isprite:LzInputTextSprite = (this.sprite cast LzInputTextSprite);    
     return isprite.getText();
 }

Modified: openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/WEB-INF/lps/schema/lfc.lzx	2008-04-21 14:35:50 UTC (rev 8804)
@@ -213,7 +213,9 @@
   <method name="setExpectedAttribute"/>
   <method name="setOption"/>
   <method name="setProp"/>
+  <method name="setSelected" />
   <method name="toString"/>
+  <method name="updateData"/>
 
 </interface>
 
@@ -654,7 +656,6 @@
       <method name="inputtextevent"/>
       <method name="setEnabled"/>
       <method name="setHTML"/>
-      <method name="updateData"/>
 
 </interface>
 
@@ -896,8 +897,6 @@
   <method name="setComparator"/>
   <method name="setNodes"/>
   <method name="setOrder"/>
-  <method name="setSelected"/>
-  <method name="updateData"/>
 </interface>
 
 

Modified: openlaszlo/trunk/lps/components/lz/gridtext.lzx
===================================================================
--- openlaszlo/trunk/lps/components/lz/gridtext.lzx	2008-04-21 14:31:04 UTC (rev 8803)
+++ openlaszlo/trunk/lps/components/lz/gridtext.lzx	2008-04-21 14:35:50 UTC (rev 8804)
@@ -101,15 +101,12 @@
             <state pooling="true" apply="${parent.editing}" 
                    onremove="parent.editbox.datapath.updateData()">
                 <edittext datapath="$once{parent.parent.rowdp}" 
-                          name="editbox" width="${parent.width}">
+                          name="editbox" width="${parent.width}" visibility="visible" >
                     <method name="init">
                         this.globalMouseDel = new LzDelegate( this, 
                                                               "checkMouse" );
                         super.init();
                     </method>
-                    <datapath>
-                        <attribute name="datacontrolsvisibility" value="false"/>
-                    </datapath>
                     <method name="applyData" args="d">
                         //because of the monkeying with init that this
                         //componentdoes, the data for this thing can sometimes



More information about the Laszlo-checkins mailing list