You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by sv...@apache.org on 2006/11/10 10:15:40 UTC

svn commit: r473277 [20/45] - in /myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource: ./ src/ src/animation/ src/cal/ src/charting/ src/charting/svg/ src/charting/vml/ src/collections/ src/crypto/ src/data/ src/data/...

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io.js Fri Nov 10 01:15:01 2006
@@ -8,369 +8,7 @@
 		http://dojotoolkit.org/community/licensing.shtml
 */
 
-dojo.provide("dojo.io.IO");
-dojo.require("dojo.string");
-dojo.require("dojo.lang.extras");
+dojo.provide("dojo.io");
 
-/******************************************************************************
- *	Notes about dojo.io design:
- *	
- *	The dojo.io.* package has the unenviable task of making a lot of different
- *	types of I/O feel natural, despite a universal lack of good (or even
- *	reasonable!) I/O capability in the host environment. So lets pin this down
- *	a little bit further.
- *
- *	Rhino:
- *		perhaps the best situation anywhere. Access to Java classes allows you
- *		to do anything one might want in terms of I/O, both synchronously and
- *		async. Can open TCP sockets and perform low-latency client/server
- *		interactions. HTTP transport is available through Java HTTP client and
- *		server classes. Wish it were always this easy.
- *
- *	xpcshell:
- *		XPCOM for I/O. A cluster-fuck to be sure.
- *
- *	spidermonkey:
- *		S.O.L.
- *
- *	Browsers:
- *		Browsers generally do not provide any useable filesystem access. We are
- *		therefore limited to HTTP for moving information to and from Dojo
- *		instances living in a browser.
- *
- *		XMLHTTP:
- *			Sync or async, allows reading of arbitrary text files (including
- *			JS, which can then be eval()'d), writing requires server
- *			cooperation and is limited to HTTP mechanisms (POST and GET).
- *
- *		<iframe> hacks:
- *			iframe document hacks allow browsers to communicate asynchronously
- *			with a server via HTTP POST and GET operations. With significant
- *			effort and server cooperation, low-latency data transit between
- *			client and server can be acheived via iframe mechanisms (repubsub).
- *
- *		SVG:
- *			Adobe's SVG viewer implements helpful primitives for XML-based
- *			requests, but receipt of arbitrary text data seems unlikely w/o
- *			<![CDATA[]]> sections.
- *
- *
- *	A discussion between Dylan, Mark, Tom, and Alex helped to lay down a lot
- *	the IO API interface. A transcript of it can be found at:
- *		http://dojotoolkit.org/viewcvs/viewcvs.py/documents/irc/irc_io_api_log.txt?rev=307&view=auto
- *	
- *	Also referenced in the design of the API was the DOM 3 L&S spec:
- *		http://www.w3.org/TR/2004/REC-DOM-Level-3-LS-20040407/load-save.html
- ******************************************************************************/
-
-// a map of the available transport options. Transports should add themselves
-// by calling add(name)
-dojo.io.transports = [];
-dojo.io.hdlrFuncNames = [ "load", "error", "timeout" ]; // we're omitting a progress() event for now
-
-dojo.io.Request = function(url, mimetype, transport, changeUrl){
-	if((arguments.length == 1)&&(arguments[0].constructor == Object)){
-		this.fromKwArgs(arguments[0]);
-	}else{
-		this.url = url;
-		if(mimetype){ this.mimetype = mimetype; }
-		if(transport){ this.transport = transport; }
-		if(arguments.length >= 4){ this.changeUrl = changeUrl; }
-	}
-}
-
-dojo.lang.extend(dojo.io.Request, {
-
-	/** The URL to hit */
-	url: "",
-	
-	/** The mime type used to interrpret the response body */
-	mimetype: "text/plain",
-	
-	/** The HTTP method to use */
-	method: "GET",
-	
-	/** An Object containing key-value pairs to be included with the request */
-	content: undefined, // Object
-	
-	/** The transport medium to use */
-	transport: undefined, // String
-	
-	/** If defined the URL of the page is physically changed */
-	changeUrl: undefined, // String
-	
-	/** A form node to use in the request */
-	formNode: undefined, // HTMLFormElement
-	
-	/** Whether the request should be made synchronously */
-	sync: false,
-	
-	bindSuccess: false,
-
-	/** Cache/look for the request in the cache before attempting to request?
-	 *  NOTE: this isn't a browser cache, this is internal and would only cache in-page
-	 */
-	useCache: false,
-
-	/** Prevent the browser from caching this by adding a query string argument to the URL */
-	preventCache: false,
-	
-	// events stuff
-	load: function(type, data, evt){ },
-	error: function(type, error){ },
-	timeout: function(type){ },
-	handle: function(){ },
-
-	//FIXME: change BrowserIO.js to use timeouts? IframeIO?
-	// The number of seconds to wait until firing a timeout callback.
-	// If it is zero, that means, don't do a timeout check.
-	timeoutSeconds: 0,
-	
-	// the abort method needs to be filled in by the transport that accepts the
-	// bind() request
-	abort: function(){ },
-	
-	// backButton: function(){ },
-	// forwardButton: function(){ },
-
-	fromKwArgs: function(kwArgs){
-		// normalize args
-		if(kwArgs["url"]){ kwArgs.url = kwArgs.url.toString(); }
-		if(kwArgs["formNode"]) { kwArgs.formNode = dojo.byId(kwArgs.formNode); }
-		if(!kwArgs["method"] && kwArgs["formNode"] && kwArgs["formNode"].method) {
-			kwArgs.method = kwArgs["formNode"].method;
-		}
-		
-		// backwards compatibility
-		if(!kwArgs["handle"] && kwArgs["handler"]){ kwArgs.handle = kwArgs.handler; }
-		if(!kwArgs["load"] && kwArgs["loaded"]){ kwArgs.load = kwArgs.loaded; }
-		if(!kwArgs["changeUrl"] && kwArgs["changeURL"]) { kwArgs.changeUrl = kwArgs.changeURL; }
-
-		// encoding fun!
-		kwArgs.encoding = dojo.lang.firstValued(kwArgs["encoding"], djConfig["bindEncoding"], "");
-
-		kwArgs.sendTransport = dojo.lang.firstValued(kwArgs["sendTransport"], djConfig["ioSendTransport"], false);
-
-		var isFunction = dojo.lang.isFunction;
-		for(var x=0; x<dojo.io.hdlrFuncNames.length; x++){
-			var fn = dojo.io.hdlrFuncNames[x];
-			if(isFunction(kwArgs[fn])){ continue; }
-			if(isFunction(kwArgs["handle"])){
-				kwArgs[fn] = kwArgs.handle;
-			}
-			// handler is aliased above, shouldn't need this check
-			/* else if(dojo.lang.isObject(kwArgs.handler)){
-				if(isFunction(kwArgs.handler[fn])){
-					kwArgs[fn] = kwArgs.handler[fn]||kwArgs.handler["handle"]||function(){};
-				}
-			}*/
-		}
-		dojo.lang.mixin(this, kwArgs);
-	}
-
-});
-
-dojo.io.Error = function(msg, type, num){
-	this.message = msg;
-	this.type =  type || "unknown"; // must be one of "io", "parse", "unknown"
-	this.number = num || 0; // per-substrate error number, not normalized
-}
-
-dojo.io.transports.addTransport = function(name){
-	this.push(name);
-	// FIXME: do we need to handle things that aren't direct children of the
-	// dojo.io namespace? (say, dojo.io.foo.fooTransport?)
-	this[name] = dojo.io[name];
-}
-
-// binding interface, the various implementations register their capabilities
-// and the bind() method dispatches
-dojo.io.bind = function(request){
-	// if the request asks for a particular implementation, use it
-	if(!(request instanceof dojo.io.Request)){
-		try{
-			request = new dojo.io.Request(request);
-		}catch(e){ dojo.debug(e); }
-	}
-	var tsName = "";
-	if(request["transport"]){
-		tsName = request["transport"];
-		// FIXME: it would be good to call the error handler, although we'd
-		// need to use setTimeout or similar to accomplish this and we can't
-		// garuntee that this facility is available.
-		if(!this[tsName]){ return request; }
-	}else{
-		// otherwise we do our best to auto-detect what available transports
-		// will handle 
-		for(var x=0; x<dojo.io.transports.length; x++){
-			var tmp = dojo.io.transports[x];
-			if((this[tmp])&&(this[tmp].canHandle(request))){
-				tsName = tmp;
-			}
-		}
-		if(tsName == ""){ return request; }
-	}
-	this[tsName].bind(request);
-	request.bindSuccess = true;
-	return request;
-}
-
-dojo.io.queueBind = function(request){
-	if(!(request instanceof dojo.io.Request)){
-		try{
-			request = new dojo.io.Request(request);
-		}catch(e){ dojo.debug(e); }
-	}
-
-	// make sure we get called if/when we get a response
-	var oldLoad = request.load;
-	request.load = function(){
-		dojo.io._queueBindInFlight = false;
-		var ret = oldLoad.apply(this, arguments);
-		dojo.io._dispatchNextQueueBind();
-		return ret;
-	}
-
-	var oldErr = request.error;
-	request.error = function(){
-		dojo.io._queueBindInFlight = false;
-		var ret = oldErr.apply(this, arguments);
-		dojo.io._dispatchNextQueueBind();
-		return ret;
-	}
-
-	dojo.io._bindQueue.push(request);
-	dojo.io._dispatchNextQueueBind();
-	return request;
-}
-
-dojo.io._dispatchNextQueueBind = function(){
-	if(!dojo.io._queueBindInFlight){
-		dojo.io._queueBindInFlight = true;
-		if(dojo.io._bindQueue.length > 0){
-			dojo.io.bind(dojo.io._bindQueue.shift());
-		}else{
-			dojo.io._queueBindInFlight = false;
-		}
-	}
-}
-dojo.io._bindQueue = [];
-dojo.io._queueBindInFlight = false;
-
-dojo.io.argsFromMap = function(map, encoding, last){
-	var enc = /utf/i.test(encoding||"") ? encodeURIComponent : dojo.string.encodeAscii;
-	var mapped = [];
-	var control = new Object();
-	for(var name in map){
-		var domap = function(elt){
-			var val = enc(name)+"="+enc(elt);
-			mapped[(last == name) ? "push" : "unshift"](val);
-		}
-		if(!control[name]){
-			var value = map[name];
-			// FIXME: should be isArrayLike?
-			if (dojo.lang.isArray(value)){
-				dojo.lang.forEach(value, domap);
-			}else{
-				domap(value);
-			}
-		}
-	}
-	return mapped.join("&");
-}
-
-dojo.io.setIFrameSrc = function(iframe, src, replace){
-	try{
-		var r = dojo.render.html;
-		// dojo.debug(iframe);
-		if(!replace){
-			if(r.safari){
-				iframe.location = src;
-			}else{
-				frames[iframe.name].location = src;
-			}
-		}else{
-			// Fun with DOM 0 incompatibilities!
-			var idoc;
-			if(r.ie){
-				idoc = iframe.contentWindow.document;
-			}else if(r.safari){
-				idoc = iframe.document;
-			}else{ //  if(r.moz){
-				idoc = iframe.contentWindow;
-			}
-
-			//For Safari (at least 2.0.3) and Opera, if the iframe
-			//has just been created but it doesn't have content
-			//yet, then iframe.document may be null. In that case,
-			//use iframe.location and return.
-			if(!idoc){
-				iframe.location = src;
-				return;
-			}else{
-				idoc.location.replace(src);
-			}
-		}
-	}catch(e){ 
-		dojo.debug(e); 
-		dojo.debug("setIFrameSrc: "+e); 
-	}
-}
-
-/*
-dojo.io.sampleTranport = new function(){
-	this.canHandle = function(kwArgs){
-		// canHandle just tells dojo.io.bind() if this is a good transport to
-		// use for the particular type of request.
-		if(	
-			(
-				(kwArgs["mimetype"] == "text/plain") ||
-				(kwArgs["mimetype"] == "text/html") ||
-				(kwArgs["mimetype"] == "text/javascript")
-			)&&(
-				(kwArgs["method"] == "get") ||
-				( (kwArgs["method"] == "post") && (!kwArgs["formNode"]) )
-			)
-		){
-			return true;
-		}
-
-		return false;
-	}
-
-	this.bind = function(kwArgs){
-		var hdlrObj = {};
-
-		// set up a handler object
-		for(var x=0; x<dojo.io.hdlrFuncNames.length; x++){
-			var fn = dojo.io.hdlrFuncNames[x];
-			if(typeof kwArgs.handler == "object"){
-				if(typeof kwArgs.handler[fn] == "function"){
-					hdlrObj[fn] = kwArgs.handler[fn]||kwArgs.handler["handle"];
-				}
-			}else if(typeof kwArgs[fn] == "function"){
-				hdlrObj[fn] = kwArgs[fn];
-			}else{
-				hdlrObj[fn] = kwArgs["handle"]||function(){};
-			}
-		}
-
-		// build a handler function that calls back to the handler obj
-		var hdlrFunc = function(evt){
-			if(evt.type == "onload"){
-				hdlrObj.load("load", evt.data, evt);
-			}else if(evt.type == "onerr"){
-				var errObj = new dojo.io.Error("sampleTransport Error: "+evt.msg);
-				hdlrObj.error("error", errObj);
-			}
-		}
-
-		// the sample transport would attach the hdlrFunc() when sending the
-		// request down the pipe at this point
-		var tgtURL = kwArgs.url+"?"+dojo.io.argsFromMap(kwArgs.content);
-		// sampleTransport.sendRequest(tgtURL, hdlrFunc);
-	}
-
-	dojo.io.transports.addTransport("sampleTranport");
-}
-*/
+dojo.require("dojo.io.*");
+dojo.deprecated("dojo.io", "replaced by dojo.io.*", "0.5");

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/BrowserIO.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/BrowserIO.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/BrowserIO.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/BrowserIO.js Fri Nov 10 01:15:01 2006
@@ -10,7 +10,7 @@
 
 dojo.provide("dojo.io.BrowserIO");
 
