Author: hqm
Date: 2007-08-04 22:00:51 -0700 (Sat, 04 Aug 2007)
New Revision: 5937
Added:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataRequest.lzs
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
openlaszlo/branches/wafflecone/test/data/datatag-1.lzx
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/Library.lzs
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataset.lzs
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
openlaszlo/branches/wafflecone/WEB-INF/lps/schema/lzx.rnc
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
openlaszlo/branches/wafflecone/demos/chat/chatlib.lzx
openlaszlo/branches/wafflecone/lps/components/rpc/library/swf/rpc.js
openlaszlo/branches/wafflecone/test/lfc/data/dollarpath.lzx
Log:
Change 20070805-hqm-4 by [EMAIL PROTECTED] on 2007-08-05 00:48:45 EDT
in /cygdrive/c/users/hqm/openlaszlo/wafflecone
for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone
Summary: checkin of dataprovider implementation for dataset
New Features:
Bugs Fixed: LPP-4404
Technical Reviewer: pkang (pending)
QA Reviewer: (pending)
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details:
Tests:
test/lfc/data/alldata.lzx
test/lfc/data/runtestdatapath.lzx
test/lfc/data/dollarpath.lzx
test/lfc/data/lzunit-lzparsedpath.lzx
test/lfc/data/xpath.lzx
demos/amazon
demos/weather
demos/vacation-survey
demos/calendar
Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/Library.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/Library.lzs
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/Library.lzs
2007-08-05 05:00:51 UTC (rev 5937)
@@ -1,7 +1,7 @@
/**
* Library.lzs
*
- * @copyright Copyright 2001-2006 Laszlo Systems, Inc. All Rights Reserved.
+ * @copyright Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved.
* Use is subject to license terms.
*
* @access private
@@ -10,6 +10,11 @@
#include "data/LzDataNode.lzs"
#include "data/LzDataElement.lzs"
#include "data/LzDataText.lzs"
+
+// new DataProvider classes
+#include "data/LzDataRequest.lzs"
+#include "data/LzHTTPDataProvider.lzs"
+
#include "data/LzDataset.lzs"
#include "data/LzDatapointer.lzs"
#include "data/LzParam.lzs"
@@ -20,6 +25,7 @@
#include "data/LzHTTPDatasource.lzs"
#include "data/LzDataAttrBind.lzs"
+
#include "data/LzLazyReplicationManager.lzs"
#include "data/LzResizeReplicationManager.lzs"
Added: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataRequest.lzs
Property changes on:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataRequest.lzs
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataset.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataset.lzs
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzDataset.lzs
2007-08-05 05:00:51 UTC (rev 5937)
@@ -97,14 +97,21 @@
*/
static var tagname = 'dataset';
+var dataprovider = defaultdataprovider;
+var multirequest = false;
+var dataRequest = null;
+var dataRequestClass = LzHTTPDataRequest;
+
DeclareEvent(prototype, 'ondata' );
/** Sent when the dataset's request results in an error. */
DeclareEvent(prototype, 'onerror' );
/** Sent when the request made by the dataset times out. */
DeclareEvent(prototype, 'ontimeout' );
-var timeout = 30000;
+var timeout = 60000;
+var postbody = null;
+
/** When true, the server will accept
* encoded responses for this request.
* Encoded responses require more work for the LPS (encoding the
@@ -127,11 +134,17 @@
/** When true, the server will encode and
* send the HTTP response headers along with the data (defaults to false).
- * This does not work for SOLO applications; in SOLO applications the call
returns empty.
+ * Due to a lack of a native API to get this information, SOLO SWF
applications
+ * will always return an empty set.
* @type Boolean
*/
var getresponseheaders = false;
+
+/** HTTP method */
+var querytype = "GET";
+
+
/** When true, the server will trim
* whitespace in the XML data (defaults to false).
* @type Boolean
@@ -176,9 +189,6 @@
/* var request; */
setters.request = "setRequest";
-static var anonDatasourceNum = 0;
-
-
var autorequest = false;
var headers = null;
var proxied = null;
@@ -191,24 +201,11 @@
function construct ( parent , args ){
this.queuerequests = false; // default to false, to emulate browser default
- this._createdParent = null;
- if (! (parent instanceof LzDatasource)) {
- this.oncanvas = parent == canvas || parent == null;
+ this.oncanvas = parent == canvas || parent == null;
- // Default datasource type is http
- this._dsrc = new LzHTTPDatasource( canvas,
- { name: "anonHTTPDS" +
-
LzDataset.anonDatasourceNum++});
- this._dsrc.repset = true;
- this._createdParent = this._dsrc;
- if (this._instanceAttrs['name'] == null) {
- this._instanceAttrs['name'] = 'localdata';
- }
- } else {
- // assume datasource is parent;
- this._dsrc = parent;
- this.oncanvas = true;
+ if (this._instanceAttrs['name'] == null) {
+ this._instanceAttrs['name'] = 'localdata';
}
// bwcompat 1.0 support for port
@@ -223,7 +220,7 @@
if ('src' in args && args.src) {
this.src = args.src;
} else {
- this.src = ('src' in this._dsrc) ? this._dsrc.src : null;
+ this.src = null;
}
this.ownerDocument = this;
@@ -253,8 +250,7 @@
canvas.datasets = {};
}
- //support name is global identifier on canvas behavior, even though
- //datasets create a datasource for themselves if none is given
+ //support "name is global identifier on canvas" behavior
if ( this.oncanvas ){
if ($debug) {
if (global[name] && global[name] !== this) {
@@ -271,9 +267,8 @@
if (null != canvas.datasets[name]) {
if ($debug) {
- Debug.warn("A dataset already exists with the name '%s': %w" +
- " - use explicit datasources in your datapaths.",
- name, canvas.datasets[name]);
+ Debug.warn("A dataset already exists with the name '%s': %w",
+ name, canvas.datasets[name]);
}
}
@@ -301,16 +296,8 @@
if (canvas.datasets[ name ] === this) {
delete canvas.datasets[ name ];
}
- // [2005-08-25 ptw] I believe the various delegates will get
- // cleaned up automagically.
- var loader = this.getOption('dsloader');
- loader.destroy();
super.destroy.apply(this, arguments);
- // Destroy created datasource after you (to avoid unnecessary recursion)
- if (this._createdParent) {
- this._createdParent.destroy(recursiveCall);
- }
}
/**
@@ -361,14 +348,6 @@
}
/**
- * Allows the datasource to determine how the raw data should be interpreted
- * @access private
- */
-function gotRawData( data ) {
- this._dsrc.processRawData( this , data );
-}
-
-/**
* Sets the data for the dataset
* @param data a LzDataElement or list of Elements
* @param headers optional HTTP response headers
@@ -437,24 +416,6 @@
return dp;
}
-
-
-if ( $debug ){
-/** @access private */
-function lockFromUpdate ( who ){
- Debug.warn( 'LzDataset.lockFromUpdate is deprecated.' +
- 'Its use is unnecessary.');
- }
-}
-
-if ( $debug ){
-/** @access private */
-function unlockFromUpdate ( who ){
- Debug.warn( 'LzDataset.unlockFromUpdate is deprecated.' +
- 'Its use is unnecessary.');
- }
-}
-
/**
* Sets the querystring parameter of the dataset to the given
* string. If an object is given instead of a string, the object will be
@@ -486,8 +447,11 @@
}
/**
- * Sets the src attribute of the dataset's datasource.
- * @param String src: A new src for the dataset's datasource.
+ * Sets the src attribute of the data request.
+ * Calling this method will cause any pre-existing query arguments to be
discarded.
+ * If a query string is contained in the src argument, it will be used to
+ * set the query arguments of the current request.
+ * @param String src: A new src for data request.
Need to handle these cases
http:foo.html
@@ -504,26 +468,12 @@
this.querystring = url.query;
url.query = null;
this.src = url.toString();
- this._dsrc.setAttribute( 'src' , this.src );
if ( this.autorequest ){
this.doRequest() ;
}
}
/**
- * @deprecated To change the target of a request of at runtime
- * explicitly specify the dataset's <code><datasource></code>
- */
-function setURL( src ) {
- if ($debug){
- Debug.warn( "LzDataset.setURL is deprecated. " +
- "Use LzDataset.setSrc instead." );
- }
- this.setSrc( src );
-}
-
-
-/**
* Sets whether or not the dataset makes its request directly to the target
server
* or via the LPS server proxy.
* @param String val: If 'true', the dataset will make its request when it is
@@ -560,7 +510,10 @@
* @return Int: Number of miliseconds it took to load the last request.
*/
function getLoadTime( ) {
- return this._dsrc.getLoadTimeForDataset( this );
+ if ( $debug ){
+ Debug.warn( 'LzDataset.getLoadTime() is deprecated.' +
+ ' Look at dataRequest.loadtime object instead.' );
+ }
}
/**
@@ -611,14 +564,98 @@
}
}
+
/**
+ * Compute the boolean value for 'proxied', using inheritance if needed
+ * @access private
+ * @return boolean
+ */
+function isProxied ( ) {
+ var proxied_p = canvas.proxied;
+ // check if this datasource has a "proxied" attribute which overrides
canvas switch
+ if (this.proxied != null && this.proxied != "inherit") {
+ proxied_p = (this.proxied == "true"); // coerce to boolean
+ }
+
+ // Check if the dataset has a "proxied" attribute which overrides
dataset's value
+ if (this.proxied != null && this.proxied != "inherit") {
+ proxied_p = (this.proxied == "true");
+ }
+ return proxied_p;
+}
+
+/**
* Does a request immediately using the current values. If autorequest is
true,
* this method is called automatically when values change.
*/
function doRequest() {
- this._dsrc.doRequest( this );
+
+ // We try to reuse the old datarequest object, unless
+ // multirequest is true. If multirequest is true, we need
+ // a separate datarequest obj for each request.
+ if (this.multirequest || this.dataRequest == null) {
+ this.dataRequest = new this.dataRequestClass(this);
+ }
+
+ var dreq = this.dataRequest
+
+ dreq.src = this.src;
+ dreq.timeout = this.timeout;
+ dreq.status = dreq.READY;
+ dreq.method = this.querytype;
+
+ // For back compatibility with 'lzpostbody'
+ var lzpostbody = this.params.getValue('lzpostbody');
+ if (lzpostbody != null) {
+ dreq.postbody = lzpostbody;
+ }
+
+ dreq.proxied = this.isProxied();
+
+ // TODO [hqm 2007-08] does this interact with 'multirequests' flag?
+ dreq.queuerequests = this.queuerequests;
+
+ dreq.queryparams = this.params;
+
+ // TODO [hqm 2007-08] We didn't put 'querystring' in the dataprovider
spec, should
+ // it be merged into queryparams somehow?
+ dreq.querystring = this.querystring;
+
+ dreq.requestheaders = this.headers;
+ dreq.getresponseheaders = this.getresponseheaders;
+
+ dreq.secureport = this.secureport;
+
+ dreq.cacheable = this.cacheable;
+ dreq.clientcacheable = this.clientcacheable;
+ dreq.trimwhitespace = this.trimwhitespace;
+ dreq.nsprefix = this.nsprefix;
+
+ // NB: You had better set the onstatus event handler *before* issuing
request
+ this.dsloadDel = new LzDelegate( this , "handleDataResponse" , dreq,
"onstatus");
+ this.dataprovider.doRequest( dreq );
+
}
+/**
+ * @access private
+ * Called when data request status changes.
+ * If status is 'success', call setData
+ */
+
+function handleDataResponse (datareq) {
+ if (datareq.status == LzDataRequest.SUCCESS) {
+ this.setData(datareq.xmldata, datareq.responseheaders);
+ } else if (datareq.status == LzDataRequest.ERROR) {
+ this.gotError(datareq.error);
+ } else if (datareq.status == LzDataRequest.TIMEOUT) {
+ this.gotTimeout();
+ }
+
+}
+
+// TODO [hqm 2007-08] Is "request()" an ancient deprecated alias for
+// doRequest? When can we get rid of it?
prototype.request = doRequest;
/**
@@ -673,7 +710,7 @@
* @return String
*/
function getResponseHeader(name) {
- return this.responseheaders.getValueNoCase( name );
+ return this.dataRequest.responseheaders[ name ];
}
/**
@@ -689,22 +726,29 @@
* that has more than one request parameter is undefined.
*/
function setQueryType( reqtype ) {
- this._dsrc.setQueryType( reqtype.toUpperCase() );
+ this.querytype = ( reqtype.toUpperCase() );
}
+/** Sets the raw content of a POST body.
+ * This replaces the old "lzpostbody" convention for passing raw POST data.
+ * @param String str: The string to use as the raw POST body content
+ */
+function setPostBody (str) {
+ this.postbody = str;
+}
+
//-----------------------------------------------------------------------------
// Stops the load of the dataset's current request
//-----------------------------------------------------------------------------
function abort( ) {
- this._dsrc.abortLoadForDataset( this );
+ this.dataprovider.abortLoadForRequest( this.dataRequest );
}
/**
* Returns all response headers as an object of name/value pairs, or false
* if there were none.
*
- * @return LzParam: An LzParam object containing the response headers.
- * This does not work for SOLO swf applications; in SOLO swf applications it
returns empty.
+ * @return Object A hash table object containing the response headers.
*/
function getAllResponseHeaders() {
return this.responseheaders;
@@ -725,7 +769,6 @@
/** @access private */
function setInitialData ( d ){
- this.initialdata = d;
if (d != null) {
var e = LzDataNode.stringToLzData(d, this.trimwhitespace,
this.nsprefix);
this.setData(e.childNodes);
Added:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
Property changes on:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/data/LzHTTPDataProvider.lzs
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/dhtml/LzHTTPLoader.js
2007-08-05 05:00:51 UTC (rev 5937)
@@ -9,8 +9,7 @@
* @affects lzloader
*/
-var LzHTTPLoader = function (owner, proxied, dataset) {
- this.dataset = dataset;
+var LzHTTPLoader = function (owner, proxied) {
this.owner = owner;
this.options = {parsexml: true};
this.requestheaders = {};
@@ -192,8 +191,8 @@
// holds list of outstanding data requests, to handle timeouts
LzHTTPLoader.activeRequests = [];
-// Default 30 second timeout
-LzHTTPLoader.prototype.timeout = (30 * 1000);
+// Default infinite timeout
+LzHTTPLoader.prototype.timeout = Infinity;
LzHTTPLoader.prototype.setTimeout = function (timeout) {
this.timeout = timeout;
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzHTTPLoader.as
2007-08-05 05:00:51 UTC (rev 5937)
@@ -13,9 +13,8 @@
*/
// We have an internal 'lzloader' property which points to an LzLoader
(Flash-7-8-specific)
-var LzHTTPLoader = function (owner, proxied, dataset) {
- this.lzloader = this.makeLzLoader(proxied, dataset.timeout);
- this.dataset = dataset;
+var LzHTTPLoader = function (owner, proxied) {
+ this.lzloader = this.makeLzLoader(proxied);
this.owner = owner;
this.options = {
// enable server (proxy) caching
@@ -34,7 +33,8 @@
}
// Default callback handlers
-LzHTTPLoader.prototype._loadSuccessHandler = function (data) {
this.loadSuccess(this,data);}
+
+LzHTTPLoader.prototype._loadSuccessHandler = function (data)
{this.loadSuccess(this,data);}
LzHTTPLoader.prototype._loadErrorHandler = function (data) {
this.loadError(this,data);}
LzHTTPLoader.prototype._loadTimeoutHandler = function (data) {
this.loadTimeout(this,data);}
@@ -48,7 +48,7 @@
/* Returns the response as a string */
LzHTTPLoader.prototype.getResponse = function () {
- // nyi
+ return this.lzloader.rawtext;
}
/* Returns the parsed native XML DOM object, if any */
@@ -130,9 +130,7 @@
// Create a Flash XML object, and stuff it in the LzXMLLoader.
var xmlrequestobj = new XML();
-
- this.dataset.errorstring = null;
-
+
xmlrequestobj.cache = this.options.cacheable;
if (typeof(lzloader.timeout) != 'undefined') {
@@ -142,6 +140,7 @@
// trim whitespace from start and end of text node content
//Debug.write("this.options.trimwhitespace" , this.options.trimwhitespace);
xmlrequestobj.trimwhitespace = (this.options.trimwhitespace);
+ xmlrequestobj.nsprefix = (this.options.nsprefix);
// This is a Flash XML Parser flag - says to completely ignore
// text nodes which are all whitespace. If you set this to false,
@@ -149,8 +148,6 @@
xmlrequestobj.ignoreWhite = true;
xmlrequestobj.url = req;
- // create a pointer back to the dataset, so we can update it when data
arrives
- xmlrequestobj.dataset = this.dataset;
xmlrequestobj.reqtype = this.requestmethod;
xmlrequestobj.proxied = this.lzloader.proxied;
@@ -221,7 +218,7 @@
}
-LzHTTPLoader.prototype.timeout = (30 * 1000);
+LzHTTPLoader.prototype.timeout = Infinity;
LzHTTPLoader.prototype.setTimeout = function (timeout) {
this.timeout = timeout;
@@ -237,7 +234,7 @@
* @access private
* @return LzLoader
*/
-LzHTTPLoader.prototype.makeLzLoader = function (proxied, timeout){
+LzHTTPLoader.prototype.makeLzLoader = function (proxied){
if ( ! $dataloaders ){
// SWF-specific
_root.attachMovie("empty", "$dataloaders", 4242);
@@ -252,10 +249,8 @@
$dataloaders.dsnum ];
$dataloaders.dsnum++;
- //Debug.write("dataset timeout", this.timeout);
-
return new LzLoader( this, { attachRef : newloadermc ,
- timeout : timeout,
+ timeout : Infinity,
proxied: proxied} );
}
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoadQueue.as
2007-08-05 05:00:51 UTC (rev 5937)
@@ -14,13 +14,9 @@
*/
var LzLoadQueue = new Object;
-if ($profile) {
- // leave a network socket for the profiler to use
- LzLoadQueue.maxOpen = 1;
-} else {
- LzLoadQueue.maxOpen = 2;
-}
+LzLoadQueue.maxOpen = 8;
+
if ($debug) {
/**
* Set to true to monitor loadQueue state changes when debugging
@@ -101,7 +97,7 @@
Debug.warn("LzLoadQueue.XMLOnDataHandler load failed from URL %w, no
data received.", this.url);
Debug.warn("Failure to load data in serverless apps may be caused by
Flash player security policies. Check your data server crossdomain.xml file");
this.onload(false);
- if (this.dataset.onerror.ready)
this.dataset.onerror.sendEvent(this.dataset);
+ if (this.loader.onerror.ready)
this.loader.onerror.sendEvent(this.loader);
// cancel the timeout handler
LzLoadQueue.unloadRequest(this);
} else {
@@ -112,7 +108,6 @@
// Stash the raw text on the xml object, in case someone wants it
(XMLHTTPRequest, for example)
this.loader.rawtext = src;
this.parseXML(src);
- //Debug.write('XMLOnDataHandler parsing:' , src);
this.onload(true);
// Free up the network connection, so it can be reused, while we do the
copy task in background.
// Copy the Flash XML tree into tree of LFC LzData classes
@@ -464,7 +459,7 @@
// request methodcases:
// PROXIED: always POST to LPS server
// SOLO: GET, POST, (and lzpostbody special case of POST with raw content)
- if (proxied) {
+ if (loadobj.proxied) {
lvar.sendAndLoad(reqstr , loadobj, "POST" );
} else {
// get request headers from loader
Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzLoader.lzs
2007-08-05 05:00:51 UTC (rev 5937)
@@ -397,7 +397,7 @@
}
if (loadobj) {
this.unload(loadobj);
- if (this.ontimeout.ready) this.ontimeout.sendEvent(
loadobj.reqobj.dataset );
+ if (this.ontimeout.ready) this.ontimeout.sendEvent( loadobj.reqobj);
}
}
@@ -493,9 +493,7 @@
// set up the work queue
this.copyQueue = {ptr: 0, q: queue, xmlobj: xmlnode};
this.trimwhitespace = xmlnode.trimwhitespace;
- var dset = xmlnode.dataset;
- //Debug.write("dset.nsprefix=", dset.nsprefix, "queuedCopyFlashXML,
dataset = ", dset);
- this.nsprefix = dset.nsprefix; // preserve namespace prefix
+ this.nsprefix = xmlnode.nsprefix;
this.queuedCopyFlashXML_internal();
this.startCopyTask();
}
@@ -511,6 +509,8 @@
* @access private
*/
function queuedCopyFlashXML_internal () {
+ var nsprefix = this.nsprefix;
+ var trimwhitespace = this.trimwhitespace;
var ptr = this.copyQueue.ptr;
// Debug.write("enter queuedCopyFlashXML_internal", ptr);
var q = this.copyQueue.q;
@@ -537,7 +537,7 @@
// text node?
if (node.nodeType == 3) {
- if (this.trimwhitespace == true) {
+ if (trimwhitespace == true) {
nv = LzDataNode.trim(nv);
}
lfcnode = {__proto__: LzDataText.prototype, data: nv, parentNode:
lfcparent};
@@ -546,7 +546,7 @@
// After this works, try bashing the __proto__
// and see if GC still works.
- var stripnsprefix = !this.nsprefix;
+ var stripnsprefix = !nsprefix;
var nattrs = node.attributes;
var cattrs;
if (stripnsprefix) {
@@ -573,7 +573,7 @@
////////
var nodename = node.nodeName;
- if (nodename && !this.nsprefix) {
+ if (nodename && !nsprefix) {
var npos = nodename.indexOf(':');
if (npos >= 0) {
nodename = nodename.substring(npos+1);
Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/schema/lzx.rnc
===================================================================
--- openlaszlo/branches/wafflecone/WEB-INF/lps/schema/lzx.rnc 2007-08-04
18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/WEB-INF/lps/schema/lzx.rnc 2007-08-05
05:00:51 UTC (rev 5937)
@@ -653,6 +653,8 @@
## url from which to load its content, rather than as a static xml file to
## inline.
attribute type {xsd:string}? &
+ ## If true, initial literal XML data is taken from <data> child node
+ attribute datafromchild {boolean}? &
[lza:visibility="private"]
attribute endpoint {xsd:string}? &
[lza:visibility="private"]
@@ -926,6 +928,9 @@
nodeElements =
objectElements
& datapathChildren
+ & element data {
+ datasetAttributes & anyXML
+ }*
& element dataset {
datasetAttributes & anyXML
}*
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java
===================================================================
---
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java
2007-08-04 18:48:44 UTC (rev 5936)
+++
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/DataCompiler.java
2007-08-05 05:00:51 UTC (rev 5937)
@@ -24,6 +24,16 @@
* @author Oliver Steele
*/
class DataCompiler extends ElementCompiler {
+
+ /* TODO [hqm 2007-07] This is for top level datasets only. The function in
the LFC,
+ * lzAddLocalData, creates the dataset
+ * *immediately*, it is not queued for instantiation. This happens to
+ * allow forward references to datasets in LZX code. It also happens to
slow
+ * down initialization of an app if it has large static datasets. This
could be
+ * made better by queuing the data for quantized lzIdle processing,
although it
+ * would mean delaying the "ondata" of the datasets until they were
processed.
+ */
+
static final String LOCAL_DATA_FNAME = "lzAddLocalData";
DataCompiler(CompilationEnvironment env) {
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
===================================================================
---
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
2007-08-04 18:48:44 UTC (rev 5936)
+++
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/NodeModel.java
2007-08-05 05:00:51 UTC (rev 5937)
@@ -332,9 +332,14 @@
// This emits a local dataset node, so only process
// <dataset> tags that are not top level datasets.
+
if (elt.getName().equals("dataset")) {
- attrs.put("initialdata", getDatasetContent(elt, env));
- includeChildren = false;
+ String datafromchild = elt.getAttributeValue("datafromchild");
+ if (! "true".equals(datafromchild)) {
+ // Default to legacy behavior, treat all children as XML
literal data.
+ attrs.put("initialdata", getDatasetContent(elt, env));
+ includeChildren = false;
+ }
}
if (includeChildren) {
@@ -747,7 +752,7 @@
nsprefix = true;
}
- Element content = new Element("datacontent");
+ Element content = new Element("data");
String src = element.getAttributeValue("src");
// If 'src' attribute is a URL or null, don't try to expand it now,
@@ -849,7 +854,10 @@
for (Iterator iter = element.getChildren().iterator(); iter.hasNext();
) {
ElementWithLocationInfo child = (ElementWithLocationInfo)
iter.next();
try {
- if (isPropertyElement(child)) {
+ if (child.getName().equals("data")) {
+ // literal data
+ addLiteralDataElement(child);
+ } else if (isPropertyElement(child)) {
addPropertyElement(child);
} else if (schema.isHTMLElement(child)) {
; // ignore; the text compiler wiil handle this
@@ -1177,6 +1185,8 @@
if (when.equals("")) {
when = WHEN_ALWAYS;
}
+ } else if (type == ViewSchema.XML_LITERAL) {
+ value = "LzDataNode.stringToLzData("+value+")";
} else if (type == ViewSchema.COLOR_TYPE) {
if (when.equals(WHEN_IMMEDIATELY)) {
try {
@@ -1517,6 +1527,34 @@
}
}
+ /* Handle a <data> tag.
+ * If there is more than one immediate child data node at the top level,
signal a warning.
+ */
+
+ void addLiteralDataElement(Element element) {
+ String name = element.getAttributeValue("name");
+
+ if (name == null) {
+ name = "initialdata";
+ }
+
+ boolean trimWhitespace =
"true".equals(element.getAttributeValue("trimwhitespace"));
+
+ String xmlcontent = getDatasetContent(element, env, trimWhitespace);
+
+ Element parent = element.getParentElement();
+
+ CompiledAttribute cattr = compileAttribute(element,
+ name,
+ xmlcontent,
+ ViewSchema.XML_LITERAL,
+ WHEN_IMMEDIATELY);
+
+ addAttribute(cattr, name, attrs, events, references, paths, styles);
+ }
+
+
+
boolean hasAttribute(String name) {
return attrs.containsKey(name);
}
Modified:
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
===================================================================
---
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
2007-08-04 18:48:44 UTC (rev 5936)
+++
openlaszlo/branches/wafflecone/WEB-INF/lps/server/src/org/openlaszlo/compiler/ViewSchema.java
2007-08-05 05:00:51 UTC (rev 5937)
@@ -70,6 +70,7 @@
public static final Type SIZE_EXPRESSION_TYPE = newType("sizeExpression");
public static final Type CSS_TYPE = newType("css");
public static final Type INHERITABLE_BOOLEAN_TYPE =
newType("inheritableBoolean");
+ public static final Type XML_LITERAL = newType("xmlLiteral");
static {
sHTMLContentElements.add("text");
Modified: openlaszlo/branches/wafflecone/demos/chat/chatlib.lzx
===================================================================
--- openlaszlo/branches/wafflecone/demos/chat/chatlib.lzx 2007-08-04
18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/demos/chat/chatlib.lzx 2007-08-05
05:00:51 UTC (rev 5937)
@@ -262,13 +262,13 @@
<method event="onkeyup" reference="LzKeys" args="k">
if ( k == 13 ) {
- bSend.handler();
+ bSend.inputhandler();
}
</method>
</library>
<!-- * X_LZ_COPYRIGHT_BEGIN ***************************************************
-* Copyright 2001-2006 Laszlo Systems, Inc. All Rights Reserved. *
+* Copyright 2001-2007 Laszlo Systems, Inc. All Rights Reserved. *
* Use is subject to license terms. *
* X_LZ_COPYRIGHT_END ****************************************************** -->
<!-- @LZX_VERSION@ -->
Modified: openlaszlo/branches/wafflecone/lps/components/rpc/library/swf/rpc.js
===================================================================
--- openlaszlo/branches/wafflecone/lps/components/rpc/library/swf/rpc.js
2007-08-04 18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/lps/components/rpc/library/swf/rpc.js
2007-08-05 05:00:51 UTC (rev 5937)
@@ -135,11 +135,11 @@
if (delegate['dataobject'] != null) {
if ( delegate.dataobject instanceof LzDataset ) {
- var element = LzDataElement.prototype.valueToElement(data);
+ var element = LzDataElement.valueToElement(data);
// the child nodes of element will be placed in datasets
childNodes
delegate.dataobject.setData( element.childNodes );
} else if ( delegate.dataobject instanceof LzDataElement ) {
- var element = LzDataElement.prototype.valueToElement(data);
+ var element = LzDataElement.valueToElement(data);
// xpath: element/value
delegate.dataobject.appendChild( element );
} else {
Added: openlaszlo/branches/wafflecone/test/data/datatag-1.lzx
Property changes on: openlaszlo/branches/wafflecone/test/data/datatag-1.lzx
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:mime-type
+ text/plain
Name: svn:eol-style
+ native
Modified: openlaszlo/branches/wafflecone/test/lfc/data/dollarpath.lzx
===================================================================
--- openlaszlo/branches/wafflecone/test/lfc/data/dollarpath.lzx 2007-08-04
18:48:44 UTC (rev 5936)
+++ openlaszlo/branches/wafflecone/test/lfc/data/dollarpath.lzx 2007-08-05
05:00:51 UTC (rev 5937)
@@ -2,6 +2,56 @@
<debug x="200" width="500" height="500"/>
<include href="lzunit/lzunit.lzx" />
+ <dataset name="somedat">
+ <data>
+ <record show="true">
+ <name>Boo</name>
+ <phone home="155-1212" work="122-1515"/>
+ <options>
+ <hairy color="red"/>
+ <glasses type="tortoise"/>
+ </options>
+ </record>
+ <record>
+ <name>Coo</name>
+ <phone home="255-1212" work="222-1515"/>
+ <options>
+ <hairy />
+ <glasses type="blue"/>
+ </options>
+ </record>
+ <record show="true">
+ <name>Doo</name>
+ <phone home="355-1212" work="322-1515"/>
+ <options>
+ <hairy color="blue"/>
+ <glasses type="tortoise"/>
+ </options>
+ </record>
+ <record>
+ <name>Foo</name>
+ <phone home="455-1212" work="422-1515"/>
+ <options>
+ <hairy />
+ </options>
+ </record>
+ <record show="true">
+ <name>Goo</name>
+ <phone home="555-1212" work="522-1515"/>
+ <options>
+ <hairy color="green"/>
+ </options>
+ </record>
+ <record show="true">
+ <name>Hoo</name>
+ <phone home="655-1212" work="622-1515"/>
+ <options>
+ <glasses type="contacts"/>
+ </options>
+ </record>
+ </data>
+ </dataset>
+
<view y="200" name="rpar">
<attribute name="repcnt" value="0"/>
<view datapath="somedat:/data/record[3]/">
@@ -51,55 +101,7 @@
<simplelayout/>
</view>
- <dataset name="somedat">
- <data>
- <record show="true">
- <name>Boo</name>
- <phone home="155-1212" work="122-1515"/>
- <options>
- <hairy color="red"/>
- <glasses type="tortoise"/>
- </options>
- </record>
- <record>
- <name>Coo</name>
- <phone home="255-1212" work="222-1515"/>
- <options>
- <hairy />
- <glasses type="blue"/>
- </options>
- </record>
- <record show="true">
- <name>Doo</name>
- <phone home="355-1212" work="322-1515"/>
- <options>
- <hairy color="blue"/>
- <glasses type="tortoise"/>
- </options>
- </record>
- <record>
- <name>Foo</name>
- <phone home="455-1212" work="422-1515"/>
- <options>
- <hairy />
- </options>
- </record>
- <record show="true">
- <name>Goo</name>
- <phone home="555-1212" work="522-1515"/>
- <options>
- <hairy color="green"/>
- </options>
- </record>
- <record show="true">
- <name>Hoo</name>
- <phone home="655-1212" work="622-1515"/>
- <options>
- <glasses type="contacts"/>
- </options>
- </record>
- </data>
- </dataset>
+
<TestSuite>
<TestCase>
<method name="test1">
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins