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/05/14 14:06:57 UTC
svn commit: r944216 - in
/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl:
_util/_HtmlStripper.js core/_Runtime.js core/jsf_impl.js
xhrCore/_AjaxRequest.js xhrCore/_AjaxResponse.js xhrCore/_AjaxUtils.js
xhrCore/_Exception.js
Author: werpu
Date: Fri May 14 12:06:56 2010
New Revision: 944216
URL: http://svn.apache.org/viewvc?rev=944216&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2716
impl singleton cleanup, the old code was useful in conjunction with the old structures but is not anymore
Modified:
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_HtmlStripper.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_impl.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/_AjaxResponse.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_HtmlStripper.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_HtmlStripper.js?rev=944216&r1=944215&r2=944216&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_HtmlStripper.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_HtmlStripper.js Fri May 14 12:06:56 2010
@@ -84,7 +84,7 @@ myfaces._impl.core._Runtime.extendClass(
this._tokenForward = 1;
if ('undefined' == typeof tagNameStart || null == tagNameStart) {
- this.tagNameStart = this.prototype.BEGIN_TAG;
+ this.tagNameStart = this.BEGIN_TAG;
} else {
this.tagNameStart = tagNameStart;
}
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=944216&r1=944215&r2=944216&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 Fri May 14 12:06:56 2010
@@ -297,27 +297,6 @@ if ('undefined' == typeof myfaces._impl
return true; // Boolean
};
- /**
- * gets the local or global options with local ones having higher priority
- * if no local or global one was found then the default value is given back
- *
- * @param {String} configName the name of the configuration entry
- * @param {String} localOptions the local options root for the configuration myfaces as default marker is added implicitely
- *
- * @param {Object} defaultValue the default init value
- *
- * @return either the config entry or if none is given the default value
- */
- myfaces._impl.core._Runtime.getLocalOrGlobalConfig = function(localOptions, configName, defaultValue) {
- /*use(myfaces._impl._util)*/
- var _RT = myfaces._impl._util._Core;
-
- var globalOption = myfaces._impl._util._Dom.getGlobalConfig(configName, defaultValue);
- if (!_RT.exists(localOptions, "myfaces") || !_RT.exists(localOptions.myfaces, configName)) {
- return globalOption;
- }
- return localOptions.myfaces[configName];
- };
/**
* Convenience method
@@ -325,7 +304,7 @@ if ('undefined' == typeof myfaces._impl
* our lazily binding configuration system
*/
myfaces._impl.core._Runtime.getImpl = function() {
- myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces.ajax);
+ myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
};
/**
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js?rev=944216&r1=944215&r2=944216&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js Fri May 14 12:06:56 2010
@@ -12,517 +12,508 @@
* limitations under the License.
* under the License.
*/
+myfaces._impl.core._Runtime.singletonExtendClass("myfaces._impl.core._jsfImpl", Object, {
-if (myfaces._impl.core._Runtime.reserveNamespace("myfaces._impl.core._jsfImpl")) {
+ //third option myfaces._impl.xhrCoreAjax which will be the new core impl for now
+ _requestHandler : new (myfaces._impl.core._Runtime.getGlobalConfig("transport", myfaces._impl.xhrCore._Ajax))(),
- myfaces._impl.core._Runtime.applyToGlobalNamespace("myfaces._impl.core._jsfImpl", myfaces._impl.core._Runtime.extendClass(function() {
- }, Object, {
+ /**
+ * external event listener queue!
+ */
+ _eventListenerQueue : new (myfaces._impl.core._Runtime.getGlobalConfig("eventListenerQueue", myfaces._impl._util._ListenerQueue))(),
+
+ /**
+ * external error listener queue!
+ */
+ _errorListenerQueue : new (myfaces._impl.core._Runtime.getGlobalConfig("errorListenerQueue", myfaces._impl._util._ListenerQueue))(),
+
+ /*CONSTANTS*/
+
+ /*internal identifiers for options*/
+ _OPT_IDENT_ALL : "@all",
+ _OPT_IDENT_NONE : "@none",
+ _OPT_IDENT_THIS : "@this",
+ _OPT_IDENT_FORM : "@form",
+
+ /*
+ * [STATIC] constants
+ */
+
+ _PROP_PARTIAL_SOURCE : "javax.faces.source",
+ _PROP_VIEWSTATE : "javax.faces.ViewState",
+ _PROP_AJAX : "javax.faces.partial.ajax",
+ _PROP_EXECUTE : "javax.faces.partial.execute",
+ _PROP_RENDER : "javax.faces.partial.render",
+ _PROP_EVENT : "javax.faces.partial.event",
+
+ /* message types */
+ _MSG_TYPE_ERROR : "error",
+ _MSG_TYPE_EVENT : "event",
+
+ /* event emitting stages */
+ _AJAX_STAGE_BEGIN : "begin",
+ _AJAX_STAGE_COMPLETE : "complete",
+ _AJAX_STAGE_SUCCESS : "success",
+
+ /*ajax errors spec 14.4.2*/
+ _ERROR_HTTPERROR : "httpError",
+ _ERROR_EMPTY_RESPONSE : "emptyResponse",
+ _ERROR_MALFORMEDXML : "malformedXML",
+ _ERROR_SERVER_ERROR : "serverError",
+ _ERROR_CLIENT_ERROR : "clientError",
- //third option myfaces._impl.xhrCoreAjax which will be the new core impl for now
- _requestHandler : new (myfaces._impl.core._Runtime.getGlobalConfig("transport", myfaces._impl.xhrCore._Ajax))(),
- /**
- * external event listener queue!
- */
- _eventListenerQueue : new (myfaces._impl.core._Runtime.getGlobalConfig("eventListenerQueue", myfaces._impl._util._ListenerQueue))(),
+ /**
+ * collect and encode data for a given form element (must be of type form)
+ * find the javax.faces.ViewState element and encode its value as well!
+ * return a concatenated string of the encoded values!
+ *
+ * @throws error in case of the given element not being of type form!
+ * https://issues.apache.org/jira/browse/MYFACES-2110
+ */
+ getViewState : function(formElement) {
/**
- * external error listener queue!
+ * typecheck assert!, we opt for strong typing here
+ * because it makes it easier to detect bugs
*/
- _errorListenerQueue : new (myfaces._impl.core._Runtime.getGlobalConfig("errorListenerQueue", myfaces._impl._util._ListenerQueue))(),
+ if ('undefined' != typeof formElement && null != formElement) {
+ formElement = myfaces._impl._util._Lang.byId(formElement);
+ }
- /*CONSTANTS*/
+ if ('undefined' == typeof(formElement)
+ || null == formElement
+ || 'undefined' == typeof(formElement.nodeName)
+ || null == formElement.nodeName
+ || formElement.nodeName.toLowerCase() != "form") {
+ throw new Error("jsf.viewState: param value not of type form!");
+ }
- /*internal identifiers for options*/
- _OPT_IDENT_ALL : "@all",
- _OPT_IDENT_NONE : "@none",
- _OPT_IDENT_THIS : "@this",
- _OPT_IDENT_FORM : "@form",
+ var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
+ return ajaxUtils.processUserEntries(null, null, null, formElement, null);
- /*
- * [STATIC] constants
- */
+ },
- _PROP_PARTIAL_SOURCE : "javax.faces.source",
- _PROP_VIEWSTATE : "javax.faces.ViewState",
- _PROP_AJAX : "javax.faces.partial.ajax",
- _PROP_EXECUTE : "javax.faces.partial.execute",
- _PROP_RENDER : "javax.faces.partial.render",
- _PROP_EVENT : "javax.faces.partial.event",
-
- /* message types */
- _MSG_TYPE_ERROR : "error",
- _MSG_TYPE_EVENT : "event",
-
- /* event emitting stages */
- _AJAX_STAGE_BEGIN : "begin",
- _AJAX_STAGE_COMPLETE : "complete",
- _AJAX_STAGE_SUCCESS : "success",
-
- /*ajax errors spec 14.4.2*/
- _ERROR_HTTPERROR : "httpError",
- _ERROR_EMPTY_RESPONSE : "emptyResponse",
- _ERROR_MALFORMEDXML : "malformedXML",
- _ERROR_SERVER_ERROR : "serverError",
- _ERROR_CLIENT_ERROR : "clientError",
+ /**
+ * internal assertion check for the element parameter
+ * it cannot be null or undefined
+ * it must be either a string or a valid existing dom node
+ */
+ _assertElement : function(/*String|Dom Node*/ element) {
+ /*namespace remap for our local function context we mix the entire function namespace into
+ *a local function variable so that we do not have to write the entire namespace
+ *all the time
+ **/
+ var _Lang = myfaces._impl._util._Lang;
+ /**
+ * assert element
+ */
+ if ('undefined' == typeof( element ) || null == element) {
+ throw new Error("jsf.ajax, element must be set!");
+ }
+ // if (!JSF2Utils.isString(element) && !(element instanceof Node)) {
+ // throw new Error("jsf.ajax, element either must be a string or a dom node");
+ // }
+
+ element = _Lang.byId(element);
+ if ('undefined' == typeof element || null == element) {
+ throw new Error("Element either must be a string to a or must be a valid dom node");
+ }
+ },
+
+ _assertFunction : function(func) {
+ if ('undefined' == typeof func || null == func) {
+ return;
+ }
+ if (!(func instanceof Function)) {
+ throw new Error("Functioncall " + func + " is not a function! ");
+ }
+ },
+ /**
+ * this function has to send the ajax requests
+ *
+ * following request conditions must be met:
+ * <ul>
+ * <li> the request must be sent asynchronously! </li>
+ * <li> the request must be a POST!!! request </li>
+ * <li> the request url must be the form action attribute </li>
+ * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
+ * </ul>
+ *
+ * @param {String|Node} element any dom element no matter being it html or jsf, from which the event is emitted
+ * @param {|Event|} event any javascript event supported by that object
+ * @param {|Object|} options map of options being pushed into the ajax cycle
+ */
+ request : function(element, event, options) {
+
+ /*namespace remap for our local function context we mix the entire function namespace into
+ *a local function variable so that we do not have to write the entire namespace
+ *all the time
+ **/
+ var _Lang = myfaces._impl._util._Lang;
+ var elementId = null;
/**
- * collect and encode data for a given form element (must be of type form)
- * find the javax.faces.ViewState element and encode its value as well!
- * return a concatenated string of the encoded values!
- *
- * @throws error in case of the given element not being of type form!
- * https://issues.apache.org/jira/browse/MYFACES-2110
+ * we cross reference statically hence the mapping here
+ * the entire mapping between the functions is stateless
*/
- getViewState : function(formElement) {
- /**
- * typecheck assert!, we opt for strong typing here
- * because it makes it easier to detect bugs
- */
- if ('undefined' != typeof formElement && null != formElement) {
- formElement = myfaces._impl._util._Lang.byId(formElement);
- }
+ element = _Lang.byId(element);
+ event = ('undefined' == typeof event && window.event) ? window.event : event;
- if ('undefined' == typeof(formElement)
- || null == formElement
- || 'undefined' == typeof(formElement.nodeName)
- || null == formElement.nodeName
- || formElement.nodeName.toLowerCase() != "form") {
- throw new Error("jsf.viewState: param value not of type form!");
+ if ('undefined' != typeof element && null != element) {
+ //detached element handling, we also store the element name
+ //to get a fallback option in case the identifier is not determinable
+ // anymore, in case of a framework induced detachment the element.name should
+ // be shared if the identifier is not determinable anymore
+ elementId = ('undefined' != typeof element.id) ? element.id : null;
+ if ((elementId == null || elementId == '') && 'undefined' != typeof element.name) {
+ elementId = element.name;
}
+ }
- var ajaxUtils = new myfaces._impl.xhrCore._AjaxUtils(0);
- return ajaxUtils.processUserEntries(null, null, null, formElement, null);
+ /*assert if the onerror is set and once if it is set it must be of type function*/
+ this._assertFunction(options.onerror);
+ /*assert if the onevent is set and once if it is set it must be of type function*/
+ this._assertFunction(options.onevent);
- },
+ /*
+ * We make a copy of our options because
+ * we should not touch the incoming params!
+ */
+ var passThroughArguments = _Lang.mixMaps({}, options, true);
+
+ /*additional passthrough cleanup*/
+ /*ie6 supportive code to prevent browser leaks*/
+ passThroughArguments.onevent = null;
+ delete passThroughArguments.onevent;
+ /*ie6 supportive code to prevent browser leaks*/
+ passThroughArguments.onerror = null;
+ delete passThroughArguments.onerror;
+
+ if ('undefined' != typeof event && null != event) {
+ passThroughArguments[this._PROP_EVENT] = event.type;
+ }
/**
- * internal assertion check for the element parameter
- * it cannot be null or undefined
- * it must be either a string or a valid existing dom node
+ * ajax pass through context with the source
+ * onevent and onerror
*/
- _assertElement : function(/*String|Dom Node*/ element) {
- /*namespace remap for our local function context we mix the entire function namespace into
- *a local function variable so that we do not have to write the entire namespace
- *all the time
- **/
- var _Lang = myfaces._impl._util._Lang;
-
- /**
- * assert element
- */
- if ('undefined' == typeof( element ) || null == element) {
- throw new Error("jsf.ajax, element must be set!");
- }
- // if (!JSF2Utils.isString(element) && !(element instanceof Node)) {
- // throw new Error("jsf.ajax, element either must be a string or a dom node");
- // }
-
- element = _Lang.byId(element);
- if ('undefined' == typeof element || null == element) {
- throw new Error("Element either must be a string to a or must be a valid dom node");
- }
+ var ajaxContext = {};
+ ajaxContext.source = element;
+ ajaxContext.onevent = options.onevent;
+ ajaxContext.onerror = options.onerror;
- },
+ /**
+ * fetch the parent form
+ */
- _assertFunction : function(func) {
- if ('undefined' == typeof func || null == func) {
- return;
- }
- if (!(func instanceof Function)) {
- throw new Error("Functioncall " + func + " is not a function! ");
+ var sourceForm = myfaces._impl._util._Dom.fuzzyFormDetection(element);
+ var _Lang = myfaces._impl._util._Lang;
+ if (null == sourceForm && 'undefined' != typeof event && null != event) {
+ sourceForm = myfaces._impl._util._Dom.fuzzyFormDetection(_Lang.getEventTarget(event));
+ if (null == sourceForm) {
+ throw Error("Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
}
- },
+ } else if (null == sourceForm) {
+ throw Error("Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
+ }
/**
- * this function has to send the ajax requests
- *
- * following request conditions must be met:
- * <ul>
- * <li> the request must be sent asynchronously! </li>
- * <li> the request must be a POST!!! request </li>
- * <li> the request url must be the form action attribute </li>
- * <li> all requests must be queued with a client side request queue to ensure the request ordering!</li>
- * </ul>
- *
- * @param {String|Node} element any dom element no matter being it html or jsf, from which the event is emitted
- * @param {|Event|} event any javascript event supported by that object
- * @param {|Object|} options map of options being pushed into the ajax cycle
+ * binding contract the javax.faces.source must be set
*/
- request : function(element, event, options) {
+ passThroughArguments[this._PROP_PARTIAL_SOURCE] = elementId;
- /*namespace remap for our local function context we mix the entire function namespace into
- *a local function variable so that we do not have to write the entire namespace
- *all the time
- **/
- var _Lang = myfaces._impl._util._Lang;
- var elementId = null;
- /**
- * we cross reference statically hence the mapping here
- * the entire mapping between the functions is stateless
- */
- element = _Lang.byId(element);
- event = ('undefined' == typeof event && window.event) ? window.event : event;
-
- if ('undefined' != typeof element && null != element) {
- //detached element handling, we also store the element name
- //to get a fallback option in case the identifier is not determinable
- // anymore, in case of a framework induced detachment the element.name should
- // be shared if the identifier is not determinable anymore
- elementId = ('undefined' != typeof element.id) ? element.id : null;
- if ((elementId == null || elementId == '') && 'undefined' != typeof element.name) {
- elementId = element.name;
- }
- }
+ /**
+ * javax.faces.partial.ajax must be set to true
+ */
+ passThroughArguments[this._PROP_AJAX] = true;
- /*assert if the onerror is set and once if it is set it must be of type function*/
- this._assertFunction(options.onerror);
- /*assert if the onevent is set and once if it is set it must be of type function*/
- this._assertFunction(options.onevent);
-
- /*
- * We make a copy of our options because
- * we should not touch the incoming params!
- */
- var passThroughArguments = _Lang.mixMaps({}, options, true);
-
- /*additional passthrough cleanup*/
- /*ie6 supportive code to prevent browser leaks*/
- passThroughArguments.onevent = null;
- delete passThroughArguments.onevent;
- /*ie6 supportive code to prevent browser leaks*/
- passThroughArguments.onerror = null;
- delete passThroughArguments.onerror;
+ /**
+ * if execute or render exist
+ * we have to pass them down as a blank delimited string representation
+ * of an array of ids!
+ */
+ if (_Lang.exists(passThroughArguments, "execute")) {
+ /*the options must be a blank delimited list of strings*/
+ var execString = _Lang.arrayToString(passThroughArguments.execute, ' ');
+ var execNone = execString.indexOf(this._OPT_IDENT_NONE) != -1;
+ var execAll = execString.indexOf(this._OPT_IDENT_ALL) != -1;
+ if (!execNone && !execAll) {
+ execString = execString.replace(this._OPT_IDENT_FORM, sourceForm.id);
+ execString = execString.replace(this._OPT_IDENT_THIS, elementId);
+
+ passThroughArguments[this._PROP_EXECUTE] = execString;
+ } else if (execAll) {
+ passThroughArguments[this._PROP_EXECUTE] = this._OPT_IDENT_ALL;
+ }
+
+ passThroughArguments.execute = null;
+ /*remap just in case we have a valid pointer to an existing object*/
+ delete passThroughArguments.execute;
+ } else {
+ passThroughArguments[this._PROP_EXECUTE] = elementId;
+ }
+
+ if (_Lang.exists(passThroughArguments, "render")) {
+ var renderString = _Lang.arrayToString(passThroughArguments.render, ' ');
+ var renderNone = renderString.indexOf(this._OPT_IDENT_NONE) != -1;
+ var renderAll = renderString.indexOf(this._OPT_IDENT_ALL) != -1;
+ if (!renderNone && !renderAll) {
+ renderString = renderString.replace(this._OPT_IDENT_FORM, sourceForm.id);
+ renderString = renderString.replace(this._OPT_IDENT_THIS, elementId);
+ passThroughArguments[this._PROP_RENDER] = renderString;
+ passThroughArguments.render = null;
+ } else if (renderAll) {
+ passThroughArguments[this._PROP_RENDER] = this._OPT_IDENT_ALL;
- if ('undefined' != typeof event && null != event) {
- passThroughArguments[this._PROP_EVENT] = event.type;
}
+ delete passThroughArguments.render;
+ }
- /**
- * ajax pass through context with the source
- * onevent and onerror
- */
- var ajaxContext = {};
- ajaxContext.source = element;
- ajaxContext.onevent = options.onevent;
- ajaxContext.onerror = options.onerror;
-
- /**
- * fetch the parent form
- */
+ //implementation specific options are added to the context for further processing
+ if ('undefined' != typeof passThroughArguments.myfaces && null != passThroughArguments.myfaces) {
+ ajaxContext.myfaces = passThroughArguments.myfaces;
+ delete passThroughArguments.myfaces;
+ }
+ this._requestHandler._ajaxRequest(element, sourceForm, ajaxContext, passThroughArguments);
+ },
- var sourceForm = myfaces._impl._util._Dom.fuzzyFormDetection(element);
- var _Lang = myfaces._impl._util._Lang;
- if (null == sourceForm && 'undefined' != typeof event && null != event) {
- sourceForm = myfaces._impl._util._Dom.fuzzyFormDetection(_Lang.getEventTarget(event));
- if(null == sourceForm) {
- throw Error("Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
- }
- } else if(null == sourceForm) {
- throw Error("Sourceform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
- }
+ addOnError : function(/*function*/errorListener) {
+ /*error handling already done in the assert of the queue*/
+ this._errorListenerQueue.add(errorListener);
+ },
+
+ addOnEvent : function(/*function*/eventListener) {
+ /*error handling already done in the assert of the queue*/
+ this._eventListenerQueue.add(eventListener);
+ },
+
+ /**
+ * implementation triggering the error chain
+ *
+ * @param {Object} request the request object which comes from the xhr cycle
+ * @param {Object} context (Map) the context object being pushed over the xhr cycle keeping additional metadata
+ * @param {String} name the error name
+ * @param {String} serverErrorName the server error name in case of a server error
+ * @param {String} serverErrorMessage the server error message in case of a server error
+ *
+ * handles the errors, in case of an onError exists within the context the onError is called as local error handler
+ * the registered error handlers in the queue receiv an error message to be dealt with
+ * and if the projectStage is at development an alert box is displayed
+ *
+ * note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided
+ * which changes the default output behavior from alert to something else
+ *
+ *
+ */
+ sendError : function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage) {
+ var eventData = {};
+ //we keep this in a closure because we might reuse it for our serverErrorMessage
+ var malFormedMessage = function() {
+ return ('undefined' != typeof name && name == myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML) ? "The server response could not be parsed, the server has returned with a response which is not xml !" : "";
+ };
+
+ eventData.type = this._MSG_TYPE_ERROR;
+
+ eventData.status = name;
+ eventData.serverErrorName = serverErrorName;
+ eventData.serverErrorMessage = serverErrorMessage;
- /**
- * binding contract the javax.faces.source must be set
- */
- passThroughArguments[this._PROP_PARTIAL_SOURCE] = elementId;
-
- /**
- * javax.faces.partial.ajax must be set to true
- */
- passThroughArguments[this._PROP_AJAX] = true;
-
- /**
- * if execute or render exist
- * we have to pass them down as a blank delimited string representation
- * of an array of ids!
- */
- if (_Lang.exists(passThroughArguments, "execute")) {
- /*the options must be a blank delimited list of strings*/
- var execString = _Lang.arrayToString(passThroughArguments.execute, ' ');
- var execNone = execString.indexOf(this._OPT_IDENT_NONE) != -1;
- var execAll = execString.indexOf(this._OPT_IDENT_ALL) != -1;
- if (!execNone && !execAll) {
- execString = execString.replace(this._OPT_IDENT_FORM, sourceForm.id);
- execString = execString.replace(this._OPT_IDENT_THIS, elementId);
-
- passThroughArguments[this._PROP_EXECUTE] = execString;
- } else if (execAll) {
- passThroughArguments[this._PROP_EXECUTE] = this._OPT_IDENT_ALL;
- }
-
- passThroughArguments.execute = null;
- /*remap just in case we have a valid pointer to an existing object*/
- delete passThroughArguments.execute;
- } else {
- passThroughArguments[this._PROP_EXECUTE] = elementId;
- }
+ try {
+ eventData.source = context.source;
+ eventData.responseCode = request.status;
+ eventData.responseText = request.responseText;
+ eventData.responseXML = request.responseXML;
+ } catch (e) {
+ // silently ignore: user can find out by examining the event data
+ }
- if (_Lang.exists(passThroughArguments, "render")) {
- var renderString = _Lang.arrayToString(passThroughArguments.render, ' ');
- var renderNone = renderString.indexOf(this._OPT_IDENT_NONE) != -1;
- var renderAll = renderString.indexOf(this._OPT_IDENT_ALL) != -1;
- if (!renderNone && !renderAll) {
- renderString = renderString.replace(this._OPT_IDENT_FORM, sourceForm.id);
- renderString = renderString.replace(this._OPT_IDENT_THIS, elementId);
- passThroughArguments[this._PROP_RENDER] = renderString;
- passThroughArguments.render = null;
- } else if (renderAll) {
- passThroughArguments[this._PROP_RENDER] = this._OPT_IDENT_ALL;
+ /**/
+ if (myfaces._impl._util._Lang.exists(context, "onerror")) {
+ context.onerror(eventData);
+ }
- }
- delete passThroughArguments.render;
- }
+ /*now we serve the queue as well*/
+ this._errorListenerQueue.broadcastEvent(eventData);
- //implementation specific options are added to the context for further processing
- if ('undefined' != typeof passThroughArguments.myfaces && null != passThroughArguments.myfaces) {
- ajaxContext.myfaces = passThroughArguments.myfaces;
- delete passThroughArguments.myfaces;
- }
+ if (jsf.getProjectStage() === "Development" && this._errorListenerQueue.length() == 0) {
+ var defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert);
+ var finalMessage = [];
+
+ finalMessage.push(('undefined' != typeof name && null != name) ? name : "");
+ finalMessage.push(('undefined' != typeof serverErrorName && null != serverErrorName) ? serverErrorName : "");
+ finalMessage.push(('undefined' != typeof serverErrorMessage && null != serverErrorMessage) ? serverErrorMessage : "");
+ finalMessage.push(malFormedMessage());
- this._requestHandler._ajaxRequest(element, sourceForm, ajaxContext, passThroughArguments);
+ defaultErrorOutput(finalMessage.join("-") + " Note, this message is only sent, because project stage is development and no " +
+ "other error listeners are registered.");
+ }
+ },
- },
+ /**
+ * sends an event
+ */
+ sendEvent : function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) {
+ var eventData = {};
+ eventData.type = this._MSG_TYPE_EVENT;
- addOnError : function(/*function*/errorListener) {
- /*error handling already done in the assert of the queue*/
- this._errorListenerQueue.add(errorListener);
- },
-
- addOnEvent : function(/*function*/eventListener) {
- /*error handling already done in the assert of the queue*/
- this._eventListenerQueue.add(eventListener);
- },
+ eventData.status = name;
+ eventData.source = context.source;
- /**
- * implementation triggering the error chain
- *
- * @param {Object} request the request object which comes from the xhr cycle
- * @param {Object} context (Map) the context object being pushed over the xhr cycle keeping additional metadata
- * @param {String} name the error name
- * @param {String} serverErrorName the server error name in case of a server error
- * @param {String} serverErrorMessage the server error message in case of a server error
- *
- * handles the errors, in case of an onError exists within the context the onError is called as local error handler
- * the registered error handlers in the queue receiv an error message to be dealt with
- * and if the projectStage is at development an alert box is displayed
- *
- * note: we have additional functionality here, via the global config myfaces.config.defaultErrorOutput a function can be provided
- * which changes the default output behavior from alert to something else
- *
- *
- */
- sendError : function sendError(/*Object*/request, /*Object*/ context, /*String*/ name, /*String*/ serverErrorName, /*String*/ serverErrorMessage) {
- var eventData = {};
- //we keep this in a closure because we might reuse it for our serverErrorMessage
- var malFormedMessage = function() {
- return ('undefined' != typeof name && name == myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML) ? "The server response could not be parsed, the server has returned with a response which is not xml !" :"";
- };
-
- eventData.type = this._MSG_TYPE_ERROR;
-
- eventData.status = name;
- eventData.serverErrorName = serverErrorName;
- eventData.serverErrorMessage = serverErrorMessage;
+ if (name !== this._AJAX_STAGE_BEGIN) {
try {
- eventData.source = context.source;
eventData.responseCode = request.status;
eventData.responseText = request.responseText;
eventData.responseXML = request.responseXML;
- } catch (e) {
- // silently ignore: user can find out by examining the event data
- }
-
- /**/
- if (myfaces._impl._util._Lang.exists(context, "onerror")) {
- context.onerror(eventData);
- }
-
- /*now we serve the queue as well*/
- this._errorListenerQueue.broadcastEvent(eventData);
-
- if (jsf.getProjectStage() === "Development" && this._errorListenerQueue.length() == 0) {
- var defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert);
- var finalMessage = [];
-
- finalMessage.push(('undefined' != typeof name && null != name) ? name : "");
- finalMessage.push(('undefined' != typeof serverErrorName && null != serverErrorName) ? serverErrorName : "");
- finalMessage.push(('undefined' != typeof serverErrorMessage && null != serverErrorMessage) ? serverErrorMessage : "");
- finalMessage.push(malFormedMessage());
-
- defaultErrorOutput(finalMessage.join("-") + " Note, this message is only sent, because project stage is development and no " +
- "other error listeners are registered.");
- }
- },
-
- /**
- * sends an event
- */
- sendEvent : function sendEvent(/*Object*/request, /*Object*/ context, /*event name*/ name) {
- var eventData = {};
- eventData.type = this._MSG_TYPE_EVENT;
-
- eventData.status = name;
- eventData.source = context.source;
- if (name !== this._AJAX_STAGE_BEGIN) {
-
- try {
- eventData.responseCode = request.status;
- eventData.responseText = request.responseText;
- eventData.responseXML = request.responseXML;
-
- } catch (e) {
- var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces.ajax);
- impl.sendError(request, context, this._ERROR_CLIENT_ERROR, "ErrorRetrievingResponse",
- "Parts of the response couldn't be retrieved when constructing the event data: " + e);
- //client errors are not swallowed
- throw e;
- }
-
- }
-
- /**/
- if (myfaces._impl._util._Lang.exists(context, "onevent")) {
- /*calling null to preserve the original scope*/
- context.onevent.call(null, eventData);
+ } catch (e) {
+ var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+ impl.sendError(request, context, this._ERROR_CLIENT_ERROR, "ErrorRetrievingResponse",
+ "Parts of the response couldn't be retrieved when constructing the event data: " + e);
+ //client errors are not swallowed
+ throw e;
}
- /*now we serve the queue as well*/
- this._eventListenerQueue.broadcastEvent(eventData);
- },
+ }
- /**
- * processes the ajax response if the ajax request completes successfully
- * @param {Object} request (xhrRequest) the ajax request!
- * @param {Object} context (Map) context map keeping context data not being passed down over
- * the request boundary but kept on the client
- */
- response : function(request, context) {
- this._requestHandler._ajaxResponse(request, context);
- },
+ /**/
+ if (myfaces._impl._util._Lang.exists(context, "onevent")) {
+ /*calling null to preserve the original scope*/
+ context.onevent.call(null, eventData);
+ }
- /**
- * @return the project stage also emitted by the server:
- * it cannot be cached and must be delivered over the server
- * The value for it comes from the request parameter of the jsf.js script called "stage".
- */
- getProjectStage : function() {
- /* run through all script tags and try to find the one that includes jsf.js */
- var scriptTags = document.getElementsByTagName("script");
- for (var i = 0; i < scriptTags.length; i++)
+ /*now we serve the queue as well*/
+ this._eventListenerQueue.broadcastEvent(eventData);
+ },
+
+ /**
+ * processes the ajax response if the ajax request completes successfully
+ * @param {Object} request (xhrRequest) the ajax request!
+ * @param {Object} context (Map) context map keeping context data not being passed down over
+ * the request boundary but kept on the client
+ */
+ response : function(request, context) {
+ this._requestHandler._ajaxResponse(request, context);
+ },
+
+ /**
+ * @return the project stage also emitted by the server:
+ * it cannot be cached and must be delivered over the server
+ * The value for it comes from the request parameter of the jsf.js script called "stage".
+ */
+ getProjectStage : function() {
+ /* run through all script tags and try to find the one that includes jsf.js */
+ var scriptTags = document.getElementsByTagName("script");
+ for (var i = 0; i < scriptTags.length; i++)
+ {
+ if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1)
{
- if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1)
+ /* try to extract stage=XXX */
+ var result = scriptTags[i].src.match(/stage=([^&;]*)/);
+ if (result)
{
- /* try to extract stage=XXX */
- var result = scriptTags[i].src.match(/stage=([^&;]*)/);
- if (result)
+ /* we found stage=XXX */
+ /* return only valid values of ProjectStage */
+ if (result[1] == "Production"
+ || result[1] == "Development"
+ || result[1] == "SystemTest"
+ || result[1] == "UnitTest")
{
- /* we found stage=XXX */
- /* return only valid values of ProjectStage */
- if (result[1] == "Production"
- || result[1] == "Development"
- || result[1] == "SystemTest"
- || result[1] == "UnitTest")
- {
- return result[1];
- }
- }
- else
- {
- /* we found the script, but there was no stage parameter --> Production */
- return "Production";
+ return result[1];
}
}
- }
- /* we could not find anything valid --> return the default value */
- return "Production";
- },
-
- /**
- * implementation of the external chain function
- * moved into the impl
- *
- * @param {Object} source the source which also becomes
- * the scope for the calling function (unspecified side behavior)
- * the spec states here that the source can be any arbitrary code block.
- * Which means it either is a javascript function directly passed or a code block
- * which has to be evaluated separately.
- *
- * After revisiting the code additional testing against components showed that
- * the this parameter is only targeted at the component triggering the eval
- * (event) if a string code block is passed. This is behavior we have to resemble
- * in our function here as well, I guess.
- *
- * @param {Event} event the event object being passed down into the the chain as event origin
- * the spec is contradicting here, it on one hand defines event, and on the other
- * it says it is optional, after asking, it meant that event must be passed down
- * but can be undefined
- */
- chain : function(source, event) {
- var len = arguments.length;
- //the spec is contradicting here, it on one hand defines event, and on the other
- //it says it is optional, I have cleared this up now
- //the spec meant the param must be passed down, but can be 'undefined'
- if (len < 2) {
- throw new Error(" an event object or unknown must be passed as second parameter ");
- } else if (len < 3) {
- if ('function' == typeof event || myfaces._impl._util._Lang.isString(event)) {
- throw new Error(" an event must be passed down (either a an event object null or undefined) ");
+ else
+ {
+ /* we found the script, but there was no stage parameter --> Production */
+ return "Production";
}
- //nothing to be done here, move along
- return true;
}
- //now we fetch from what is given from the parameter list
- //we cannot work with splice here in any performant way so we do it the hard way
- //arguments only are give if not set to undefined even null values!
-
- //assertions source either null or set as dom element:
-
- if ('undefined' == typeof source) {
- throw new Error(" source must be defined");
- //allowed chain datatypes
- } else if ('function' == typeof source) {
- throw new Error(" source cannot be a function (probably source and event were not defined or set to null");
- }
- if (myfaces._impl._util._Lang.isString(source)) {
- throw new Error(" source cannot be a string ");
- }
-
- //assertion if event is a function or a string we already are in our function elements
- //since event either is undefined, null or a valid event object
-
+ }
+ /* we could not find anything valid --> return the default value */
+ return "Production";
+ },
+
+ /**
+ * implementation of the external chain function
+ * moved into the impl
+ *
+ * @param {Object} source the source which also becomes
+ * the scope for the calling function (unspecified side behavior)
+ * the spec states here that the source can be any arbitrary code block.
+ * Which means it either is a javascript function directly passed or a code block
+ * which has to be evaluated separately.
+ *
+ * After revisiting the code additional testing against components showed that
+ * the this parameter is only targeted at the component triggering the eval
+ * (event) if a string code block is passed. This is behavior we have to resemble
+ * in our function here as well, I guess.
+ *
+ * @param {Event} event the event object being passed down into the the chain as event origin
+ * the spec is contradicting here, it on one hand defines event, and on the other
+ * it says it is optional, after asking, it meant that event must be passed down
+ * but can be undefined
+ */
+ chain : function(source, event) {
+ var len = arguments.length;
+ //the spec is contradicting here, it on one hand defines event, and on the other
+ //it says it is optional, I have cleared this up now
+ //the spec meant the param must be passed down, but can be 'undefined'
+ if (len < 2) {
+ throw new Error(" an event object or unknown must be passed as second parameter ");
+ } else if (len < 3) {
if ('function' == typeof event || myfaces._impl._util._Lang.isString(event)) {
throw new Error(" an event must be passed down (either a an event object null or undefined) ");
}
+ //nothing to be done here, move along
+ return true;
+ }
+ //now we fetch from what is given from the parameter list
+ //we cannot work with splice here in any performant way so we do it the hard way
+ //arguments only are give if not set to undefined even null values!
+
+ //assertions source either null or set as dom element:
+
+ if ('undefined' == typeof source) {
+ throw new Error(" source must be defined");
+ //allowed chain datatypes
+ } else if ('function' == typeof source) {
+ throw new Error(" source cannot be a function (probably source and event were not defined or set to null");
+ }
+ if (myfaces._impl._util._Lang.isString(source)) {
+ throw new Error(" source cannot be a string ");
+ }
- for (var loop = 2; loop < len; loop++) {
- //we do not change the scope of the incoming functions
- //but we reuse the argument array capabilities of apply
- var retVal;
-
- if ('function' == typeof arguments[loop]) {
- retVal = arguments[loop].call(source, event);
- } else {
- //either a function or a string can be passed in case of a string we have to wrap it into another function
- retVal = new Function("event", arguments[loop]).call(source, event);
- }
- //now if one function returns false in between we stop the execution of the cycle
- //here, note we do a strong comparison here to avoid constructs like 'false' or null triggering
- if ('undefined' != typeof retVal && retVal === false) {
- return false;
- }
+ //assertion if event is a function or a string we already are in our function elements
+ //since event either is undefined, null or a valid event object
+
+ if ('function' == typeof event || myfaces._impl._util._Lang.isString(event)) {
+ throw new Error(" an event must be passed down (either a an event object null or undefined) ");
+ }
+
+ for (var loop = 2; loop < len; loop++) {
+ //we do not change the scope of the incoming functions
+ //but we reuse the argument array capabilities of apply
+ var retVal;
+ if ('function' == typeof arguments[loop]) {
+ retVal = arguments[loop].call(source, event);
+ } else {
+ //either a function or a string can be passed in case of a string we have to wrap it into another function
+ retVal = new Function("event", arguments[loop]).call(source, event);
+ }
+ //now if one function returns false in between we stop the execution of the cycle
+ //here, note we do a strong comparison here to avoid constructs like 'false' or null triggering
+ if ('undefined' != typeof retVal && retVal === false) {
+ return false;
}
- return true;
}
- }));
- // singleton
- myfaces.ajax = new myfaces._impl.core._jsfImpl();
-}
+ return true;
+
+ }
+});
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=944216&r1=944215&r2=944216&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 Fri May 14 12:06:56 2010
@@ -49,9 +49,9 @@ myfaces._impl.core._Runtime.extendClass(
this.m_queuesize = context.myfaces.queuesize;
}
if (_Runtime.getLocalOrGlobalConfig(context, "pps", null) != null
- && _Lang.exists(passThrough, myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE)
- && passThrough[myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE].length > 0) {
- this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl.prototype._PROP_EXECUTE].split(" ");
+ && _Lang.exists(passThrough, myfaces._impl.core._jsfImpl._PROP_EXECUTE)
+ && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].length > 0) {
+ this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].split(" ");
}
if (_Runtime.getLocalOrGlobalConfig(context, "timeout", null) != null) {
this.m_timeout = context.myfaces.timeout;
@@ -88,8 +88,8 @@ myfaces._impl.core._Runtime.extendClass(
this.m_xhr.setRequestHeader("Content-Type", this.m_contentType);
this.m_xhr.setRequestHeader("Faces-Request", "partial/ajax");
this.m_xhr.onreadystatechange = myfaces._impl.xhrCore._AjaxRequestQueue.handleCallback;
-
- myfaces.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_BEGIN);
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+ _Impl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN);
this.m_xhr.send(this.m_requestParameters);
if ('undefined' != typeof this.m_timeout) {
var timeoutId = window.setTimeout(
@@ -118,16 +118,16 @@ myfaces._impl.core._Runtime.extendClass(
var READY_STATE_DONE = 4;
try {
//local namespace remapping
- var jsfAjaxImpl = myfaces.ajax;
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
if (this.m_xhr.readyState == READY_STATE_DONE) {
if (this.m_xhr.status >= 200 && this.m_xhr.status < 300) {
- jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_COMPLETE);
- jsfAjaxImpl.response(this.m_xhr, this.m_context);
- jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_SUCCESS);
+ _Impl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
+ _Impl.response(this.m_xhr, this.m_context);
+ _Impl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_SUCCESS);
myfaces._impl.xhrCore._AjaxRequestQueue.queue.processQueue();
} else {
- jsfAjaxImpl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._AJAX_STAGE_COMPLETE);
+ _Impl.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_COMPLETE);
var errorText;
try {
errorText = "Request failed";
@@ -140,8 +140,8 @@ myfaces._impl.core._Runtime.extendClass(
} catch (e) {
errorText = "Request failed with unknown status";
}
- jsfAjaxImpl.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl.prototype._ERROR_HTTPERROR,
- myfaces._impl.core._jsfImpl.prototype._ERROR_HTTPERROR, errorText);
+ _Impl.sendError(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._ERROR_HTTPERROR,
+ myfaces._impl.core._jsfImpl._ERROR_HTTPERROR, errorText);
}
}
} catch (e) {
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=944216&r1=944215&r2=944216&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Fri May 14 12:06:56 2010
@@ -66,17 +66,20 @@ myfaces._impl.core._Runtime.extendClass(
processResponse : function(request, context) {
try {
var _Lang = myfaces._impl._util._Lang;
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+
// TODO:
// Solution from
// http://www.codingforums.com/archive/index.php/t-47018.html
// to solve IE error 1072896658 when a Java server sends iso88591
// istead of ISO-8859-1
+
if ('undefined' == typeof(request) || null == request) {
throw Exception("jsf.ajaxResponse: The response cannot be null or empty!");
}
if (!_Lang.exists(request, "responseXML")) {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_EMPTY_RESPONSE);
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_EMPTY_RESPONSE);
return;
}
@@ -89,19 +92,19 @@ myfaces._impl.core._Runtime.extendClass(
if ((_Lang.exists(xmlContent,"parseError.errorCode") && xmlContent.parseError.errorCode != 0) || _Lang.equalsIgnoreCase(xmlContent.firstChild.tagName, "parsererror")) {
//TODO improve error name and message sending here
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML);
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
return;
}
var partials = xmlContent.childNodes[0];
if ('undefined' == typeof partials || partials == null) {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML);
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
return;
} else {
if (partials.tagName != this._RESPONSE_PARTIAL) {
// IE 8 sees XML Header as first sibling ...
partials = partials.nextSibling;
if ('undefined' == typeof partials || partials == null || partials.tagName != this._RESPONSE_PARTIAL) {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML);
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
return;
}
}
@@ -187,7 +190,9 @@ myfaces._impl.core._Runtime.extendClass(
if ('undefined' == typeof errorMessage || null == errorMessage) {
errorMessage = "";
}
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_SERVER_ERROR, errorName, errorMessage);
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_SERVER_ERROR, errorName, errorMessage);
},
processRedirect : function(request, context, node) {
@@ -196,7 +201,9 @@ myfaces._impl.core._Runtime.extendClass(
*/
var redirectUrl = node.getAttribute("url");
if ('undefined' == typeof redirectUrl || null == redirectUrl) {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Redirect without url");
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Redirect without url");
return false;
}
redirectUrl = myfaces._impl._util._Lang.trim(redirectUrl);
@@ -244,7 +251,9 @@ myfaces._impl.core._Runtime.extendClass(
//you have to insert it here
// this._responseHandler.doExtension(childNode);
} else {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_MALFORMEDXML);
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
return false;
}
}
@@ -326,7 +335,7 @@ myfaces._impl.core._Runtime.extendClass(
var _Dom = myfaces._impl._util._Dom;
- var parser = myfaces.ajax._impl = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+ var parser = new (myfaces._impl.core._Runtime.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
var oldBody = document.getElementsByTagName("body")[0];
var newBody = document.createElement("body");
@@ -404,7 +413,7 @@ myfaces._impl.core._Runtime.extendClass(
/*remapping global namespaces for speed and readability reasons*/
var _Lang = myfaces._impl._util._Lang;
var _Dom = myfaces._impl._util._Dom;
- var _JSFImpl = myfaces._impl.core._jsfImpl;
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
var insertId = node.getAttribute('id');
@@ -416,11 +425,11 @@ myfaces._impl.core._Runtime.extendClass(
var afterSet = 'undefined' != typeof afterId && null != afterId &&_Lang.trim(afterId) != "";
if (!insertSet) {
- myfaces.ajax.sendError(request, context, _JSFImpl.prototype._ERROR_MALFORMEDXML, _JSFImpl.prototype._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
+ _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
return false;
}
if (!(beforeSet || afterSet)) {
- myfaces.ajax.sendError(request, context, _JSFImpl.prototype._ERROR_MALFORMEDXML, _JSFImpl.prototype._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
+ _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
return false;
}
//either before or after but not two at the same time
@@ -433,7 +442,7 @@ myfaces._impl.core._Runtime.extendClass(
beforeId =_Lang.trim(beforeId);
var beforeNode = document.getElementById(beforeId);
if ('undefined' == typeof beforeNode || null == beforeNode) {
- myfaces.ajax.sendError(request, context, _JSFImpl.prototype._ERROR_MALFORMEDXML, _JSFImpl.prototype._ERROR_MALFORMEDXML, "Error in PPR Insert, before node of id " + beforeId + " does not exist in document");
+ _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, before node of id " + beforeId + " does not exist in document");
return false;
}
/**
@@ -457,7 +466,7 @@ myfaces._impl.core._Runtime.extendClass(
afterId =_Lang.trim(afterId);
var afterNode = document.getElementById(afterId);
if ('undefined' == typeof afterNode || null == afterNode) {
- myfaces.ajax.sendError(request, context, _JSFImpl.prototype._ERROR_MALFORMEDXML, _JSFImpl.prototype._ERROR_MALFORMEDXML, "Error in PPR Insert, after node of id " + after + " does not exist in document");
+ _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML, _Impl._ERROR_MALFORMEDXML, "Error in PPR Insert, after node of id " + after + " does not exist in document");
return false;
}
@@ -477,13 +486,13 @@ myfaces._impl.core._Runtime.extendClass(
},
processDelete : function(request, context, node) {
- var _JSFImpl = myfaces._impl.core._jsfImpl;
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
var _Dom = myfaces._impl._util._Dom;
var deleteId = node.getAttribute('id');
if ('undefined' == typeof deleteId || null == deleteId) {
- myfaces.ajax.sendError(request, context, _JSFImpl.prototype._ERROR_MALFORMEDXML,
- _JSFImpl.prototype._ERROR_MALFORMEDXML, "Error in delete, id not in xml markup");
+ _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML,
+ _Impl._ERROR_MALFORMEDXML, "Error in delete, id not in xml markup");
return false;
}
@@ -499,13 +508,13 @@ myfaces._impl.core._Runtime.extendClass(
//myfaces._impl._util._Dom.setAttribute(domNode, attribute, value;
var _Dom = myfaces._impl._util._Dom;
- var _JSFImpl = myfaces._impl.core._jsfImpl;
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
//<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes>
var elementId = node.getAttribute('id');
if ('undefined' == typeof elementId || null == elementId) {
- myfaces.ajax.sendError(request, context, _JSFImpl.prototype._ERROR_MALFORMEDXML
- , _JSFImpl.prototype._ERROR_MALFORMEDXML, "Error in attributes, id not in xml markup");
+ _Impl.sendError(request, context, _Impl._ERROR_MALFORMEDXML
+ , _Impl._ERROR_MALFORMEDXML, "Error in attributes, id not in xml markup");
return false;
}
var childNodes = node.childNodes;
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js?rev=944216&r1=944215&r2=944216&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxUtils.js Fri May 14 12:06:56 2010
@@ -94,7 +94,7 @@ myfaces._impl.core._Runtime.extendClass(
if (insideSubmittedPart
|| isPartialSubmitContainer
|| (elementName != null
- && elementName == myfaces._impl.core._jsfImpl.prototype._PROP_VIEWSTATE)) {
+ && elementName == myfaces._impl.core._jsfImpl._PROP_VIEWSTATE)) {
// node required for PPS
this.addField(child, stringBuffer);
if (insideSubmittedPart || isPartialSubmitContainer) {
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js?rev=944216&r1=944215&r2=944216&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_Exception.js Fri May 14 12:06:56 2010
@@ -29,7 +29,8 @@ myfaces._impl.core._Runtime.extendClass(
*/
throwError : function(request, context, func, exception) {
if (this.m_threshold == "ERROR") {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_CLIENT_ERROR, exception.name,
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR, exception.name,
"MyFaces ERROR\n"
+ "Affected Class: " + this.m_class + "\n"
+ "Affected Method: " + func + "\n"
@@ -50,7 +51,8 @@ myfaces._impl.core._Runtime.extendClass(
*/
throwWarning : function(request, context, func, message) {
if (this.m_threshold == "WARNING" || this.m_threshold == "ERROR") {
- myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl.prototype._ERROR_CLIENT_ERROR, exception.name,
+ var _Impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl);
+ _Impl.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_CLIENT_ERROR, exception.name,
"MyFaces WARNING\n[" + this.m_class + "::" + func + "]\n\n"
+ message);
}