-dojo.require("dojo.io");
+dojo.require("dojo.io.common");
 dojo.require("dojo.lang.array");
 dojo.require("dojo.lang.func");
 dojo.require("dojo.string.extras");
@@ -57,7 +57,7 @@
 dojo.io.formFilter = function(node) {
 	var type = (node.type||"").toLowerCase();
 	return !node.disabled && node.name
-		&& !dojo.lang.inArray(type, ["file", "submit", "image", "reset", "button"]);
+		&& !dojo.lang.inArray(["file", "submit", "image", "reset", "button"], type);
 }
 
 // TODO: Move to htmlUtils
@@ -81,7 +81,7 @@
 					values.push(name + "=" + enc(elm.options[j].value));
 				}
 			}
-		}else if(dojo.lang.inArray(type, ["radio", "checkbox"])){
+		}else if(dojo.lang.inArray(["radio", "checkbox"], type)){
 			if(elm.checked){
 				values.push(name + "=" + enc(elm.value));
 			}
@@ -139,7 +139,7 @@
 
 		for(var i = 0; i < form.elements.length; i++) {
 			var node = form.elements[i];
-			if(node && node.type && dojo.lang.inArray(node.type.toLowerCase(), ["submit", "button"])) {
+			if(node && node.type && dojo.lang.inArray(["submit", "button"], node.type.toLowerCase())) {
 				this.connect(node, "onclick", "click");
 			}
 		}
@@ -177,11 +177,11 @@
 		var accept = false;
 		if(node.disabled || !node.name) {
 			accept = false;
-		} else if(dojo.lang.inArray(type, ["submit", "button", "image"])) {
+		} else if(dojo.lang.inArray(["submit", "button", "image"], type)) {
 			if(!this.clickedButton) { this.clickedButton = node; }
 			accept = node == this.clickedButton;
 		} else {
-			accept = !dojo.lang.inArray(type, ["file", "submit", "reset", "button"]);
+			accept = !dojo.lang.inArray(["file", "submit", "reset", "button"], type);
 		}
 		return accept;
 	},
@@ -253,7 +253,7 @@
 					dojo.debug(http.responseText);
 					ret = null;
 				}
