[Laszlo-checkins] r11936 - in openlaszlo/trunk/WEB-INF/lps/lfc: core data

bargull@openlaszlo.org bargull at openlaszlo.org
Sun Nov 30 08:14:03 PST 2008


Author: bargull
Date: 2008-11-30 08:14:00 -0800 (Sun, 30 Nov 2008)
New Revision: 11936

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
   openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
Log:
Change 20081129-bargull-85W by bargull at dell--p4--2-53 on 2008-11-29 23:35:19
    in /home/Admin/src/svn/openlaszlo/trunk
    for http://svn.openlaszlo.org/openlaszlo/trunk

Summary: turn "setData()" into real setter

New Features:

Bugs Fixed: LPP-7393

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

Documentation:

Release Notes:

Details:
LzNode:
- move implementation from "setData()" to "data"-setter, (but don't mark "setData()" as final, because of replicator/lazyreplicator)
LzDataset:
- override "data"-setter instead of "setData()"
- set http responseheaders directly in "handleDataResponse()"
- update callers of "setData()"
- add type-doc for proxyurl and dataprovider (LPP-7408)
For LPP-7350:
- moved "setHeader()" to other request-headers methods
- moved "abort()" to "doRequest()"
- moved "setQueryParam()" and "setQueryParams()" to "setQueryString()"
- moved both "getErrorString()" and "getLoadTime()" to the other getters
    

Tests:
alldata passes



Modified: openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs	2008-11-30 16:09:10 UTC (rev 11935)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/core/LzNode.lzs	2008-11-30 16:14:00 UTC (rev 11936)
@@ -1683,11 +1683,15 @@
 
   /** @access private */
   var data:* = null;
-  
+
   /**
     * @access private
     */
-  function $lzc$set_data (v:*) :void { this.setData(v); }
+  function $lzc$set_data (data:*) :void {
+    this.data = data;
+    (this.datapath || new LzDatapath(this)).setPointer(data /*cast LzDataNodeMixin*/);
+    if (this.ondata.ready) this.ondata.sendEvent(data);
+  }
 
   /**
    * Sets the datacontext for the node to the data element given as an
@@ -1696,12 +1700,11 @@
    * @param LzDataElement data: The dataelement to use as the context
    * @param ignore: This parameter is only used in LzDataset
    * @deprecated Use setAttribute('data', ...) instead
+   * @devnote Don't mark as final, or replicator/lazyreplicator won't compile anymore
    */
   function setData (data:*, ignore=null) :void {
-    this.data = data;
-    var dp:LzDatapath = (this.datapath != null) ? this.datapath : new LzDatapath(this);
-    dp.setPointer(data /*cast LzDataNodeMixin*/);
-    if (this.ondata.ready) this.ondata.sendEvent(data);
+    if ($debug) Debug.deprecated(this, arguments.callee, this.setAttribute);
+    this.$lzc$set_data(data);
   }
 
   /**
@@ -1714,7 +1717,7 @@
    */
   function applyData ( data ){
   }
-  
+
   /*
    * FIXME: [20080419 anba] doc: LPP-4259
    * FIXME: [20080419 anba] return type: LPP-4077
@@ -1725,9 +1728,9 @@
    *
    * @access public
    */
-  function updateData () /*:String*/ { 
-    return void(0); 
-  } 
+  function updateData () /*:String*/ {
+    return void(0);
+  }
 
   /*
    * If you use LzSelectionManager, you can decide the selection method,

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-11-30 16:09:10 UTC (rev 11935)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/data/LzDataset.lzs	2008-11-30 16:14:00 UTC (rev 11936)
@@ -109,6 +109,7 @@
 
 /** Holds a pointer to the DataProvider which handles data load requests for this dataset. 
   * Default value is canvas.defaultdataprovider
+  * @lzxtype expression
   */
 var dataprovider :LzDataProvider;
 
@@ -140,7 +141,10 @@
   */
 var secureport :uint;
 
-/** The URL of the proxy server, for proxied requests */
+/** The URL of the proxy server, for proxied requests
+  * @type String
+  * @lzxtype string
+  */
 var proxyurl :String = null;
 
 /** Sent when the dataset's request results in an error. 
@@ -329,7 +333,9 @@
     return (this.proxied != null) ? this.proxied : canvas.proxied;
 }
 
-/** @access private */
+/** HTTP response headers
+  * @access private
+  */
 var responseheaders :LzParam = null;
 
 /** If true, the client should ensure that each request is made, rather than just 
@@ -348,7 +354,7 @@
     if (d != null) {
         var e:LzDataElement = LzDataElement.stringToLzData(d, this.trimwhitespace, this.nsprefix);
         if (e != null) {
-            this.setData(e.childNodes);
+            this.$lzc$set_data(e.childNodes);
         }
     }
 }
@@ -449,6 +455,23 @@
 }
 
 /**
+  * Returns an error string if there was an error, or <code>undefined</code> if there was none.
+  * @return String: An error string, or <code>undefined</code> if none.
+  */
+function getErrorString () :String { 
+    return this.errorstring;
+}
+
+/**
+  * Returns the number of miliseconds it took to load the dataset's request
+  * @return Int: Number of miliseconds it took to load the last request.
+  */
+function getLoadTime () :Number {
+    var dreq:LzHTTPDataRequest = this.dataRequest;
+    return dreq ? dreq.loadtime : 0;
+}
+
+/**
   * Return the src attribute of the dataset, if one was given.
   * @return String: The src of attribute of the dataset
   */
@@ -484,11 +507,9 @@
 /**
   * Sets the data for the dataset
   * @param data a LzDataElement or list of Elements
-  * @param headers optional HTTP response headers
-  * @deprecated Use setAttribute('data', ...) instead when headers is not specified.
   * @access private
   */
-override function setData (data:*, headers/*:LzParam*/ = null) :void {
+override function $lzc$set_data (data:*) :void {
     if (data == null) {
         return;
     } else if (data instanceof Array) {
@@ -496,14 +517,9 @@
     } else {
         this.setChildNodes([data]);
     }
-                
+
     this.data = data;
 
-    if (this.responseheaders != null) {
-        this.responseheaders.destroy();
-    }
-    this.responseheaders = headers;
-
     if (this.ondata.ready) this.ondata.sendEvent(this);
 }
 
@@ -582,6 +598,51 @@
 }
 
 /**
+  * Sets a named query parameter to the given value. The query parameters are 
+  * sent with every request.  The key 'lzpostbody' has a specific interpretation,
+  * see setQueryType() for details.
+  * @param String key: The name of the parameter
+  * @param String val: The value for the parameter
+  */
+function setQueryParam (key:String, val:String) :void {
+    this.querystring = null;
+    if (! this.params) {
+        this.params = new lz.Param();
+    }
+    this.params.setValue(key, val);
+
+    if (this.autorequest) {
+        this.doRequest();
+    }
+}
+
+/**
+  * Sets multiple query parameters from using the keys in the argument as keys
+  * and the values of those keys as values. This method can also be used to
+  * clear the query params, by passing null to it.
+  * @param Object o: An object whose keys are keys of parameters and whose 
+  * values are those parameters' values. Passing a value of null to this 
+  * method clears the query parameters.
+  * The key 'lzpostbody' has a specific interpretation, see setQueryType() for details.
+  */
+function setQueryParams (obj:Object) :void {
+    this.querystring = null;
+    if (! this.params) {
+        this.params = new lz.Param();
+    }
+
+    if (obj) {
+        this.params.addObject(obj);
+    } else if (obj == null) {
+        this.params.remove();
+    }
+
+    if (obj && this.autorequest) {
+        this.doRequest();
+    }
+}
+
+/**
   * Sets the src attribute of the data request.
   * @deprecated Use setAttribute('src', ...) instead.
   * @param String src: A new src URL for data request.
@@ -674,60 +735,6 @@
 }
 
 /**
-  * Returns the number of miliseconds it took to load the dataset's request
-  * @return Int: Number of miliseconds it took to load the last request.
-  */
-function getLoadTime () :Number {
-    var dreq:LzHTTPDataRequest = this.dataRequest;
-    return dreq ? dreq.loadtime : 0;
-}
-
-/**
-  * Sets a named query parameter to the given value. The query parameters are 
-  * sent with every request.  The key 'lzpostbody' has a specific interpretation,
-  * see setQueryType() for details.
-  * @param String key: The name of the parameter
-  * @param String val: The value for the parameter
-  */
-function setQueryParam (key:String, val:String) :void {
-    this.querystring = null;
-    if (! this.params) {
-        this.params = new lz.Param();
-    }
-    this.params.setValue(key, val);
-
-    if (this.autorequest) {
-        this.doRequest();
-    }
-}
-
-/**
-  * Sets multiple query parameters from using the keys in the argument as keys
-  * and the values of those keys as values. This method can also be used to
-  * clear the query params, by passing null to it.
-  * @param Object o: An object whose keys are keys of parameters and whose 
-  * values are those parameters' values. Passing a value of null to this 
-  * method clears the query parameters.
-  * The key 'lzpostbody' has a specific interpretation, see setQueryType() for details.
-  */
-function setQueryParams (obj:Object) :void {
-    this.querystring = null;
-    if (! this.params) {
-        this.params = new lz.Param();
-    }
-
-    if (obj) {
-        this.params.addObject(obj);
-    } else if (obj == null) {
-        this.params.remove();
-    }
-
-    if (obj && this.autorequest) {
-        this.doRequest();
-    }
-}
-
-/**
   * Produce a hash table of key-value pairs.
   * In the case of a duplicated key, creates an array of values.
   */
@@ -756,6 +763,15 @@
     return queries;
 }
 
