You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/07/12 10:36:58 UTC
svn commit: r963211 - in /myfaces/core/trunk/api/src: assembler/
main/javascript/META-INF/resources/myfaces/_impl/core/
main/javascript/META-INF/resources/myfaces/_impl/xhrCore/
Author: werpu
Date: Mon Jul 12 08:36:57 2010
New Revision: 963211
URL: http://svn.apache.org/viewvc?rev=963211&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2803
https://issues.apache.org/jira/browse/MYFACES-2808
Added:
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_BaseRequest.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js
Modified:
myfaces/core/trunk/api/src/assembler/jsfscripts-compiler.xml
myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
Modified: myfaces/core/trunk/api/src/assembler/jsfscripts-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/assembler/jsfscripts-compiler.xml?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/assembler/jsfscripts-compiler.xml (original)
+++ myfaces/core/trunk/api/src/assembler/jsfscripts-compiler.xml Mon Jul 12 08:36:57 2010
@@ -48,7 +48,12 @@
<include>**/_impl/_util/_HtmlStripper.js</include>
<include>**/_impl/xhrCore/_AjaxUtils.js</include>
<include>**/_impl/xhrCore/_AjaxRequestQueue.js</include>
+ <include>**/_impl/xhrCore/_BaseRequest.js</include>
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
+ <!-- not yet used so we comment it out this is pure 2.1 functionality -->
+ <!--
+ <include>**/_impl/xhrCore/_IFrameRequest.js</include>
+ -->
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
<include>**/_impl/core/Impl.js</include>
Modified: myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml (original)
+++ myfaces/core/trunk/api/src/assembler/jsfscripts-uncompressed-full-compiler.xml Mon Jul 12 08:36:57 2010
@@ -49,7 +49,10 @@
<include>**/_impl/_util/_HtmlStripper.js</include>
<include>**/_impl/xhrCore/_AjaxUtils.js</include>
<include>**/_impl/xhrCore/_AjaxRequestQueue.js</include>
+ <include>**/_impl/xhrCore/_BaseRequest.js</include>
<include>**/_impl/xhrCore/_AjaxRequest.js</include>
+ <!-- not yet used in 2.0 but for development purposes it makes sense to include it here -->
+ <include>**/_impl/xhrCore/_IFrameRequest.js</include>
<include>**/_impl/xhrCore/_AjaxResponse.js</include>
<include>**/_impl/xhrCore/_Transports.js</include>
<include>**/_impl/core/Impl.js</include>
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/Impl.js Mon Jul 12 08:36:57 2010
@@ -250,8 +250,23 @@ myfaces._impl.core._Runtime.singletonExt
delete passThrgh.myfaces;
}
- this._transport.xhrQueuedPost(elem, form, context, passThrgh);
-
+ /**
+ * multiple transports upcoming jsf 2.1 feature currently allowed
+ * default (no value) xhrQueuedPost
+ *
+ * xhrQueuedPost
+ * xhrPost
+ * xhrGet
+ * xhrQueuedGet
+ * iframePost
+ * iframeQueuedPost
+ *
+ */
+ var transportType = myfaces._impl.core._Runtime.getLocalOrGlobalConfig(context, "transportType", "xhrQueuedPost");
+ if (!this._transport[transportType]) {
+ throw new Error("Transport type " + transportType + " does not exist");
+ }
+ this._transport[transportType](elem, form, context, passThrgh);
},
addOnError : function(/*function*/errorListener) {
@@ -351,9 +366,9 @@ myfaces._impl.core._Runtime.singletonExt
}
};
- eventData.responseCode = getValue (request, "status");
- eventData.responseText = getValue (request, "responseText");
- eventData.responseXML = getValue (request, "responseXML");
+ eventData.responseCode = getValue(request, "status");
+ eventData.responseText = getValue(request, "responseText");
+ eventData.responseXML = getValue(request, "responseXML");
} catch (e) {
var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/_Runtime.js Mon Jul 12 08:36:57 2010
@@ -188,6 +188,12 @@ if (!myfaces._impl.core._Runtime) {
*
* reserves a namespace and if not already registered directly applies the function the namespace
*
+ * note for now the reserved namespaces reside as global maps justl like jsf.js but
+ * we also use a speedup index which is kept internally to reduce the number of evals or loops to walk through those
+ * namespaces (eval is a heavy operation and loops even only for namespace resolution introduce (O)2 runtime
+ * complexity while a simple map lookup is (O)log n with additional speedup from the engine.
+ *
+ *
* @param {|String|} nms
* @returns true if it was not provided
* false otherwise for further action
@@ -676,9 +682,9 @@ if (!myfaces._impl.core._Runtime) {
* @param func the function which should be added to the load
* chain (note we cannot rely on return values here, hence jsf.util.chain will fail)
*/
- this.addOnLoad = function(func) {
- var oldonload = window.onload;
- window.onload = (!this.assertType(window.onload, "function")) ? func : function() {
+ this.addOnLoad = function(target, func) {
+ var oldonload = target.onload;
+ target.onload = (!this.assertType(window.onload, "function")) ? func : function() {
oldonload();
func();
};
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf-uncompressed.js Mon Jul 12 08:36:57 2010
@@ -23,7 +23,9 @@ if (!window.jsf) {
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.util:_HtmlStripper.js']}", null, null, "UTF-8");
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxUtils.js']}", null, null, "UTF-8");
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequestQueue.js']}", null, null, "UTF-8");
+ myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_BaseRequest.js']}", null, null, "UTF-8");
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxRequest.js']}", null, null, "UTF-8");
+ myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_IFrameRequest.js']}", null, null, "UTF-8");
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_AjaxResponse.js']}", null, null, "UTF-8");
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.xhrCore:_Transports.js']}", null, null, "UTF-8");
myfaces._impl.core._Runtime.loadScript("#{resource['org.apache.myfaces.core.impl.core:Impl.js']}", null, null, "UTF-8");
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Mon Jul 12 08:36:57 2010
@@ -23,52 +23,18 @@
* Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
*/
/** @namespace myfaces._impl.xhrCore._AjaxRequest */
-myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequest", Object, {
+myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._AjaxRequest", myfaces._impl.xhrCore._BaseRequest, {
- /*all instance vars can be set from the outside
- * via a parameter map*/
- _contentType: "application/x-www-form-urlencoded",
- _source: null,
- _xhr: null,
- _encoding:null ,
-
- _context:null,
- _ajaxUtil: null,
- _sourceForm: null,
- _passThrough: null,
- _requestParameters: null,
- _exception: null,
- _timeout: null,
- _delay:null,
- _queueSize:-1,
-
- _partialIdsArray : null,
- _ajaxType: "POST",
-
-
- //callbacks for onDone... done issues
- //onSuccess everything has passed through
- //onError server side error
-
- //onException exception thrown by the client
- //onWarning warning issued by the client
- _onDone : null,
- _onSuccess: null,
- _onError: null,
- _onException: null,
- _onWarning: null,
- _onTimeout:null,
- /*response object which is exposed to the queue*/
- _response: null,
-
- _timeoutId: null,
/*
- * constants used internally
+ note there is a load of common properties
+ inherited by the base class which define the corner
+ parameters and the general internal behavior
+ like _onError etc...
*/
- _CONTENT_TYPE:"Content-Type",
- _HEAD_FACES_REQ:"Faces-Request",
- _VAL_AJAX: "partial/ajax",
+
+
+
/**
* Constructor
@@ -80,9 +46,9 @@ myfaces._impl.core._Runtime.extendClass(
try {
/*namespace remapping for readability*/
- var _Lang = myfaces._impl._util._Lang;
//we fetch in the standard arguments
- _Lang.applyArgs(this, arguments);
+ //and apply them to our protected attributes
+ this._Lang.applyArgs(this, arguments);
//if our response handler is not set
if (!this._response) {
@@ -120,7 +86,6 @@ myfaces._impl.core._Runtime.extendClass(
* starts the asynchronous xhr request
*/
_startXHR: function() {
- var _Lang = myfaces._impl._util._Lang;
this._xhr = myfaces._impl.core._Runtime.getXHRObject();
this._xhr.open(this._ajaxType, this._sourceForm.action, true);
@@ -133,7 +98,7 @@ myfaces._impl.core._Runtime.extendClass(
this._xhr.setRequestHeader(this._CONTENT_TYPE, this._contentType);
this._xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX);
- this._xhr.onreadystatechange = _Lang.hitch(this, this.callback);
+ this._xhr.onreadystatechange = this._Lang.hitch(this, this.callback);
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
_Impl.sendEvent(this._xhr, this._context, myfaces._impl.core.Impl.BEGIN);
this._xhr.send(this._requestParameters);
@@ -144,7 +109,6 @@ myfaces._impl.core._Runtime.extendClass(
* which is able to terminate the xhr upfront early
*/
_startTimeout: function() {
- var _Lang = myfaces._impl._util._Lang;
if (this._timeout && this._onTimeout) {
var _req = this._xhr;
var _context = this._context;
@@ -155,7 +119,7 @@ myfaces._impl.core._Runtime.extendClass(
this._timeoutId = window.setTimeout(
//we unify the api, there must be always a request passed to the external function
//and always a context, no matter what
- _Lang.hitch(this,
+ this._Lang.hitch(this,
function() {
//the hitch has to be done due to the setTimeout refocusing the scope of this
//to window
@@ -180,11 +144,11 @@ myfaces._impl.core._Runtime.extendClass(
* triggered by RequestQueue
*/
callback : function() {
- var READY_STATE_DONE = 4;
+
try {
var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
- if (this._xhr.readyState == READY_STATE_DONE) {
+ if (this._xhr.readyState == this._READY_STATE_DONE) {
if(this._timeoutId) {
//normally the timeout should not cause anything anymore
//but just to make sure
@@ -192,7 +156,7 @@ myfaces._impl.core._Runtime.extendClass(
this._timeoutId = null;
}
this._onDone(this._xhr, this._context);
- if (this._xhr.status >= 200 && this._xhr.status < 300) {
+ if (this._xhr.status >= this._STATUS_OK_MINOR && this._xhr.status < this._STATUS_OK_MAJOR) {
this._onSuccess(this._xhr, this._context);
} else {
this._onError(this._xhr, this._context);
@@ -203,19 +167,6 @@ myfaces._impl.core._Runtime.extendClass(
} finally {
//final cleanup to terminate everything
}
- },
-
- /**
- * Spec. 13.3.1
- * Collect and encode input elements.
- * Additionally the hidden element javax.faces.ViewState
- * @return {String} - Concatenated String of the encoded input elements
- * and javax.faces.ViewState element
- */
- getViewState : function() {
- return this._ajaxUtil.encodeSubmittableFields(this._xhr, this._context, this._source,
- this._sourceForm, this._partialIdsArray);
}
-
});
Added: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_BaseRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_BaseRequest.js?rev=963211&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_BaseRequest.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_BaseRequest.js Mon Jul 12 08:36:57 2010
@@ -0,0 +1,112 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ *
+ * Abstract base request encapuslating all methods and variables
+ * shared over all different request objects
+ *
+ * Author: Werner Punz (latest modification by $Author: ganeshpuri $)
+ * Version: $Revision: 1.4 $ $Date: 2009/05/31 09:16:44 $
+ */
+/** @namespace myfaces._impl.xhrCore._AjaxRequest */
+myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._BaseRequest", Object, {
+
+ _Dom: myfaces._impl._util._Dom,
+ _Lang: myfaces._impl._util._Lang,
+
+ _contentType: "application/x-www-form-urlencoded",
+ _source: null,
+ _xhr: null,
+ _encoding:null ,
+
+ _context:null,
+ _ajaxUtil: null,
+ _sourceForm: null,
+ _passThrough: null,
+ _requestParameters: null,
+ _exception: null,
+ _timeout: null,
+ _delay:null,
+ _queueSize:-1,
+
+ _partialIdsArray : null,
+ //callbacks for onDone... done issues
+ //onSuccess everything has passed through
+ //onError server side error
+
+ //onException exception thrown by the client
+ //onWarning warning issued by the client
+ _onDone : null,
+ _onSuccess: null,
+ _onError: null,
+ _onException: null,
+ _onWarning: null,
+ _onTimeout:null,
+
+ /*response object which is exposed to the queue*/
+ _response: null,
+
+ _timeoutId: null,
+
+ /*all instance vars can be set from the outside
+ * via a parameter map*/
+ _ajaxType: "POST",
+
+ /*
+ * constants used internally
+ */
+ _CONTENT_TYPE:"Content-Type",
+ _HEAD_FACES_REQ:"Faces-Request",
+
+ _READY_STATE_DONE: 4,
+ _STATUS_OK_MINOR: 200,
+ _STATUS_OK_MAJOR: 300,
+
+ _VAL_AJAX: "partial/ajax",
+
+ //abstract methods which have to be implemented
+ //since we do not have abstract methods we simulate them
+ //by using empty ones
+ constructor_: function() {
+ },
+
+ /**
+ * send the request
+ */
+ send: function() {
+ },
+
+ /**
+ * the callback function after the request is done
+ */
+ callback: function() {
+
+ },
+
+ //non abstract ones
+ /**
+ * Spec. 13.3.1
+ * Collect and encode input elements.
+ * Additionally the hidden element javax.faces.ViewState
+ * @return {String} - Concatenated String of the encoded input elements
+ * and javax.faces.ViewState element
+ */
+ getViewState : function() {
+ return this._ajaxUtil.encodeSubmittableFields(this._xhr, this._context, this._source,
+ this._sourceForm, this._partialIdsArray);
+ }
+});
\ No newline at end of file
Added: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js?rev=963211&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js Mon Jul 12 08:36:57 2010
@@ -0,0 +1,186 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to you under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Iframe request for communications over Iframes
+ *
+ * This method can be used by older browsers and if you have
+ * a multipart request which includes
+ * a fileupload element, fileuploads cannot be handled by
+ */
+myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._IFrameRequest", myfaces._impl.xhrCore._BaseRequest, {
+
+ _FRAME_ID: "myfaces-communications-frame",
+ _frame: null,
+
+ /**
+ * constructor which shifts the arguments
+ * to the protected properties of this clas
+ *
+ * @param arguments
+ */
+ constructor_: function(arguments) {
+ try {
+ //we fetch in the standard arguments
+ this._Lang.applyArgs(this, arguments);
+ } catch (e) {
+ //_onError
+ this._onException(null, this._context, "myfaces._impl.xhrCore._IFrameRequest", "constructor", e);
+ }
+ },
+
+ /**
+ * send method, central callback which sends the
+ * request
+ */
+ send: function() {
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
+ this._frame = this._createTransportFrame();
+ //we append an onload handler to the frame
+ //to cover the starting and loading events,
+ //timeouts cannot be covered in a cross browser way
+
+ //we point our onload handler to the frame
+ this._Lang.addOnLoad(this._frame, this._Lang.hitch(this, this.callback));
+
+ if (!this._response) {
+ this._response = new myfaces._impl.xhrCore._AjaxResponse(this._onException, this._onWarning);
+ }
+ //now to the parameter passing:
+ _Impl.sendEvent(this._xhr, _Impl.BEGIN);
+
+ //viewstate should be in our parent form which we will isse we however have to add the execute and
+ //render parameters as well as the usual javax.faces.request params to our target
+
+ var oldTarget = this._sourceForm.target;
+ var oldMethod = this._sourceForm.method;
+ try {
+ this._initAjaxParams();
+ this._sourceForm.target = this._frame.name;
+ this._sourceForm.method = this._ajaxType;
+ this._sourceForm.submit();
+ } finally {
+ this._removeAjaxParams(oldTarget);
+ this._sourceForm.target = oldTarget;
+ this._sourceForm.method = oldMethod;
+ }
+ },
+
+ /**
+ * the callback function after the request is done
+ */
+ callback: function() {
+ //now we have to do the processing, for that we have to parse the result, if it is a http 404 then
+ //nothing could be delivered and we bomb out with an error anything else has to be parsed
+ //via our xml parser
+
+ var request = {};
+ try {
+ request.responseText = this._frame.contentWindow.document.body ? this._frame.contentWindow.document.body.innerHTML : this._frame.contentWindow.document.documentElement.textContent;
+ request.responseXML = this._frame.contentWindow.document.XMLDocument ? this._frame.contentWindow.document.XMLDocument : this._frame.contentWindow.document;
+
+ request.readyState = this._READY_STATE_DONE;
+ this._onDone(request, this._context);
+
+ if (!this._Lang.isXMLParseError(request.responseXML)) {
+ request.status = 201;
+ this._onSuccess(request, this._context);
+ } else {
+ request.status = 0;
+ this._onError(request, this._context);
+ }
+ } catch (e) {
+ //_onError
+ this._onException(null, this._context, "myfaces._impl.xhrCore._IFrameRequest", "constructor", e);
+ } finally {
+ this._frame.parentNode.removeChild(this._frame);
+ delete this._frame;
+ }
+ },
+
+ _initAjaxParams: function() {
+ var _Impl = myfaces._impl.core.Impl;
+ //this._appendHiddenValue(_Impl.P_AJAX, "");
+
+ for (var key in this._passThrough) {
+ this._appendHiddenValue(key, this._passThrough[key]);
+ }
+ },
+
+ _removeAjaxParams: function(oldTarget) {
+ var _Impl = myfaces._impl.core.Impl;
+ this._sourceForm.target = oldTarget;
+ for (var key in this._passThrough) {
+ this._removeHiddenValue(key);
+ }
+ },
+
+ _appendHiddenValue: function(key, value) {
+ if ('undefined' == typeof value) {
+ return;
+ }
+ var input = document.createElement("input");
+ this._Dom.setAttribute(input, "name", key);
+ this._Dom.setAttribute(input, "style", "display:none");
+ this._Dom.setAttribute(input, "value", value);
+ this._sourceForm.appendChild(input);
+ },
+
+ _removeHiddenValue: function(key) {
+ var elem = this._Dom.findByName(this._sourceForm, key, true);
+ if (elem.length) {
+ elem[0].parentNode.removeChild(elem[0]);
+ delete elem[0];
+ }
+ },
+
+ _createTransportFrame: function() {
+ var frame = document.getElementById(this._FRAME_ID);
+ //normally this code should not be called
+ //but just to be sure
+ if (frame) {
+ frame.parentNode.removeChild(frame);
+ delete frame;
+ }
+
+ frame = document.createElement('iframe');
+
+ this._Dom.setAttribute(frame, "src", "about:blank");
+ this._Dom.setAttribute(frame, "id", this._FRAME_ID);
+ this._Dom.setAttribute(frame, "name", this._FRAME_ID);
+ this._Dom.setAttribute(frame, "type", "content");
+ this._Dom.setAttribute(frame, "collapsed", "true");
+ this._Dom.setAttribute(frame, "style", "display:none");
+
+ //security, we turn everything off
+ //we wont need it
+ if (frame.webNavigation) {
+ frame.webNavigation.allowAuth = false;
+ frame.webNavigation.allowImages = false;
+ frame.webNavigation.allowJavascript = false;
+ frame.webNavigation.allowMetaRedirects = false;
+ frame.webNavigation.allowPlugins = false;
+ frame.webNavigation.allowSubframes = false;
+ }
+ document.body.appendChild(frame);
+ return frame;
+ }
+
+ //TODO pps, the idea behind pps is to generate another form
+ // and temporarily shift the elements over which have to be
+ // ppsed, but it is up for discussion if we do pps at all in case of
+ // an iframe, so I wont implement anything for now
+});
\ No newline at end of file
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js?rev=963211&r1=963210&r2=963211&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Transports.js Mon Jul 12 08:36:57 2010
@@ -28,6 +28,12 @@
* transport.xhrQueuedPost
*
* or transport.xhrPost,transport.xhrGet etc... in the future
+ *
+ * Note we have taken a pattern lesson or two from the dojo toolkit and its excellent handling
+ * of transports by our patterns here (which is mainly a centralized transport singleton which routes
+ * to different transport implementations and the auto passing of parameters into their
+ * corresponding protected attributes on class level in the transports themselves)
+ *
*/
/** @namespace myfaces._impl.xhrCore._Transports */
myfaces._impl.core._Runtime.extendClass("myfaces._impl.xhrCore._Transports"
@@ -60,6 +66,22 @@ myfaces._impl.core._Runtime.extendClass(
/**
+ * a simple not enqueued xhr post
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ xhrPost : function(source, sourceForm, context, passThrgh) {
+ (new myfaces._impl.xhrCore._AjaxRequest(this._getArguments(source, sourceForm, context, passThrgh))).send();
+ },
+
+ /**
+ * xhr post with enqueuing as defined by the jsf 2.0 specification
+ *
* mapped options already have the exec and view properly in place
* myfaces specifics can be found under mappedOptions.myFaces
* @param {Node} source the source of this call
@@ -73,6 +95,124 @@ myfaces._impl.core._Runtime.extendClass(
},
/**
+ * xhr get without enqueuing
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ xhrGet : function(source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ args.ajaxType = "GET";
+ (new myfaces._impl.xhrCore._AjaxRequest(args)).send();
+ },
+
+ /**
+ * xhr get which takes the existing queue into consideration to by synchronized
+ * to previous queued post requests
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ xhrQueuedGet : function(source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ args.ajaxType = "GET";
+ this._q.enqueue(
+ new myfaces._impl.xhrCore._AjaxRequest(args));
+ },
+
+
+ /**
+ * iframe post without queueing
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ iframePost : function(source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+
+ (new myfaces._impl.xhrCore._IFrameRequest(args)).send();
+ },
+
+ /**
+ * iframe queued post
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ iframeQueuedPost : function(source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ this._q.enqueue(
+ new myfaces._impl.xhrCore._IFrameRequest(args));
+ },
+
+
+ /**
+ * iframe get without queueing
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ iframeGet : function(source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ // we have to live with it
+ args.ajaxType = "GET";
+ (new myfaces._impl.xhrCore._IFrameRequest(args)).send();
+ },
+
+ /**
+ * iframe queued http get
+ *
+ * mapped options already have the exec and view properly in place
+ * myfaces specifics can be found under mappedOptions.myFaces
+ * @param {Node} source the source of this call
+ * @param {Node} sourceForm the html form which is the source of this call
+ * @param {Object} context (Map) the internal pass through context
+ * @param {Object} passThrgh (Map) values to be passed through
+ **/
+ iframeQueuedGet : function(source, sourceForm, context, passThrgh) {
+ var args = this._getArguments(source, sourceForm, context, passThrgh);
+ // note in get the timeout is not working delay however is and queue size as well
+ // since there are no cross browser ways to resolve a timeout on xhr level
+ args.ajaxType = "GET";
+ this._q.enqueue(
+ new myfaces._impl.xhrCore._IFrameRequest(args));
+ },
+
+
+ /**
* Spec. 13.3.3
* Examining the response markup and updating the DOM tree
* @param {XmlHttpRequest} request - the ajax request
@@ -179,7 +319,7 @@ myfaces._impl.core._Runtime.extendClass(
this._loadImpl();
try {
this._Impl.response(request, context);
-
+
this._Impl.sendEvent(request, context, this._Impl.SUCCESS);
} finally {
this._q.processQueue();
@@ -206,15 +346,20 @@ myfaces._impl.core._Runtime.extendClass(
errorText += " and reason " + this._xhr.statusText;
}
}
+
} catch (e) {
errorText = "Request failed with unknown status";
+ } finally {
+ try {
+ this._Impl.sendError(request, context, this._Impl.HTTPERROR,
+ this._Impl.HTTPERROR, errorText);
+ } finally {
+ this._q.processQueue();
+ }
}
//_onError
- this._Impl.sendError(request, context, this._Impl.HTTPERROR,
- this._Impl.HTTPERROR, errorText);
- },
-
+ },
/**
* standard timeout handler
@@ -262,7 +407,7 @@ myfaces._impl.core._Runtime.extendClass(
throw exception;
}
},
-
+
_loadImpl: function() {
if (!this._Impl) {