-			}else if(kwArgs.mimetype == "text/json"){
+			}else if(kwArgs.mimetype == "text/json" || kwArgs.mimetype == "application/json"){
 				try{
 					ret = dj_eval("("+http.responseText+")");
 				}catch(e){
@@ -299,41 +299,61 @@
 
 	this.startWatchingInFlight = function(){
 		if(!this.inFlightTimer){
-			this.inFlightTimer = setInterval("dojo.io.XMLHTTPTransport.watchInFlight();", 10);
+			// setInterval broken in mozilla x86_64 in some circumstances, see
+			// https://bugzilla.mozilla.org/show_bug.cgi?id=344439
+			// using setTimeout instead
+			this.inFlightTimer = setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();", 10);
 		}
 	}
 
 	this.watchInFlight = function(){
 		var now = null;
-		for(var x=this.inFlight.length-1; x>=0; x--){
-			var tif = this.inFlight[x];
-			if(!tif){ this.inFlight.splice(x, 1); continue; }
-			if(4==tif.http.readyState){
-				// remove it so we can clean refs
-				this.inFlight.splice(x, 1);
-				doLoad(tif.req, tif.http, tif.url, tif.query, tif.useCache);
-			}else if (tif.startTime){
-				//See if this is a timeout case.
-				if(!now){
-					now = (new Date()).getTime();
-				}
-				if(tif.startTime + (tif.req.timeoutSeconds * 1000) < now){
-					//Stop the request.
-					if(typeof tif.http.abort == "function"){
-						tif.http.abort();
+		// make sure sync calls stay thread safe, if this callback is called during a sync call
+		// and this results in another sync call before the first sync call ends the browser hangs
+		if(!dojo.hostenv._blockAsync && !_this._blockAsync){
+			for(var x=this.inFlight.length-1; x>=0; x--){
+				try{
+					var tif = this.inFlight[x];
+					if(!tif || tif.http._aborted || !tif.http.readyState){
+						this.inFlight.splice(x, 1); continue; 
+					}
+					if(4==tif.http.readyState){
+						// remove it so we can clean refs
+						this.inFlight.splice(x, 1);
+						doLoad(tif.req, tif.http, tif.url, tif.query, tif.useCache);
+					}else if (tif.startTime){
+						//See if this is a timeout case.
+						if(!now){
+							now = (new Date()).getTime();
+						}
+						if(tif.startTime + (tif.req.timeoutSeconds * 1000) < now){
+							//Stop the request.
+							if(typeof tif.http.abort == "function"){
+								tif.http.abort();
+							}
+		
+							// remove it so we can clean refs
+							this.inFlight.splice(x, 1);
+							tif.req[(typeof tif.req.timeout == "function") ? "timeout" : "handle"]("timeout", null, tif.http, tif.req);
+						}
+					}
+				}catch(e){
+					try{
+						var errObj = new dojo.io.Error("XMLHttpTransport.watchInFlight Error: " + e);
+						tif.req[(typeof tif.req.error == "function") ? "error" : "handle"]("error", errObj, tif.http, tif.req);
+					}catch(e2){
+						dojo.debug("XMLHttpTransport error callback failed: " + e2);
 					}
-
-					// remove it so we can clean refs
-					this.inFlight.splice(x, 1);
-					tif.req[(typeof tif.req.timeout == "function") ? "timeout" : "handle"]("timeout", null, tif.http, tif.req);
 				}
 			}
 		}
 
+		clearTimeout(this.inFlightTimer);
 		if(this.inFlight.length == 0){
-			clearInterval(this.inFlightTimer);
 			this.inFlightTimer = null;
+			return;
 		}
+		this.inFlightTimer = setTimeout("dojo.io.XMLHTTPTransport.watchInFlight();", 10);
 	}
 
 	var hasXmlHttp = dojo.hostenv.getXmlhttpObject() ? true : false;
@@ -345,7 +365,7 @@
 		// multi-part mime encoded and avoid using this transport for those
 		// requests.
 		return hasXmlHttp
-			&& dojo.lang.inArray((kwArgs["mimetype"].toLowerCase()||""), ["text/plain", "text/html", "application/xml", "text/xml", "text/javascript", "text/json"])
+			&& dojo.lang.inArray(["text/plain", "text/html", "application/xml", "text/xml", "text/javascript", "text/json", "application/json"], (kwArgs["mimetype"].toLowerCase()||""))
 			&& !( kwArgs["formNode"] && dojo.io.formHasFile(kwArgs["formNode"]) );
 	}
 
@@ -389,7 +409,7 @@
 			kwArgs.method = "get";
 		}
 
-		// guess the multipart value		
+		// guess the multipart value
 		if(kwArgs.method.toLowerCase() == "get"){
 			// GET cannot use multipart
 			kwArgs.multipart = false;
@@ -506,11 +526,18 @@
 				"startTime": kwArgs.timeoutSeconds ? (new Date()).getTime() : 0
 			});
 			this.startWatchingInFlight();
+		}else{
+			// block async callbacks until sync is in, needed in khtml, others?
+			_this._blockAsync = true;
 		}
 
 		if(kwArgs.method.toLowerCase() == "post"){
 			// FIXME: need to hack in more flexible Content-Type setting here!
-			http.open("POST", url, async);
+			if (!kwArgs.user) {
+				http.open("POST", url, async);
+			}else{
+        http.open("POST", url, async, kwArgs.user, kwArgs.password);
+			}
 			setHeaders(http, kwArgs);
 			http.setRequestHeader("Content-Type", kwArgs.multipart ? ("multipart/form-data; boundary=" + this.multipartBoundary) : 
 				(kwArgs.contentType || "application/x-www-form-urlencoded"));
@@ -531,7 +558,11 @@
 				tmpUrl += (dojo.string.endsWithAny(tmpUrl, "?", "&")
 					? "" : (tmpUrl.indexOf("?") > -1 ? "&" : "?")) + "dojo.preventCache=" + new Date().valueOf();
 			}
-			http.open(kwArgs.method.toUpperCase(), tmpUrl, async);
+			if (!kwArgs.user) {
+				http.open(kwArgs.method.toUpperCase(), tmpUrl, async);
+			}else{
+				http.open(kwArgs.method.toUpperCase(), tmpUrl, async, kwArgs.user, kwArgs.password);
+			}
 			setHeaders(http, kwArgs);
 			try {
 				http.send(null);
@@ -545,9 +576,13 @@
 
 		if( !async ) {
 			doLoad(kwArgs, http, url, query, useCache);
+			_this._blockAsync = false;
 		}
 
 		kwArgs.abort = function(){
+			try{// khtml doesent reset readyState on abort, need this workaround
+				http._aborted = true; 
+			}catch(e){/*squelsh*/}
 			return http.abort();
 		}
 

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/IframeIO.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/IframeIO.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/IframeIO.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/IframeIO.js Fri Nov 10 01:15:01 2006
@@ -15,23 +15,27 @@
 // FIXME: is it possible to use the Google htmlfile hack to prevent the
 // background click with this transport?
 
-dojo.io.createIFrame = function(fname, onloadstr){
+dojo.io.createIFrame = function(fname, onloadstr, uri){
 	if(window[fname]){ return window[fname]; }
 	if(window.frames[fname]){ return window.frames[fname]; }
 	var r = dojo.render.html;
 	var cframe = null;
-	var turi = dojo.uri.dojoUri("iframe_history.html?noInit=true");
-	var ifrstr = ((r.ie)&&(dojo.render.os.win)) ? "<iframe name='"+fname+"' src='"+turi+"' onload='"+onloadstr+"'>" : "iframe";
+	var turi = uri||dojo.uri.dojoUri("iframe_history.html?noInit=true");
+	var ifrstr = ((r.ie)&&(dojo.render.os.win)) ? '<iframe name="'+fname+'" src="'+turi+'" onload="'+onloadstr+'">' : 'iframe';
 	cframe = document.createElement(ifrstr);
 	with(cframe){
 		name = fname;
 		setAttribute("name", fname);
 		id = fname;
 	}
-	(document.body||document.getElementsByTagName("body")[0]).appendChild(cframe);
+	dojo.body().appendChild(cframe);
 	window[fname] = cframe;
+
 	with(cframe.style){
-		position = "absolute";
+		if(!r.safari){
+			//We can't change the src in Safari 2.0.3 if absolute position. Bizarro.
+			position = "absolute";
+		}
 		left = top = "0px";
 		height = width = "1px";
 		visibility = "hidden";
@@ -49,31 +53,10 @@
 		dojo.io.setIFrameSrc(cframe, turi, true);
 		cframe.onload = new Function(onloadstr);
 	}
+	
 	return cframe;
 }
 
-// thanks burstlib!
-dojo.io.iframeContentWindow = function(iframe_el) {
-	var win = iframe_el.contentWindow || // IE
-		dojo.io.iframeContentDocument(iframe_el).defaultView || // Moz, opera
-		// Moz. TODO: is this available when defaultView isn't?
-		dojo.io.iframeContentDocument(iframe_el).__parent__ || 
-		(iframe_el.name && document.frames[iframe_el.name]) || null;
-	return win;
-}
-
-dojo.io.iframeContentDocument = function(iframe_el){
-	var doc = iframe_el.contentDocument || // W3
-		(
-			(iframe_el.contentWindow)&&(iframe_el.contentWindow.document)
-		) ||  // IE
-		(
-			(iframe_el.name)&&(document.frames[iframe_el.name])&&
-			(document.frames[iframe_el.name].document)
-		) || null;
-	return doc;
-}
-
 dojo.io.IframeTransport = new function(){
 	var _this = this;
 	this.currentRequest = null;
@@ -81,71 +64,68 @@
 	this.iframeName = "dojoIoIframe";
 
 	this.fireNextRequest = function(){
-		if((this.currentRequest)||(this.requestQueue.length == 0)){ return; }
-		// dojo.debug("fireNextRequest");
-		var cr = this.currentRequest = this.requestQueue.shift();
-		cr._contentToClean = [];
-		var fn = cr["formNode"];
-		var content = cr["content"] || {};
-		if(cr.sendTransport) {
-			content["dojo.transport"] = "iframe";
-		}
-		if(fn){
-			if(content){
-				// if we have things in content, we need to add them to the form
-				// before submission
-				for(var x in content){
-					if(!fn[x]){
-						var tn;
-						if(dojo.render.html.ie){
-							tn = document.createElement("<input type='hidden' name='"+x+"' value='"+content[x]+"'>");
-							fn.appendChild(tn);
+		try{
+			if((this.currentRequest)||(this.requestQueue.length == 0)){ return; }
+			// dojo.debug("fireNextRequest");
+			var cr = this.currentRequest = this.requestQueue.shift();
+			cr._contentToClean = [];
+			var fn = cr["formNode"];
+			var content = cr["content"] || {};
+			if(cr.sendTransport) {
+				content["dojo.transport"] = "iframe";
+			}
+			if(fn){
+				if(content){
+					// if we have things in content, we need to add them to the form
+					// before submission
+					for(var x in content){
+						if(!fn[x]){
+							var tn;
+							if(dojo.render.html.ie){
+								tn = document.createElement("<input type='hidden' name='"+x+"' value='"+content[x]+"'>");
+								fn.appendChild(tn);
+							}else{
+								tn = document.createElement("input");
+								fn.appendChild(tn);
+								tn.type = "hidden";
+								tn.name = x;
+								tn.value = content[x];
+							}
+							cr._contentToClean.push(x);
 						}else{
-							tn = document.createElement("input");
-							fn.appendChild(tn);
-							tn.type = "hidden";
-							tn.name = x;
-							tn.value = content[x];
+							fn[x].value = content[x];
 						}
-						cr._contentToClean.push(x);
-					}else{
-						fn[x].value = content[x];
 					}
 				}
+				if(cr["url"]){
+					cr._originalAction = fn.getAttribute("action");
+					fn.setAttribute("action", cr.url);
+				}
+				if(!fn.getAttribute("method")){
+					fn.setAttribute("method", (cr["method"]) ? cr["method"] : "post");
+				}
+				cr._originalTarget = fn.getAttribute("target");
+				fn.setAttribute("target", this.iframeName);
+				fn.target = this.iframeName;
+				fn.submit();
+			}else{
+				// otherwise we post a GET string by changing URL location for the
+				// iframe
+				var query = dojo.io.argsFromMap(this.currentRequest.content);
+				var tmpUrl = cr.url + (cr.url.indexOf("?") > -1 ? "&" : "?") + query;
+				dojo.io.setIFrameSrc(this.iframe, tmpUrl, true);
 			}
-			if(cr["url"]){
-				cr._originalAction = fn.getAttribute("action");
-				fn.setAttribute("action", cr.url);
-			}
-			if(!fn.getAttribute("method")){
-				fn.setAttribute("method", (cr["method"]) ? cr["method"] : "post");
-			}
-			cr._originalTarget = fn.getAttribute("target");
-			fn.setAttribute("target", this.iframeName);
-			fn.target = this.iframeName;
-			fn.submit();
-		}else{
-			// otherwise we post a GET string by changing URL location for the
-			// iframe
-			var query = dojo.io.argsFromMap(this.currentRequest.content);
-			var tmpUrl = (cr.url.indexOf("?") > -1 ? "&" : "?") + query;
-			dojo.io.setIFrameSrc(this.iframe, tmpUrl, true);
+		}catch(e){
+			this.iframeOnload(e);
 		}
 	}
 
 	this.canHandle = function(kwArgs){
 		return (
 			(
-				// FIXME: can we really handle text/plain and
-				// text/javascript requests?
-				dojo.lang.inArray(kwArgs["mimetype"], 
-				[	"text/plain", "text/html", 
-					"text/javascript", "text/json"])
+				dojo.lang.inArray([	"text/plain", "text/html", "text/javascript", "text/json", "application/json"], kwArgs["mimetype"])
 			)&&(
-				// make sur we really only get used in file upload cases	
-				(kwArgs["formNode"])&&(dojo.io.checkChildrenForFile(kwArgs["formNode"]))
-			)&&(
-				dojo.lang.inArray(kwArgs["method"].toLowerCase(), ["post", "get"])
+				dojo.lang.inArray(["post", "get"], kwArgs["method"].toLowerCase())
 			)&&(
 				// never handle a sync request
 				!  ((kwArgs["sync"])&&(kwArgs["sync"] == true))
@@ -167,7 +147,7 @@
 		this.iframe = dojo.io.createIFrame(this.iframeName, "dojo.io.IframeTransport.iframeOnload();");
 	}
 
-	this.iframeOnload = function(){
+	this.iframeOnload = function(errorObject /* Object */){
 		if(!_this.currentRequest){
 			_this.fireNextRequest();
 			return;
@@ -175,63 +155,81 @@
 
 		var req = _this.currentRequest;
 
-		// remove all the hidden content inputs
-		var toClean = req._contentToClean;
-		for(var i = 0; i < toClean.length; i++) {
-			var key = toClean[i];
-			if(dojo.render.html.safari){
-				//In Safari (at least 2.0.3), can't use formNode[key] syntax to find the node,
-				//for nodes that were dynamically added.
-				var fNode = req.formNode;
-				for(var j = 0; j < fNode.childNodes.length; j++){
-					var chNode = fNode.childNodes[j];
-					if(chNode.name == key){
-						var pNode = chNode.parentNode;
-						pNode.removeChild(chNode);
-						break;
+		if(req.formNode){
+			// remove all the hidden content inputs
+			var toClean = req._contentToClean;
+			for(var i = 0; i < toClean.length; i++) {
+				var key = toClean[i];
+				if(dojo.render.html.safari){
+					//In Safari (at least 2.0.3), can't use formNode[key] syntax to find the node,
+					//for nodes that were dynamically added.
+					var fNode = req.formNode;
+					for(var j = 0; j < fNode.childNodes.length; j++){
+						var chNode = fNode.childNodes[j];
+						if(chNode.name == key){
+							var pNode = chNode.parentNode;
+							pNode.removeChild(chNode);
+							break;
+						}
 					}
+				}else{
+					var input = req.formNode[key];
+					req.formNode.removeChild(input);
+					req.formNode[key] = null;
 				}
-			}else{
-				var input = req.formNode[key];
-				req.formNode.removeChild(input);
-				req.formNode[key] = null;
+			}
+	
+			// restore original action + target
+			if(req["_originalAction"]){
+				req.formNode.setAttribute("action", req._originalAction);
+			}
+			if(req["_originalTarget"]){
+				req.formNode.setAttribute("target", req._originalTarget);
+				req.formNode.target = req._originalTarget;
 			}
 		}
 
-		// restore original action + target
-		if(req["_originalAction"]){
-			req.formNode.setAttribute("action", req._originalAction);
-		}
-		req.formNode.setAttribute("target", req._originalTarget);
-		req.formNode.target = req._originalTarget;
+		var contentDoc = function(iframe_el){
+			var doc = iframe_el.contentDocument || // W3
+				(
+					(iframe_el.contentWindow)&&(iframe_el.contentWindow.document)
+				) ||  // IE
+				(
+					(iframe_el.name)&&(document.frames[iframe_el.name])&&
+					(document.frames[iframe_el.name].document)
+				) || null;
+			return doc;
+		};
 
-		var ifd = dojo.io.iframeContentDocument(_this.iframe);
-		// handle successful returns
-		// FIXME: how do we determine success for iframes? Is there an equiv of
-		// the "status" property?
 		var value;
 		var success = false;
 
-		try{
-			var cmt = req.mimetype;
-			if((cmt == "text/javascript")||(cmt == "text/json")){
-				// FIXME: not sure what to do here? try to pull some evalulable
-				// text from a textarea or cdata section? 
-				// how should we set up the contract for that?
-				var js = ifd.getElementsByTagName("textarea")[0].value;
-				if(cmt == "text/json") { js = "(" + js + ")"; }
-				value = dj_eval(js);
-			}else if(cmt == "text/html"){
-				value = ifd;
-			}else{ // text/plain
-				value = ifd.getElementsByTagName("textarea")[0].value;
-			}
-			success = true;
-		}catch(e){ 
-			// looks like we didn't get what we wanted!
-			var errObj = new dojo.io.Error("IframeTransport Error");
-			if(dojo.lang.isFunction(req["error"])){
-				req.error("error", errObj, req);
+		if (errorObject){
+				this._callError(req, "IframeTransport Request Error: " + errorObject);
+		}else{
+			var ifd = contentDoc(_this.iframe);
+			// handle successful returns
+			// FIXME: how do we determine success for iframes? Is there an equiv of
+			// the "status" property?
+	
+			try{
+				var cmt = req.mimetype;
+				if((cmt == "text/javascript")||(cmt == "text/json")||(cmt == "application/json")){
+					// FIXME: not sure what to do here? try to pull some evalulable
+					// text from a textarea or cdata section? 
+					// how should we set up the contract for that?
+					var js = ifd.getElementsByTagName("textarea")[0].value;
+					if(cmt == "text/json" || cmt == "application/json") { js = "(" + js + ")"; }
+					value = dj_eval(js);
+				}else if(cmt == "text/html"){
+					value = ifd;
+				}else{ // text/plain
+					value = ifd.getElementsByTagName("textarea")[0].value;
+				}
+				success = true;
+			}catch(e){ 
+				// looks like we didn't get what we wanted!
+				this._callError(req, "IframeTransport Error: " + e);
 			}
 		}
 
@@ -246,6 +244,13 @@
 		} finally {
 			_this.currentRequest = null;
 			_this.fireNextRequest();
+		}
+	}
+	
+	this._callError = function(req /* Object */, message /* String */){
+		var errObj = new dojo.io.Error(message);
+		if(dojo.lang.isFunction(req["error"])){
+			req.error("error", errObj, req);
 		}
 	}
 

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RepubsubIO.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RepubsubIO.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RepubsubIO.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RepubsubIO.js Fri Nov 10 01:15:01 2006
@@ -1,13 +1,10 @@
 //	Copyright (c) 2004 Friendster Inc., Licensed under the Academic Free
 //	License version 2.0 or later 
 
-dojo.require("dojo.event.Event");
-dojo.require("dojo.event.BrowserEvent");
+dojo.require("dojo.event.*");
 dojo.require("dojo.io.BrowserIO");
 
 dojo.provide("dojo.io.RepubsubIO");
-dojo.provide("dojo.io.repubsub");
-dojo.provide("dojo.io.repubsubTransport");
 
 dojo.io.repubsubTranport = new function(){
 	var rps = dojo.io.repubsub;

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RhinoIO.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RhinoIO.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RhinoIO.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/RhinoIO.js Fri Nov 10 01:15:01 2006
@@ -10,13 +10,138 @@
 
 dojo.provide("dojo.io.RhinoIO");
 
-// TODO: this doesn't execute
-/*dojo.io.SyncHTTPRequest = function(){
-	dojo.io.SyncRequest.call(this);
+dojo.require("dojo.io.common");
+dojo.require("dojo.lang.func");
+dojo.require("dojo.lang.array");
+dojo.require("dojo.string.extras");
 
-	this.send = function(URI){
-	}
-}
+dojo.io.RhinoHTTPTransport = new function(){
+		this.canHandle = function(req){
+			// We have to limit to text types because Rhino doesnt support 
+			// a W3C dom implementation out of the box.  In the future we 
+			// should provide some kind of hook to inject your own, because
+			// in all my projects I use XML for Script to provide a W3C DOM.
+			if(!dojo.lang.inArray((req.mimetype.toLowerCase() || ""),
+				["text/plain", "text/html", "text/javascript", "text/json", "application/json"])){
+				return false;
+			}
+			
+			// We only handle http requests!  Unfortunately, because the method is 
+			// protected, I can't directly create a java.net.HttpURLConnection, so
+			// this is the only way to test.
+			if(req.url.substr(0, 7) != "http://"){
+				return false;
+			}
+			
+			return true;
+		}
+
+		function doLoad(req, conn){
+			var ret;
+			if (req.method.toLowerCase() == "head"){
+				// TODO: return the headers
+			}else{
+				var stream = conn.getContent();
+				var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream));
+
+				// read line-by-line because why not?
+				var text = "";
+				var line = null;
+				while((line = reader.readLine()) != null){
+					text += line;
+				}
+
+				if(req.mimetype == "text/javascript"){
+					try{
+						ret = dj_eval(text);
+					}catch(e){
+						dojo.debug(e);
+						dojo.debug(text);
+						ret = null;
+					}
+				}else if(req.mimetype == "text/json" || req.mimetype == "application/json"){
+					try{
+						ret = dj_eval("("+text+")");
+					}catch(e){
+						dojo.debug(e);
+						dojo.debug(text);
+						ret = false;
+					}
+				}else{
+					ret = text;
+				}
+			}
+
+			req.load("load", ret, req);
+		}
+		
+		function connect(req){
+			var content = req.content || {};
+			var query;
+	
+			if (req.sendTransport){
+				content["dojo.transport"] = "rhinohttp";
+			}
+	
+			if(req.postContent){
+				query = req.postContent;
+			}else{
+				query = dojo.io.argsFromMap(content, req.encoding);
+			}
+	
+			var url_text = req.url;
+			if(req.method.toLowerCase() == "get" && query != ""){
+				url_text = url_text + "?" + query;
+			}
+			
+			var url  = new java.net.URL(url_text);
+			var conn = url.openConnection();
+			
+			//
+			// configure the connection
+			//
+			
+			conn.setRequestMethod(req.method.toUpperCase());
+			
+			if(req.headers){
+				for(var header in req.headers){
+					if(header.toLowerCase() == "content-type" && !req.contentType){
+						req.contentType = req.headers[header];
+					}else{
+						conn.setRequestProperty(header, req.headers[header]);
+					}
+				}
+			}
+			if(req.contentType){
+				conn.setRequestProperty("Content-Type", req.contentType);
+			}
 
-dojo.inherits(dojo.io.SyncHTTPRequest, dojo.io.SyncRequest);
-*/
+			if(req.method.toLowerCase() == "post"){
+				conn.setDoOutput(true);
+
+				// write the post data
+				var output_stream = conn.getOutputStream();
+				var byte_array = (new java.lang.String(query)).getBytes();
+				output_stream.write(byte_array, 0, byte_array.length);
+			}
+			
+			// do it to it!
+			conn.connect();
+
+			// perform the load
+			doLoad(req, conn);
+		}
+		
+		this.bind = function(req){
+			var async = req["sync"] ? false : true;
+			if (async){
+				setTimeout(dojo.lang.hitch(this, function(){
+					connect(req);
+				}), 1);
+			} else {
+				connect(req);
+			}
+		}
+
+		dojo.io.transports.addTransport("RhinoHTTPTransport");
+}

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/ScriptSrcIO.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/ScriptSrcIO.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/ScriptSrcIO.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/ScriptSrcIO.js Fri Nov 10 01:15:01 2006
@@ -47,15 +47,17 @@
 			if(currentState.isDone){
 				doneCount++;
 				delete this._state[param];
-			}else{
+			}else if(!currentState.isFinishing){
 				var listener = currentState.kwArgs;
 				try{
 					if(currentState.checkString && eval("typeof(" + currentState.checkString + ") != 'undefined'")){
+						currentState.isFinishing = true;
 						this._finish(currentState, "load");
 						doneCount++;
 						delete this._state[param];
 					}else if(listener.timeoutSeconds && listener.timeout){
 						if(currentState.startTime + (listener.timeoutSeconds * 1000) < (new Date()).getTime()){
+							currentState.isFinishing = true;
 							this._finish(currentState, "timeout");
 							doneCount++;
 							delete this._state[param];
@@ -68,19 +70,20 @@
 						doneCount++;
 					}
 				}catch(e){
+					currentState.isFinishing = true;
 					this._finish(currentState, "error", {status: this.DsrStatusCodes.Error, response: e});
 				}
 			}
 		}
 	
-		if(doneCount == totalCount){
+		if(doneCount >= totalCount){
 			clearInterval(this.inFlightTimer);
 			this.inFlightTimer = null;
 		}
 	}
 
 	this.canHandle = function(kwArgs){
-		return dojo.lang.inArray((kwArgs["mimetype"].toLowerCase()), ["text/javascript", "text/json"])
+		return dojo.lang.inArray(["text/javascript", "text/json", "application/json"], (kwArgs["mimetype"].toLowerCase()))
 			&& (kwArgs["method"].toLowerCase() == "get")
 			&& !(kwArgs["formNode"] && dojo.io.formHasFile(kwArgs["formNode"]))
 			&& (!kwArgs["sync"] || kwArgs["sync"] == false)
@@ -178,7 +181,8 @@
 			"url": url,
 			"query": query,
 			"kwArgs": kwArgs,
-			"startTime": (new Date()).getTime()
+			"startTime": (new Date()).getTime(),
+			"isFinishing": false
 		};
 
 		if(!url){
@@ -192,7 +196,9 @@
 			state.jsonp = content[jsonpName];
 			state.jsonpCall = function(data){
 				if(data["Error"]||data["error"]){
-					dojo.debug(dojo.json.serialize(data));
+					if(dojo["json"] && dojo["json"]["serialize"]){
+						dojo.debug(dojo.json.serialize(data));
+					}
 					dojo.io.ScriptSrcTransport._finish(this, "error", data);
 				}else{
 					dojo.io.ScriptSrcTransport._finish(this, "load", data);

Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,211 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.provide("dojo.io.XhrIframeProxy");
+
+dojo.require("dojo.experimental");
+dojo.experimental("dojo.io.XhrIframeProxy");
+
+dojo.require("dojo.io.IframeIO");
+dojo.require("dojo.html.iframe");
+dojo.require("dojo.dom");
+dojo.require("dojo.uri.Uri");
+
+/*
+TODO: This page might generate a "loading unsecure items on a secure page"
+popup in browsers if it is served on a https URL, given that we are not
+setting a src on the iframe element.
+//TODO: Document that it doesn't work from local disk in Safari.
+
+*/
+
+dojo.io.XhrIframeProxy = new function(){
+	this.xipClientUrl = dojo.uri.dojoUri("src/io/xip_client.html");
+
+	this._state = {};
+	this._stateIdCounter = 0;
+
+	this.send = function(facade){		
+		var stateId = "XhrIframeProxy" + (this._stateIdCounter++);
+		facade._stateId = stateId;
+
+		this._state[stateId] = {
+			facade: facade,
+			stateId: stateId,
+			clientFrame: dojo.io.createIFrame(stateId,
+				"dojo.io.XhrIframeProxy.clientFrameLoaded('" + stateId + "');",
+				this.xipClientUrl)
+		};
+	}
+	
+	this.receive = function(stateId, urlEncodedData){
+		/* urlEncodedData should have the following params:
+				- responseHeaders
+				- status
+				- statusText
+				- responseText
+		*/
+		//Decode response data.
+		var response = {};
+		var nvPairs = urlEncodedData.split("&");
+		for(var i = 0; i < nvPairs.length; i++){
+			if(nvPairs[i]){
+				var nameValue = nvPairs[i].split("=");
+				response[decodeURIComponent(nameValue[0])] = decodeURIComponent(nameValue[1]);
+			}
+		}
+
+		//Set data on facade object.
+		var state = this._state[stateId];
+		var facade = state.facade;
+
+		facade._setResponseHeaders(response.responseHeaders);
+		if(response.status == 0 || response.status){
+			facade.status = parseInt(response.status, 10);
+		}
+		if(response.statusText){
+			facade.statusText = response.statusText;
+		}
+		if(response.responseText){
+			facade.responseText = response.responseText;
+			
+			//Fix responseXML.
+			var contentType = facade.getResponseHeader("Content-Type");
+			if(contentType && (contentType == "application/xml" || contentType == "text/xml")){
+				facade.responseXML = dojo.dom.createDocumentFromText(response.responseText, contentType);
+			}
+		}
+		facade.readyState = 4;
+		
+		this.destroyState(stateId);
+	}
+
+	this.clientFrameLoaded = function(stateId){
+		var state = this._state[stateId];
+		var facade = state.facade;
+		var clientWindow = dojo.html.iframeContentWindow(state.clientFrame);
+		
+		var reqHeaders = [];
+		for(var param in facade._requestHeaders){
+			reqHeaders.push(param + ": " + facade._requestHeaders[param]);
+		}
+		
+		var requestData = {
+			uri: facade._uri
+		};
+		if(reqHeaders.length > 0){
+			requestData.requestHeaders = reqHeaders.join("\r\n");		
+		}
+		if(facade._method){
+			requestData.method = facade._method;
+		}
+		if(facade._bodyData){
+			requestData.data = facade._bodyData;
+		}
+
+		clientWindow.send(stateId, facade._ifpServerUrl, dojo.io.argsFromMap(requestData, "utf8"));
+	}
+	
+	this.destroyState = function(stateId){
+		var state = this._state[stateId];
+		if(state){
+			delete this._state[stateId];
+			var parentNode = state.clientFrame.parentNode;
+			parentNode.removeChild(state.clientFrame);
+			state.clientFrame = null;
+			state = null;
+		}
+	}
+
+	this.createFacade = function(){
+		if(arguments && arguments[0] && arguments[0]["iframeProxyUrl"]){
+			return new dojo.io.XhrIframeFacade(arguments[0]["iframeProxyUrl"]);
+		}else{
+			return dojo.io.XhrIframeProxy.oldGetXmlhttpObject.apply(dojo.hostenv, arguments);
+		}
+	}
+}
+
+//Replace the normal XHR factory with the proxy one.
+dojo.io.XhrIframeProxy.oldGetXmlhttpObject = dojo.hostenv.getXmlhttpObject;
+dojo.hostenv.getXmlhttpObject = dojo.io.XhrIframeProxy.createFacade;
+
+/**
+	Using this a reference: http://www.w3.org/TR/XMLHttpRequest/
+
+	Does not implement the onreadystate callback since dojo.io.BrowserIO does
+	not use it.
+*/
+dojo.io.XhrIframeFacade = function(ifpServerUrl){
+	this._requestHeaders = {};
+	this._allResponseHeaders = null;
+	this._responseHeaders = {};
+	this._method = null;
+	this._uri = null;
+	this._bodyData = null;
+	this.responseText = null;
+	this.responseXML = null;
+	this.status = null;
+	this.statusText = null;
+	this.readyState = 0;
+	
+	this._ifpServerUrl = ifpServerUrl;
+	this._stateId = null;
+}
+
+dojo.lang.extend(dojo.io.XhrIframeFacade, {
+	//The open method does not properly reset since Dojo does not reuse XHR objects.
+	open: function(method, uri){
+		this._method = method;
+		this._uri = uri;
+
+		this.readyState = 1;
+	},
+	
+	setRequestHeader: function(header, value){
+		this._requestHeaders[header] = value;
+	},
+	
+	send: function(stringData){
+		this._bodyData = stringData;
+		
+		dojo.io.XhrIframeProxy.send(this);
+		
+		this.readyState = 2;
+	},
+	abort: function(){
+		dojo.io.XhrIframeProxy.destroyState(this._stateId);
+	},
+	
+	getAllResponseHeaders: function(){
+		return this._allResponseHeaders;
+
+	},
+	
+	getResponseHeader: function(header){
+		return this._responseHeaders[header];
+	},
+	
+	_setResponseHeaders: function(allHeaders){
+		if(allHeaders){
+			this._allResponseHeaders = allHeaders;
+			
+			//Make sure ther are now CR characters in the headers.
+			allHeaders = allHeaders.replace(/\r/g, "");
+			var nvPairs = allHeaders.split("\n");
+			for(var i = 0; i < nvPairs.length; i++){
+				if(nvPairs[i]){
+					var nameValue = nvPairs[i].split(": ");
+					this._responseHeaders[nameValue[0]] = nameValue[1];
+				}
+			}
+		}
+	}
+});

Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js
------------------------------------------------------------------------------
    svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"

Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/XhrIframeProxy.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/__package__.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/__package__.js?view=diff&rev=473277&r1=473276&r2=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/__package__.js (original)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/__package__.js Fri Nov 10 01:15:01 2006
@@ -9,7 +9,7 @@
 */
 
 dojo.kwCompoundRequire({
-	common: ["dojo.io"],
+	common: ["dojo.io.common"],
 	rhino: ["dojo.io.RhinoIO"],
 	browser: ["dojo.io.BrowserIO", "dojo.io.cookie"],
 	dashboard: ["dojo.io.BrowserIO", "dojo.io.cookie"]

Added: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js?view=auto&rev=473277
==============================================================================
--- myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js (added)
+++ myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js Fri Nov 10 01:15:01 2006
@@ -0,0 +1,929 @@
+/*
+	Copyright (c) 2004-2006, The Dojo Foundation
+	All Rights Reserved.
+
+	Licensed under the Academic Free License version 2.1 or above OR the
+	modified BSD license. For more information on Dojo licensing, see:
+
+		http://dojotoolkit.org/community/licensing.shtml
+*/
+
+dojo.require("dojo.io.common"); // io/common.js provides setIFrameSrc and the IO module
+dojo.provide("dojo.io.cometd");
+dojo.require("dojo.AdapterRegistry");
+dojo.require("dojo.json");
+dojo.require("dojo.io.BrowserIO"); // we need XHR for the handshake, etc.
+// FIXME: determine if we can use XMLHTTP to make x-domain posts despite not
+//        being able to hear back about the result
+dojo.require("dojo.io.IframeIO");
+dojo.require("dojo.io.ScriptSrcIO"); // for x-domain long polling
+dojo.require("dojo.io.cookie"); // for peering
+dojo.require("dojo.event.*");
+dojo.require("dojo.lang.common");
+dojo.require("dojo.lang.func");
+
+/*
+ * this file defines Comet protocol client. Actual message transport is
+ * deferred to one of several connection type implementations. The default is a
+ * forever-frame implementation. A single global object named "cometd" is
+ * used to mediate for these connection types in order to provide a stable
+ * interface.
+ */
+
+// TODO: the auth handling in this file is a *mess*. It should probably live in
+// the cometd object with the ability to mix in or call down to an auth-handler
+// object, the prototypical variant of which is a no-op
+
+cometd = new function(){
+
+	this.initialized = false;
+	this.connected = false;
+
+	this.connectionTypes = new dojo.AdapterRegistry(true);
+
+	this.version = 0.1;
+	this.minimumVersion = 0.1;
+	this.clientId = null;
+
+	this._isXD = false;
+	this.handshakeReturn = null;
+	this.currentTransport = null;
+	this.url = null;
+	this.lastMessage = null;
+	this.globalTopicChannels = {};
+	this.backlog = [];
+
+	this.tunnelInit = function(childLocation, childDomain){
+		// placeholder
+	}
+
+	this.tunnelCollapse = function(){
+		dojo.debug("tunnel collapsed!");
+		// placeholder
+	}
+
+	this.init = function(props, root, bargs){
+		// FIXME: if the root isn't from the same host, we should automatically
+		// try to select an XD-capable transport
+		props = props||{};
+		// go ask the short bus server what we can support
+		props.version = this.version;
+		props.minimumVersion = this.minimumVersion;
+		props.channel = "/meta/handshake";
+		// FIXME: do we just assume that the props knows
+		// everything we care about WRT to auth? Should we be trying to
+		// call back into it for subsequent auth actions? Should we fire
+		// local auth functions to ask for/get auth data?
+
+		// FIXME: what about ScriptSrcIO for x-domain comet?
+		this.url = root||djConfig["cometdRoot"];
+		if(!this.url){
+			dojo.debug("no cometd root specified in djConfig and no root passed");
+			return;
+		}
+		
+		// FIXME: we need to select a way to handle JSONP-style stuff
+		// generically here. We already know if the server is gonna be on
+		// another domain (or can know it), so we should select appropriate
+		// negotiation methods here as well as in final transport type
+		// selection.
+		var bindArgs = {
+			url: this.url,
+			method: "POST",
+			mimetype: "text/json",
+			load: dojo.lang.hitch(this, "finishInit"),
+			content: { "message": dojo.json.serialize([props]) }
+		};
+
+		// borrowed from dojo.uri.Uri in lieu of fixed host and port properties
+        var regexp = "^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?$";
+		var r = (""+window.location).match(new RegExp(regexp));
+		if(r[4]){
+			var tmp = r[4].split(":");
+			var thisHost = tmp[0];
+			var thisPort = tmp[1]||"80"; // FIXME: match 443
+
+			r = this.url.match(new RegExp(regexp));
+			if(r[4]){
+				tmp = r[4].split(":");
+				var urlHost = tmp[0];
+				var urlPort = tmp[1]||"80";
+				if(	(urlHost != thisHost)||
+					(urlPort != thisPort) ){
+					dojo.debug(thisHost, urlHost);
+					dojo.debug(thisPort, urlPort);
+
+					this._isXD = true;
+					bindArgs.transport = "ScriptSrcTransport";
+					bindArgs.jsonParamName = "jsonp";
+					bindArgs.method = "GET";
+				}
+			}
+		}
+		if(bargs){
+			dojo.lang.mixin(bindArgs, bargs);
+		}
+		return dojo.io.bind(bindArgs);
+	}
+
+	this.finishInit = function(type, data, evt, request){
+		data = data[0];
+		this.handshakeReturn = data;
+		// pick a transport
+		if(data["authSuccessful"] == false){
+			dojo.debug("cometd authentication failed");
+			return;
+		}
+		if(data.version < this.minimumVersion){
+			dojo.debug("cometd protocol version mismatch. We wanted", this.minimumVersion, "but got", data.version);
+			return;
+		}
+		this.currentTransport = this.connectionTypes.match(
+			data.supportedConnectionTypes,
+			data.version,
+			this._isXD
+		);
+		this.currentTransport.version = data.version;
+		this.clientId = data.clientId;
+		this.tunnelInit = dojo.lang.hitch(this.currentTransport, "tunnelInit");
+		this.tunnelCollapse = dojo.lang.hitch(this.currentTransport, "tunnelCollapse");
+		this.initialized = true;
+		this.currentTransport.startup(data);
+		while(this.backlog.length != 0){
+			var cur = this.backlog.shift();
+			var fn = cur.shift();
+			this[fn].apply(this, cur);
+		}
+	}
+
+	this._getRandStr = function(){
+		return Math.random().toString().substring(2, 10);
+	}
+
+	// public API functions called by cometd or by the transport classes
+	this.deliver = function(messages){
+		dojo.lang.forEach(messages, this._deliver, this);
+	}
+
+	this._deliver = function(message){
+		// dipatch events along the specified path
+		if(!message["channel"]){
+			dojo.debug("cometd error: no channel for message!");
+			return;
+		}
+		if(!this.currentTransport){
+			this.backlog.push(["deliver", message]);
+			return;
+		}
+		this.lastMessage = message;
+		// check to see if we got a /meta channel message that we care about
+		if(	(message.channel.length > 5)&&
+			(message.channel.substr(0, 5) == "/meta")){
+			// check for various meta topic actions that we need to respond to
+			switch(message.channel){
+				case "/meta/subscribe":
+					if(!message.successful){
+						dojo.debug("cometd subscription error for channel", message.channel, ":", message.error);
+						return;
+					}
+					this.subscribed(message.subscription, message);
+					break;
+				case "/meta/unsubscribe":
+					if(!message.successful){
+						dojo.debug("cometd unsubscription error for channel", message.channel, ":", message.error);
+						return;
+					}
+					this.unsubscribed(message.subscription, message);
+					break;
+			}
+		}
+		// send the message down for processing by the transport
+		this.currentTransport.deliver(message);
+
+		// dispatch the message to any locally subscribed listeners
+		var tname = (this.globalTopicChannels[message.channel]) ? message.channel : "/cometd"+message.channel;
+		dojo.event.topic.publish(tname, message);
+	}
+
+	this.disconnect = function(){
+		if(!this.currentTransport){
+			dojo.debug("no current transport to disconnect from");
+			return;
+		}
+		this.currentTransport.disconnect();
+	}
+
+	// public API functions called by end users
+	this.publish = function(/*string*/channel, /*object*/data, /*object*/properties){
+		// summary: 
+		//		publishes the passed message to the cometd server for delivery
+		//		on the specified topic
+		// channel:
+		//		the destination channel for the message
+		// data:
+		//		a JSON object containing the message "payload"
+		// properties:
+		//		Optional. Other meta-data to be mixed into the top-level of the
+		//		message
+		if(!this.currentTransport){
+			this.backlog.push(["publish", channel, data, properties]);
+			return;
+		}
+		var message = {
+			data: data,
+			channel: channel
+		};
+		if(properties){
+			dojo.lang.mixin(message, properties);
+		}
+		return this.currentTransport.sendMessage(message);
+	}
+
+	this.subscribe = function(	/*string*/				channel, 
+								/*boolean, optional*/	useLocalTopics, 
+								/*object, optional*/	objOrFunc, 
+								/*string, optional*/	funcName){ // return: boolean
+		// summary:
+		//		inform the server of this client's interest in channel
+		// channel:
+		//		name of the cometd channel to subscribe to
+		// useLocalTopics:
+		//		Determines if up a local event topic subscription to the passed
+		//		function using the channel name that was passed is constructed,
+		//		or if the topic name will be prefixed with some other
+		//		identifier for local message distribution. Setting this to
+		//		"true" is a good way to hook up server-sent message delivery to
+		//		pre-existing local topics.
+		// objOrFunc:
+		//		an object scope for funcName or the name or reference to a
+		//		function to be called when messages are delivered to the
+		//		channel
+		// funcName:
+		//		the second half of the objOrFunc/funcName pair for identifying
+		//		a callback function to notifiy upon channel message delivery
+		if(!this.currentTransport){
+			this.backlog.push(["subscribe", channel, useLocalTopics, objOrFunc, funcName]);
+			return;
+		}
+		if(objOrFunc){
+			var tname = (useLocalTopics) ? channel : "/cometd"+channel;
+			if(useLocalTopics){
+				this.globalTopicChannels[channel] = true;
+			}
+			dojo.event.topic.subscribe(tname, objOrFunc, funcName);
+		}
+		// FIXME: would we handle queuing of the subscription if not connected?
+		// Or should the transport object?
+		return this.currentTransport.sendMessage({
+			channel: "/meta/subscribe",
+			subscription: channel
+		});
+	}
+
+	this.subscribed = function(	/*string*/				channel, 
+								/*obj*/					message){
+		dojo.debug(channel);
+		dojo.debugShallow(message);
+	}
+
+	this.unsubscribe = function(/*string*/				channel, 
+								/*boolean, optional*/	useLocalTopics, 
+								/*object, optional*/	objOrFunc, 
+								/*string, optional*/	funcName){ // return: boolean
+		// summary:
+		//		inform the server of this client's disinterest in channel
+		// channel:
+		//		name of the cometd channel to subscribe to
+		// useLocalTopics:
+		//		Determines if up a local event topic subscription to the passed
+		//		function using the channel name that was passed is destroyed,
+		//		or if the topic name will be prefixed with some other
+		//		identifier for stopping message distribution.
+		// objOrFunc:
+		//		an object scope for funcName or the name or reference to a
+		//		function to be called when messages are delivered to the
+		//		channel
+		// funcName:
+		//		the second half of the objOrFunc/funcName pair for identifying
+		if(!this.currentTransport){
+			this.backlog.push(["unsubscribe", channel, useLocalTopics, objOrFunc, funcName]);
+			return;
+		}
+		//		a callback function to notifiy upon channel message delivery
+		if(objOrFunc){
+			// FIXME: should actual local topic unsubscription be delayed for
+			// successful unsubcribe notices from the other end? (guessing "no")
+			// FIXME: if useLocalTopics is false, should we go ahead and
+			// destroy the local topic?
+			var tname = (useLocalTopics) ? channel : "/cometd"+channel;
+			dojo.event.topic.unsubscribe(tname, objOrFunc, funcName);
+		}
+		return this.currentTransport.sendMessage({
+			channel: "/meta/unsubscribe",
+			subscription: channel
+		});
+	}
+
+	this.unsubscribed = function(/*string*/				channel, 
+								/*obj*/					message){
+		dojo.debug(channel);
+		dojo.debugShallow(message);
+	}
+
+	// FIXME: add an "addPublisher" function
+
+}
+
+/*
+transport objects MUST expose the following methods:
+	- check
+	- startup
+	- sendMessage
+	- deliver
+	- disconnect
+optional, standard but transport dependent methods are:
+	- tunnelCollapse
+	- tunnelInit
+
+Transports SHOULD be namespaced under the cometd object and transports MUST
+register themselves with cometd.connectionTypes
+
+here's a stub transport defintion:
+
+cometd.blahTransport = new function(){
+	this.connected = false;
+	this.connectionId = null;
+	this.authToken = null;
+	this.lastTimestamp = null;
+	this.lastId = null;
+
+	this.check = function(types, version, xdomain){
+		// summary:
+		//		determines whether or not this transport is suitable given a
+		//		list of transport types that the server supports
+		return dojo.lang.inArray(types, "blah");
+	}
+
+	this.startup = function(){
+		if(this.connected){ return; }
+		// FIXME: fill in startup routine here
+		this.connected = true;
+	}
+
+	this.sendMessage = function(message){
+		// FIXME: fill in message sending logic
+	}
+
+	this.deliver = function(message){
+		if(message["timestamp"]){
+			this.lastTimestamp = message.timestamp;
+		}
+		if(message["id"]){
+			this.lastId = message.id;
+		}
+		if(	(message.channel.length > 5)&&
+			(message.channel.substr(0, 5) == "/meta")){
+			// check for various meta topic actions that we need to respond to
+			// switch(message.channel){
+			// 	case "/meta/connect":
+			//		// FIXME: fill in logic here
+			//		break;
+			//	// case ...: ...
+			//	}
+		}
+	}
+
+	this.disconnect = function(){
+		if(!this.connected){ return; }
+		// FIXME: fill in shutdown routine here
+		this.connected = false;
+	}
+}
+cometd.connectionTypes.register("blah", cometd.blahTransport.check, cometd.blahTransport);
+*/
+
+cometd.iframeTransport = new function(){
+	this.connected = false;
+	this.connectionId = null;
+
+	this.rcvNode = null;
+	this.rcvNodeName = "";
+	this.phonyForm = null;
+	this.authToken = null;
+	this.lastTimestamp = null;
+	this.lastId = null;
+	this.backlog = [];
+
+	this.check = function(types, version, xdomain){
+		return ((!xdomain)&&
+				(!dojo.render.html.safari)&&
+				(dojo.lang.inArray(types, "iframe")));
+	}
+
+	this.tunnelInit = function(){
+		// we've gotten our initialization document back in the iframe, so
+		// now open up a connection and start passing data!
+		this.postToIframe({
+			message: dojo.json.serialize([
+				{
+					channel:	"/meta/connect",
+					clientId:	cometd.clientId,
+					connectionType: "iframe"
+					// FIXME: auth not passed here!
+					// "authToken": this.authToken
+				}
+			])
+		});
+	}
+
+	this.tunnelCollapse = function(){
+		if(this.connected){
+			// try to restart the tunnel
+			this.connected = false;
+
+			this.postToIframe({
+				message: dojo.json.serialize([
+					{
+						channel:	"/meta/reconnect",
+						clientId:	cometd.clientId,
+						connectionId:	this.connectionId,
+						timestamp:	this.lastTimestamp,
+						id:			this.lastId
+						// FIXME: no authToken provision!
+					}
+				])
+			});
+		}
+	}
+
+	this.deliver = function(message){
+		// handle delivery details that this transport particularly cares
+		// about. Most functions of should be handled by the main cometd object
+		// with only transport-specific details and state being tracked here.
+		if(message["timestamp"]){
+			this.lastTimestamp = message.timestamp;
+		}
+		if(message["id"]){
+			this.lastId = message.id;
+		}
+		// check to see if we got a /meta channel message that we care about
+		if(	(message.channel.length > 5)&&
+			(message.channel.substr(0, 5) == "/meta")){
+			// check for various meta topic actions that we need to respond to
+			switch(message.channel){
+				case "/meta/connect":
+					if(!message.successful){
+						dojo.debug("cometd connection error:", message.error);
+						return;
+					}
+					this.connectionId = message.connectionId;
+					this.connected = true;
+					this.processBacklog();
+					break;
+				case "/meta/reconnect":
+					if(!message.successful){
+						dojo.debug("cometd reconnection error:", message.error);
+						return;
+					}
+					this.connected = true;
+					break;
+				case "/meta/subscribe":
+					if(!message.successful){
+						dojo.debug("cometd subscription error for channel", message.channel, ":", message.error);
+						return;
+					}
+					// this.subscribed(message.channel);
+					dojo.debug(message.channel);
+					break;
+			}
+		}
+	}
+
+	this.widenDomain = function(domainStr){
+		// allow us to make reqests to the TLD
+		var cd = domainStr||document.domain;
+		if(cd.indexOf(".")==-1){ return; } // probably file:/// or localhost
+		var dps = cd.split(".");
+		if(dps.length<=2){ return; } // probably file:/// or an RFC 1918 address
+		dps = dps.slice(dps.length-2);
+		document.domain = dps.join(".");
+		return document.domain;
+	}
+
+	this.postToIframe = function(content, url){
+		if(!this.phonyForm){
+			if(dojo.render.html.ie){
+				this.phonyForm = document.createElement("<form enctype='application/x-www-form-urlencoded' method='POST' style='display: none;'>");
+				dojo.body().appendChild(this.phonyForm);
+			}else{
+				this.phonyForm = document.createElement("form");
+				this.phonyForm.style.display = "none"; // FIXME: will this still work?
+				dojo.body().appendChild(this.phonyForm);
+				this.phonyForm.enctype = "application/x-www-form-urlencoded";
+				this.phonyForm.method = "POST";
+			}
+		}
+
+		this.phonyForm.action = url||cometd.url;
+		this.phonyForm.target = this.rcvNodeName;
+		this.phonyForm.setAttribute("target", this.rcvNodeName);
+
+		while(this.phonyForm.firstChild){
+			this.phonyForm.removeChild(this.phonyForm.firstChild);
+		}
+
+		for(var x in content){
+			var tn;
+			if(dojo.render.html.ie){
+				tn = document.createElement("<input type='hidden' name='"+x+"' value='"+content[x]+"'>");
+				this.phonyForm.appendChild(tn);
+			}else{
+				tn = document.createElement("input");
+				this.phonyForm.appendChild(tn);
+				tn.type = "hidden";
+				tn.name = x;
+				tn.value = content[x];
+			}
+		}
+		this.phonyForm.submit();
+	}
+
+	this.processBacklog = function(){
+		while(this.backlog.length > 0){
+			this.sendMessage(this.backlog.shift(), true);
+		}
+	}
+
+	this.sendMessage = function(message, bypassBacklog){
+		// FIXME: what about auth fields?
+		if((bypassBacklog)||(this.connected)){
+			message.connectionId = this.connectionId;
+			message.clientId = cometd.clientId;
+			var bindArgs = {
+				url: cometd.url||djConfig["cometdRoot"],
+				method: "POST",
+				mimetype: "text/json",
+				// FIXME: we should be able to do better than this given that we're sending an array!
+				content: { message: dojo.json.serialize([ message ]) }
+			};
+			return dojo.io.bind(bindArgs);
+		}else{
+			this.backlog.push(message);
+		}
+	}
+
+	this.startup = function(handshakeData){
+		dojo.debug("startup!");
+		dojo.debug(dojo.json.serialize(handshakeData));
+
+		if(this.connected){ return; }
+
+		// this.widenDomain();
+
+		// NOTE: we require the server to cooperate by hosting
+		// cometdInit.html at the designated endpoint
+		this.rcvNodeName = "cometdRcv_"+cometd._getRandStr();
+		// the "forever frame" approach
+
+		var initUrl = cometd.url+"/?tunnelInit=iframe"; // &domain="+document.domain;
+		if(false && dojo.render.html.ie){ // FIXME: DISALBED FOR NOW
+			// use the "htmlfile hack" to prevent the background click junk
+			this.rcvNode = new ActiveXObject("htmlfile");
+			this.rcvNode.open();
+			this.rcvNode.write("<html>");
+			this.rcvNode.write("<script>document.domain = '"+document.domain+"'");
+			this.rcvNode.write("</html>");
+			this.rcvNode.close();
+
+			var ifrDiv = this.rcvNode.createElement("div");
+			this.rcvNode.appendChild(ifrDiv);
+			this.rcvNode.parentWindow.dojo = dojo;
+			ifrDiv.innerHTML = "<iframe src='"+initUrl+"'></iframe>"
+		}else{
+			this.rcvNode = dojo.io.createIFrame(this.rcvNodeName, "", initUrl);
+			// dojo.io.setIFrameSrc(this.rcvNode, initUrl);
+			// we're still waiting on the iframe to call back up to use and
+			// advertise that it's been initialized via tunnelInit
+		}
+	}
+}
+
+cometd.mimeReplaceTransport = new function(){
+	this.connected = false;
+	this.connectionId = null;
+	this.xhr = null;
+
+	this.authToken = null;
+	this.lastTimestamp = null;
+	this.lastId = null;
+	this.backlog = [];
+
+	this.check = function(types, version, xdomain){
+		return ((!xdomain)&&
+				(dojo.render.html.mozilla)&& // seems only Moz really supports this right now = (
+				(dojo.lang.inArray(types, "mime-message-block")));
+	}
+
+	this.tunnelInit = function(){
+		if(this.connected){ return; }
+		// FIXME: open up the connection here
+		this.openTunnelWith({
+			message: dojo.json.serialize([
+				{
+					channel:	"/meta/connect",
+					clientId:	cometd.clientId,
+					connectionType: "mime-message-block"
+					// FIXME: auth not passed here!
+					// "authToken": this.authToken
+				}
+			])
+		});
+		this.connected = true;
+	}
+
+	this.tunnelCollapse = function(){
+		if(this.connected){
+			// try to restart the tunnel
+			this.connected = false;
+			this.openTunnelWith({
+				message: dojo.json.serialize([
+					{
+						channel:	"/meta/reconnect",
+						clientId:	cometd.clientId,
+						connectionId:	this.connectionId,
+						timestamp:	this.lastTimestamp,
+						id:			this.lastId
+						// FIXME: no authToken provision!
+					}
+				])
+			});
+		}
+	}
+
+	this.deliver = cometd.iframeTransport.deliver;
+	// the logic appears to be the same
+
+	this.handleOnLoad = function(resp){
+		cometd.deliver(dojo.json.evalJson(this.xhr.responseText));
+	}
+
+	this.openTunnelWith = function(content, url){
+		// set up the XHR object and register the multipart callbacks
+		this.xhr = dojo.hostenv.getXmlhttpObject();
+		this.xhr.multipart = true; // FIXME: do Opera and Safari support this flag?
+		if(dojo.render.html.mozilla){
+			this.xhr.addEventListener("load", dojo.lang.hitch(this, "handleOnLoad"), false);
+		}else if(dojo.render.html.safari){
+			// Blah. WebKit doesn't actually populate responseText and/or responseXML. Useless.
+			dojo.debug("Webkit is broken with multipart responses over XHR = (");
+			this.xhr.onreadystatechange = dojo.lang.hitch(this, "handleOnLoad");
+		}else{
+			this.xhr.onload = dojo.lang.hitch(this, "handleOnLoad");
+		}
+		this.xhr.open("POST", (url||cometd.url), true); // async post
+		this.xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
+		dojo.debug(dojo.json.serialize(content));
+		this.xhr.send(dojo.io.argsFromMap(content, "utf8"));
+	}
+
+	this.processBacklog = function(){
+		while(this.backlog.length > 0){
+			this.sendMessage(this.backlog.shift(), true);
+		}
+	}
+
+	this.sendMessage = function(message, bypassBacklog){
+		// FIXME: what about auth fields?
+		if((bypassBacklog)||(this.connected)){
+			message.connectionId = this.connectionId;
+			message.clientId = cometd.clientId;
+			var bindArgs = {
+				url: cometd.url||djConfig["cometdRoot"],
+				method: "POST",
+				mimetype: "text/json",
+				content: { message: dojo.json.serialize([ message ]) }
+			};
+			return dojo.io.bind(bindArgs);
+		}else{
+			this.backlog.push(message);
+		}
+	}
+
+	this.startup = function(handshakeData){
+		dojo.debugShallow(handshakeData);
+		if(this.connected){ return; }
+		this.tunnelInit();
+	}
+}
+
+cometd.longPollTransport = new function(){
+	this.connected = false;
+	this.connectionId = null;
+
+	this.authToken = null;
+	this.lastTimestamp = null;
+	this.lastId = null;
+	this.backlog = [];
+
+	this.check = function(types, version, xdomain){
+		return ((!xdomain)&&(dojo.lang.inArray(types, "long-polling")));
+	}
+
+	this.tunnelInit = function(){
+		if(this.connected){ return; }
+		// FIXME: open up the connection here
+		this.openTunnelWith({
+			message: dojo.json.serialize([
+				{
+					channel:	"/meta/connect",
+					clientId:	cometd.clientId,
+					connectionType: "long-polling"
+					// FIXME: auth not passed here!
+					// "authToken": this.authToken
+				}
+			])
+		});
+		this.connected = true;
+	}
+
+	this.tunnelCollapse = function(){
+		if(!this.connected){
+			// try to restart the tunnel
+			this.connected = false;
+			dojo.debug("clientId:", cometd.clientId);
+			this.openTunnelWith({
+				message: dojo.json.serialize([
+					{
+						channel:	"/meta/reconnect",
+						connectionType: "long-polling",
+						clientId:	cometd.clientId,
+						connectionId:	this.connectionId,
+						timestamp:	this.lastTimestamp,
+						id:			this.lastId
+						// FIXME: no authToken provision!
+					}
+				])
+			});
+		}
+	}
+
+	this.deliver = cometd.iframeTransport.deliver;
+	// the logic appears to be the same
+
+	this.openTunnelWith = function(content, url){
+		dojo.io.bind({
+			url: (url||cometd.url),
+			method: "post",
+			content: content,
+			mimetype: "text/json",
+			load: dojo.lang.hitch(this, function(type, data, evt, args){
+				// dojo.debug(evt.responseText);
+				cometd.deliver(data);
+				this.connected = false;
+				this.tunnelCollapse();
+			}),
+			error: function(){ dojo.debug("tunnel opening failed"); }
+		});
+		this.connected = true;
+	}
+
+	this.processBacklog = function(){
+		while(this.backlog.length > 0){
+			this.sendMessage(this.backlog.shift(), true);
+		}
+	}
+
+	this.sendMessage = function(message, bypassBacklog){
+		// FIXME: what about auth fields?
+		if((bypassBacklog)||(this.connected)){
+			message.connectionId = this.connectionId;
+			message.clientId = cometd.clientId;
+			var bindArgs = {
+				url: cometd.url||djConfig["cometdRoot"],
+				method: "post",
+				mimetype: "text/json",
+				content: { message: dojo.json.serialize([ message ]) }
+			};
+			return dojo.io.bind(bindArgs);
+		}else{
+			this.backlog.push(message);
+		}
+	}
+
+	this.startup = function(handshakeData){
+		if(this.connected){ return; }
+		this.tunnelInit();
+	}
+}
+
+cometd.callbackPollTransport = new function(){
+	this.connected = false;
+	this.connectionId = null;
+
+	this.authToken = null;
+	this.lastTimestamp = null;
+	this.lastId = null;
+	this.backlog = [];
+
+	this.check = function(types, version, xdomain){
+		// we handle x-domain!
+		return dojo.lang.inArray(types, "callback-polling");
+	}
+
+	this.tunnelInit = function(){
+		if(this.connected){ return; }
+		// FIXME: open up the connection here
+		this.openTunnelWith({
+			message: dojo.json.serialize([
+				{
+					channel:	"/meta/connect",
+					clientId:	cometd.clientId,
+					connectionType: "callback-polling"
+					// FIXME: auth not passed here!
+					// "authToken": this.authToken
+				}
+			])
+		});
+		this.connected = true;
+	}
+
+	this.tunnelCollapse = function(){
+		if(!this.connected){
+			// try to restart the tunnel
+			this.connected = false;
+			this.openTunnelWith({
+				message: dojo.json.serialize([
+					{
+						channel:	"/meta/reconnect",
+						connectionType: "long-polling",
+						clientId:	cometd.clientId,
+						connectionId:	this.connectionId,
+						timestamp:	this.lastTimestamp,
+						id:			this.lastId
+						// FIXME: no authToken provision!
+					}
+				])
+			});
+		}
+	}
+
+	this.deliver = cometd.iframeTransport.deliver;
+	// the logic appears to be the same
+
+	this.openTunnelWith = function(content, url){
+		// create a <script> element to generate the request
+		var req = dojo.io.bind({
+			url: (url||cometd.url),
+			content: content,
+			mimetype: "text/json",
+			transport: "ScriptSrcTransport",
+			jsonParamName: "jsonp",
+			load: dojo.lang.hitch(this, function(type, data, evt, args){
+				dojo.debug(dojo.json.serialize(data));
+				cometd.deliver(data);
+				this.connected = false;
+				this.tunnelCollapse();
+			}),
+			error: function(){ dojo.debug("tunnel opening failed"); }
+		});
+		this.connected = true;
+	}
+
+	this.processBacklog = function(){
+		while(this.backlog.length > 0){
+			this.sendMessage(this.backlog.shift(), true);
+		}
+	}
+
+	this.sendMessage = function(message, bypassBacklog){
+		// FIXME: what about auth fields?
+		if((bypassBacklog)||(this.connected)){
+			message.connectionId = this.connectionId;
+			message.clientId = cometd.clientId;
+			var bindArgs = {
+				url: cometd.url||djConfig["cometdRoot"],
+				mimetype: "text/json",
+				transport: "ScriptSrcTransport",
+				jsonParamName: "jsonp",
+				content: { message: dojo.json.serialize([ message ]) }
+			};
+			return dojo.io.bind(bindArgs);
+		}else{
+			this.backlog.push(message);
+		}
+	}
+
+	this.startup = function(handshakeData){
+		if(this.connected){ return; }
+		this.tunnelInit();
+	}
+}
+
+cometd.connectionTypes.register("mime-message-block", cometd.mimeReplaceTransport.check, cometd.mimeReplaceTransport);
+cometd.connectionTypes.register("long-polling", cometd.longPollTransport.check, cometd.longPollTransport);
+cometd.connectionTypes.register("callback-polling", cometd.callbackPollTransport.check, cometd.callbackPollTransport);
+cometd.connectionTypes.register("iframe", cometd.iframeTransport.check, cometd.iframeTransport);
+
+// FIXME: need to implement fallback-polling, IE XML block
+
+dojo.io.cometd = cometd;

Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js
------------------------------------------------------------------------------
    svn:keywords = "Id Author LastChangedDate LastChangedBy LastChangedRevision"

Propchange: myfaces/tomahawk/trunk/core/src/main/resources/org/apache/myfaces/custom/dojo/resource/src/io/cometd.js
------------------------------------------------------------------------------
    svn:mime-type = text/plain