+/**
+  * Stops the load of the dataset's current request
+  */
+function abort () :void {
+    var dreq:LzHTTPDataRequest = this.dataRequest;
+    if (dreq) {
+        this.dataprovider.abortLoadForRequest(dreq);
+    }
+}
 
 /**
   * Does a request immediately using the current values.  If autorequest is true,
@@ -842,17 +858,21 @@
 /**
   * @access private       
   * Called when  data request status changes.
-  * If status is 'success', call setData
+  * If status is 'success', sets data and responseheaders (if available)
   */
 function handleDataResponse (datareq:LzHTTPDataRequest) :void {
     if (this.dsloadDel != null) {
         this.dsloadDel.unregisterFrom(datareq.onstatus);
     }
-    
+
     this.rawdata = datareq.rawdata;
 
     if (datareq.status == LzDataRequest.SUCCESS) {
-        this.setData(datareq.xmldata, datareq.responseheaders);
+        if (this.responseheaders != null) {
+            this.responseheaders.destroy();
+        }
+        this.responseheaders = datareq.responseheaders;
+        this.$lzc$set_data(datareq.xmldata);
     } else if (datareq.status == LzDataRequest.ERROR) {
         this.gotError(datareq.error);
     } else if (datareq.status == LzDataRequest.TIMEOUT) {
@@ -860,16 +880,21 @@
     }
 }
 
+/* Meta stuff */
+
 /**
-  * Returns an error string if there was an error, or <code>undefined</code> if there was none.
-  * @return String: An error string, or <code>undefined</code> if none.
+  * Sets a header for the next request
+  * @param String k: Key for the header
+  * @param String val: Value for the header
   */
-function getErrorString () :String { 
-    return this.errorstring;
+function setHeader (k:String, val:String) :void { 
+    if (! this.headers) {
+        this.headers = new lz.Param();
+    }
+
+    this.headers.setValue(k, val);
 }
 
-/* Meta stuff */
-
 /**
   * Retrieves the lz.Param object which represents the headers sent with
   * the dataset's last request
@@ -911,16 +936,6 @@
 }
 
 /**
-  * Stops the load of the dataset's current request
-  */
-function abort () :void {
-    var dreq:LzHTTPDataRequest = this.dataRequest;
-    if (dreq) {
-        this.dataprovider.abortLoadForRequest(dreq);
-    }
-}
-
-/**
   * Returns all response headers as an object of name/value pairs, or false
   * if there were none.
   * 
@@ -931,19 +946,6 @@
 }
 
 /**
-  * Sets a header for the next request
-  * @param String k: Key for the header
-  * @param String val: Value for the header
-  */
-function setHeader (k:String, val:String) :void { 
-    if (! this.headers) {
-        this.headers = new lz.Param();
-    }
-
-    this.headers.setValue(k, val);
-}
-
-/**
   * Get string representation
   * @access private
   * @return: String representation of this object
@@ -1003,7 +1005,7 @@
     dset.ontimeout.clearDelegates();
     dset.onerror.clearDelegates();
     // clear any data
-    dset.setData([]);
+    dset.$lzc$set_data([]);
     
     this._p.push(dset);
 }



More information about the Laszlo-checkins mailing list