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 2011/11/25 13:12:08 UTC
svn commit: r1206133 [1/2] - in
/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl:
_util/ core/ xhrCore/
Author: werpu
Date: Fri Nov 25 12:12:07 2011
New Revision: 1206133
URL: http://svn.apache.org/viewvc?rev=1206133&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-3407
Modified:
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtDom.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js
myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js
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/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
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js?rev=1206133&r1=1206132&r2=1206133&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Dom.js Fri Nov 25 12:12:07 2011
@@ -273,7 +273,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object,
deleteItem: function(itemIdToReplace) {
var item = this.byId(itemIdToReplace);
if (!item) {
- throw Error("_Dom.deleteItem Unknown Html-Component-ID: " + itemIdToReplace);
+ throw this._Lang.makeException(null, null, this._nameSpace, "deleteItem", "_Dom.deleteItem Unknown Html-Component-ID: " + itemIdToReplace);
}
this._removeNode(item, false);
@@ -545,16 +545,18 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object,
*/
_assertStdParams: function(item, markup, caller, params) {
//internal error
- if (!caller) throw Error("Caller must be set for assertion");
+ if (!caller) {
+ throw this._Lang.makeException(null, null, this._nameSpace, "_assertStdParams", "Caller must be set for assertion");
+ }
var _Lang = this._Lang,
ERR_PROV = "ERR_MUST_BE_PROVIDED1",
DOM = "myfaces._impl._util._Dom.",
finalParams = params || ["item", "markup"];
if (!item || !markup) {
- throw Error(_Lang.getMessage(ERR_PROV, null, DOM + caller, (!item) ? params[0] : params[1]));
+ _Lang.makeException(null, null,DOM, ""+caller, _Lang.getMessage(ERR_PROV, null, DOM +"."+ caller, (!item) ? params[0] : params[1]));
+ //throw Error(_Lang.getMessage(ERR_PROV, null, DOM + caller, (!item) ? params[0] : params[1]));
}
-
},
/**
@@ -602,7 +604,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object,
replaceElements: function (item, evalNodes) {
var evalNodesDefined = evalNodes && 'undefined' != typeof evalNodes.length;
if (!evalNodesDefined) {
- throw new Error(this._Lang.getMessage("ERR_REPLACE_EL"));
+ throw this._Lang.makeException(null, null, this._nameSpace, "replaceElements", this._Lang.getMessage("ERR_REPLACE_EL"));
}
var parentNode = item.parentNode,
@@ -701,8 +703,6 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object,
return ret;
},
-
-
/**
* a filtered findAll for subdom treewalking
* (which uses browser optimizations wherever possible)
@@ -888,7 +888,8 @@ _MF_SINGLTN(_PFX_UTIL + "_Dom", Object,
getParent : function(item, tagName) {
if (!item) {
- throw Error(this._Lang.getMessage("ERR_MUST_BE_PROVIDED1", null, "_Dom.getParent", "item {DomNode}"));
+ throw this._Lang.makeException(null, null, this._nameSpace, "getParent",
+ this._Lang.getMessage("ERR_MUST_BE_PROVIDED1", null, "_Dom.getParent", "item {DomNode}"));
}
var _Lang = this._Lang;
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtDom.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtDom.js?rev=1206133&r1=1206132&r2=1206133&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtDom.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtDom.js Fri Nov 25 12:12:07 2011
@@ -114,7 +114,7 @@ _MF_SINGLTN && _MF_SINGLTN(_PFX_UTIL + "
*/
getElementFromForm : function(nameId, form, nameSearch, localOnly) {
if (!nameId) {
- throw Error("_Dom.getElementFromForm an item id or name must be given");
+ throw this._Lang.makeException(null, null, this._nameSpace,"getElementFromForm", "_Dom.getElementFromForm an item id or name must be given");
}
if (!form) {
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js?rev=1206133&r1=1206132&r2=1206133&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Lang.js Fri Nov 25 12:12:07 2011
@@ -81,13 +81,10 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
this._installedLocale = new newLocale();
return;
}
- var language_Variant = this._RT.getLanguage(this._RT.getGlobalConfig("locale"));
- var langStr = language_Variant ? language_Variant.language : "";
- var variantStr = language_Variant ? [language_Variant.language,"_",language_Variant.variant || ""].join("") : "";
- var i18nRoot = myfaces._impl.i18n;
- var i18nHolder = i18nRoot["Messages_" + variantStr] ||
- i18nRoot["Messages_" + langStr] ||
- i18nRoot["Messages"];
+ var language_Variant = this._RT.getLanguage(this._RT.getGlobalConfig("locale")),
+ langStr = language_Variant ? language_Variant.language : "",
+ variantStr = language_Variant ? [language_Variant.language,"_",language_Variant.variant || ""].join("") : "",
+ i18nRoot = myfaces._impl.i18n, i18nHolder = i18nRoot["Messages_" + variantStr] || i18nRoot["Messages_" + langStr] || i18nRoot["Messages"];
this._installedLocale = new i18nHolder();
},
assertType: function(probe, theType) {
@@ -96,19 +93,6 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
exists: function(nms, theType) {
return this._RT.exists(nms, theType);
},
- isExceptionProcessed: function(e) {
- return !! this._processedExceptions[e.toString()];
- },
- setExceptionProcessed: function(e) {
- this._processedExceptions[e.toString()] = true;
- },
- clearExceptionProcessed: function() {
- //ie again
- for (var key in this._processedExceptions) {
- this._processedExceptions[key] = null;
- }
- this._processedExceptions = {};
- },
fetchNamespace : function(namespace) {
this._assertStr(namespace, "fetchNamespace", "namespace");
return this._RT.fetchNamespace(namespace);
@@ -209,7 +193,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
*/
byId : function(/*object*/ reference) {
if (!reference) {
- throw Error(this.getMessage("ERR_REF_OR_ID", null, "_Lang.byId", "reference"));
+ throw this.makeException(null, null, this._nameSpace, "byId", this.getMessage("ERR_REF_OR_ID", null, "_Lang.byId", "reference"));
}
return (this.isString(reference)) ? document.getElementById(reference) : reference;
},
@@ -234,7 +218,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
// Return true if it is a String
this._assertStr(it, "strToArray", "it");
if (!splitter) {
- throw Error(this.getMessage("ERR_PARAM_STR_RE", null, "myfaces._impl._util._Lang.strToArray", "splitter"));
+ throw this.makeException(null, null, this._nameSpace, "strToArray", this.getMessage("ERR_PARAM_STR_RE", null, "myfaces._impl._util._Lang.strToArray", "splitter"));
}
var retArr = it.split(splitter);
var len = retArr.length;
@@ -245,7 +229,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
},
_assertStr: function(it, functionName, paramName) {
if (!this.isString(it)) {
- throw Error(this.getMessage("ERR_PARAM_STR", null, "myfaces._impl._util._Lang." + functionName, paramName));
+ throw this.makeException(null, null, this._nameSpace, arguments.caller.toString(), this.getMessage("ERR_PARAM_STR", null, "myfaces._impl._util._Lang." + functionName, paramName));
}
},
/**
@@ -301,7 +285,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
**/
mixMaps: function(dest, src, overwrite, blockFilter, whitelistFilter) {
if (!dest || !src) {
- throw Error(this.getMessage("ERR_PARAM_MIXMAPS", null, "_Lang.mixMaps"));
+ throw this.makeException(null, null, this._nameSpace, "mixMaps", this.getMessage("ERR_PARAM_MIXMAPS", null, "_Lang.mixMaps"));
}
var _undef = "undefined";
for (var key in src) {
@@ -331,7 +315,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
*/
contains : function(arr, str) {
if (!arr || !str) {
- throw Error(this.getMessage("ERR_MUST_BE_PROVIDED", null, "_Lang.contains", "arr {array}", "str {string}"));
+ throw this.makeException(null, null, this._nameSpace, "contains", this.getMessage("ERR_MUST_BE_PROVIDED", null, "_Lang.contains", "arr {array}", "str {string}"));
}
return this.arrIndexOf(arr, str) != -1;
},
@@ -501,7 +485,7 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
pushRet(key);
pushRet(val);
delimiter = delimiter || "\n";
- pushRet(delimiter);
+ pushRet(delimiter);
return ret.join("");
},
parseXML: function(txt) {
@@ -665,10 +649,31 @@ _MF_SINGLTN(_PFX_UTIL + "_Lang", Object,
if (finalAttr) {
return applyAttr(obj, finalAttr, value, true);
}
- throw Error("property " + name + " not found");
+
+ throw this.makeException(null, null, this._nameSpace, "contains", "property " + name + " not found");
} finally {
findAccessor = null;
applyAttr = null;
}
+ },
+
+ /**
+ * creates an exeption with additional internal parameters
+ * for extra information
+ *
+ * @param {String} title the exception title
+ * @param {String} name the exception name
+ * @param {String} callerCls the caller class
+ * @param {String} callFunc the caller function
+ * @param {String} message the message for the exception
+ */
+ makeException: function(title, name, callerCls, callFunc, message) {
+ var ret = new Error(message || "");
+ ret._mfInternal = {};
+ ret._mfInternal.name = name ||"clientError";
+ ret._mfInternal.title = title ||"clientError";
+ ret._mfInternal.caller = callerCls ||this._nameSpace;
+ ret._mfInternal.callFunc = callFunc ||(""+arguments.caller.toString());
+ return ret;
}
});
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js?rev=1206133&r1=1206132&r2=1206133&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_LangQuirks.js Fri Nov 25 12:12:07 2011
@@ -221,7 +221,7 @@ _MF_SINGLTN(_PFX_UTIL+"_LangQuirks", myf
*/
arrToString : function(/*String or array*/ arr, /*string*/ delimiter) {
if (!arr) {
- throw Error(this.getMessage("ERR_MUST_BE_PROVIDED1",null, "arr {array}"));
+ throw this._Lang.makeException(null, null, this._nameSpace,"arrToString", this.getMessage("ERR_MUST_BE_PROVIDED1",null, "arr {array}"));
}
if (this.isString(arr)) {
return arr;
Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js?rev=1206133&r1=1206132&r2=1206133&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ListenerQueue.js Fri Nov 25 12:12:07 2011
@@ -43,7 +43,7 @@ _MF_CLS(_PFX_UTIL+"_ListenerQueue", myfa
_assertListener : function( listener) {
if ("function" != typeof (listener)) {
var msg = myfaces._impl._util._Lang.getMessage("ERR_PARAM_GENERIC",null,"_ListenerQueue", arguments.caller.toString(),"function" );
- throw Error(msg);
+ throw this._Lang.makeException(null, null, this._nameSpace,arguments.caller.toString(), msg);
}
},
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=1206133&r1=1206132&r2=1206133&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 Fri Nov 25 12:12:07 2011
@@ -108,7 +108,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
var ajaxUtils = myfaces._impl.xhrCore._AjaxUtils;
var ret = this._Lang.createFormDataDecorator([]);
- ajaxUtils.encodeSubmittableFields(ret, form, null);
+ ajaxUtils.encodeSubmittableFields(ret, form, null);
return ret.makeFinal();
},
@@ -146,8 +146,8 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
*all the time
**/
var _Lang = this._Lang,
- _Dom = this._Dom,
- WINDOW_ID = "javax.faces.windowId";
+ _Dom = this._Dom,
+ WINDOW_ID = "javax.faces.windowId";
/*assert if the onerror is set and once if it is set it must be of type function*/
_Lang.assertType(options.onerror, "function");
/*assert if the onevent is set and once if it is set it must be of type function*/
@@ -156,11 +156,11 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
//options not set we define a default one with nothing
options = options || {};
- /*preparations for jsf 2.2 windowid handling*/
+ /*preparations for jsf 2.2 windowid handling*/
//pass the window id into the options if not set already
- if(!options.windowId) {
+ if (!options.windowId) {
var windowId = _Dom.getWindowId();
- (windowId) ? options[WINDOW_ID] = windowId: null;
+ (windowId) ? options[WINDOW_ID] = windowId : null;
} else {
options[WINDOW_ID] = options.windowId;
delete options.windowId;
@@ -208,8 +208,8 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
* so that people can use dummy forms and work
* with detached objects
*/
- var form = (options.myfaces && options.myfaces.form)?
- _Lang.byId(options.myfaces.form):
+ var form = (options.myfaces && options.myfaces.form) ?
+ _Lang.byId(options.myfaces.form) :
this._getForm(elem, event);
/**
@@ -255,9 +255,9 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
context._mfInternal = {};
var mfInternal = context._mfInternal;
- mfInternal["_mfSourceFormId"] = form.id;
- mfInternal["_mfSourceControlId"] = elementId;
- mfInternal["_mfTransportType"] = transportType;
+ mfInternal["_mfSourceFormId"] = form.id;
+ mfInternal["_mfSourceControlId"] = elementId;
+ mfInternal["_mfTransportType"] = transportType;
//mojarra compatibility, mojarra is sending the form id as well
//this is not documented behavior but can be determined by running
@@ -270,10 +270,10 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
//make it into jsf 2.2
/* jsf2.2 only: options.delay || */
var delayTimeout = this._RT.getLocalOrGlobalConfig(context, "delay", false);
- if(delayTimeout) {
- this._delayTimeout = setTimeout(_Lang.hitch(this, function(){
- this._transport[transportType](elem, form, context, passThrgh);
- } ), delayTimeout);
+ if (delayTimeout) {
+ this._delayTimeout = setTimeout(_Lang.hitch(this, function() {
+ this._transport[transportType](elem, form, context, passThrgh);
+ }), delayTimeout);
} else {
this._transport[transportType](elem, form, context, passThrgh);
}
@@ -287,18 +287,19 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
* @param event
*/
_getForm: function(elem, event) {
- var _Dom = this._Dom;
+ var _Dom = this._Dom;
var _Lang = this._Lang;
- var form = _Dom.fuzzyFormDetection(elem);
+ var form = _Dom.fuzzyFormDetection(elem);
if (!form && event) {
//in case of no form is given we retry over the issuing event
form = _Dom.fuzzyFormDetection(_Lang.getEventTarget(event));
if (!form) {
- throw Error(_Lang.getMessage("ERR_FORM"));
+ throw this._Lang.makeException(null, null, this._nameSpace, "_getForm", _Lang.getMessage("ERR_FORM"));
}
} else if (!form) {
- throw Error(_Lang.getMessage("ERR_FORM"));
+ throw this._Lang.makeException(null, null, this._nameSpace, "_getForm", _Lang.getMessage("ERR_FORM"));
+
}
return form;
},
@@ -317,11 +318,11 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
* we have to pass them down as a blank delimited string representation
* of an array of ids!
*/
- //for now we turn off the transport auto selection, to enable 2.0 backwards compatibility
- //on protocol level, the file upload only can be turned on if the auto selection is set to true
+ //for now we turn off the transport auto selection, to enable 2.0 backwards compatibility
+ //on protocol level, the file upload only can be turned on if the auto selection is set to true
var getConfig = this._RT.getLocalOrGlobalConfig,
- _Lang = this._Lang,
- _Dom = this._Dom;
+ _Lang = this._Lang,
+ _Dom = this._Dom;
var transportAutoSelection = getConfig(context, "transportAutoSelection", false);
var isMultipart = (transportAutoSelection && _Dom.getAttribute(form, "enctype") == "multipart/form-data") ?
@@ -345,7 +346,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
getConfig(context, "transportType", "multipartQueuedPost");
if (!this._transport[transportType]) {
//throw new Error("Transport type " + transportType + " does not exist");
- throw new Error(_Lang.getMessage("ERR_TRANSPORT",null, transportType));
+ throw new Error(_Lang.getMessage("ERR_TRANSPORT", null, transportType));
}
return transportType;
@@ -370,12 +371,12 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
//the offset variable is there to prevent 0 which results in a javascript
//false
var offset = 1,
- vals = (srcStr) ? srcStr.split(/\s+/) : [],
+ vals = (srcStr) ? srcStr.split(/\s+/) : [],
idIdx = (vals.length) ? _Lang.arrToMap(vals, offset) : {},
- //helpers to improve speed and compression
- none = idIdx[this.IDENT_NONE],
- all = idIdx[this.IDENT_ALL],
+ //helpers to improve speed and compression
+ none = idIdx[this.IDENT_NONE],
+ all = idIdx[this.IDENT_ALL],
theThis = idIdx[this.IDENT_THIS],
theForm = idIdx[this.IDENT_FORM];
@@ -445,21 +446,19 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
return (name && name === myfaces._impl.core.Impl.MALFORMEDXML) ? _Lang.getMessage("ERR_MALFORMEDXML") : "";
};
-
-
//by setting unknown values to unknown we can handle cases
//better where a simulated context is pushed into the system
eventData.type = this.ERROR;
- eventData.status = name || UNKNOWN;
- eventData.serverErrorName = serverErrorName || UNKNOWN;
- eventData.serverErrorMessage = serverErrorMessage || UNKNOWN;
+ eventData.status = name || UNKNOWN;
+ eventData.serverErrorName = serverErrorName || UNKNOWN;
+ eventData.serverErrorMessage = serverErrorMessage || UNKNOWN;
try {
- eventData.source = context.source || UNKNOWN;
- eventData.responseCode = request.status || UNKNOWN;
- eventData.responseText = request.responseText || UNKNOWN;
- eventData.responseXML = request.responseXML || UNKNOWN;
+ eventData.source = context.source || UNKNOWN;
+ eventData.responseCode = request.status || UNKNOWN;
+ eventData.responseText = request.responseText || UNKNOWN;
+ eventData.responseXML = request.responseXML || UNKNOWN;
} catch (e) {
// silently ignore: user can find out by examining the event data
}
@@ -474,24 +473,22 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
if (jsf.getProjectStage() === "Development" && this._errListeners.length() == 0 && !context["onerror"]) {
var defaultErrorOutput = myfaces._impl.core._Runtime.getGlobalConfig("defaultErrorOutput", alert),
- finalMessage = [],
+ finalMessage = [],
//we remap the function to achieve a better compressability
- finalMessagePush = _Lang.hitch(finalMessage, finalMessage.push);
+ finalMessagePush = _Lang.hitch(finalMessage, finalMessage.push);
finalMessagePush((name) ? name : "");
- if (name)
- {
+ if (name) {
finalMessagePush(": ");
}
finalMessagePush((serverErrorName) ? serverErrorName : "");
- if (serverErrorName)
- {
+ if (serverErrorName) {
finalMessagePush(" ");
}
finalMessagePush((serverErrorMessage) ? serverErrorMessage : "");
finalMessagePush(malFormedMessage());
finalMessagePush("\n\n");
- finalMessagePush( _Lang.getMessage("MSG_DEV_MODE"));
+ finalMessagePush(_Lang.getMessage("MSG_DEV_MODE"));
defaultErrorOutput(finalMessage.join(""));
}
},
@@ -509,7 +506,6 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
eventData.status = name;
eventData.source = context.source;
-
if (name !== this.BEGIN) {
try {
@@ -524,7 +520,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
eventData.responseCode = getValue(request, "status");
eventData.responseText = getValue(request, "responseText");
- eventData.responseXML = getValue(request, "responseXML");
+ eventData.responseXML = getValue(request, "responseXML");
} catch (e) {
var impl = myfaces._impl.core._Runtime.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core.Impl);
@@ -566,16 +562,16 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
getProjectStage : function() {
//since impl is a singleton we only have to do it once at first access
if(!this._projectStage) {
- var PRJ_STAGE = "projectStage",
- STG_PROD = "Production",
+ var PRJ_STAGE = "projectStage",
+ STG_PROD = "Production",
- scriptTags = document.getElementsByTagName("script"),
- getConfig = myfaces._impl.core._Runtime.getGlobalConfig,
- projectStage = null,
- found = false,
- allowedProjectStages = {STG_PROD:1,"Development":1, "SystemTest":1,"UnitTest":1};
+ scriptTags = document.getElementsByTagName("script"),
+ getConfig = myfaces._impl.core._Runtime.getGlobalConfig,
+ projectStage = null,
+ found = false,
+ allowedProjectStages = {STG_PROD:1,"Development":1, "SystemTest":1,"UnitTest":1};
- /* run through all script tags and try to find the one that includes jsf.js */
+ /* run through all script tags and try to find the one that includes jsf.js */
for (var i = 0; i < scriptTags.length && !found; i++) {
if (scriptTags[i].src.search(/\/javax\.faces\.resource\/jsf\.js.*ln=javax\.faces/) != -1) {
var result = scriptTags[i].src.match(/stage=([^&;]*)/);
@@ -619,7 +615,7 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
* but can be undefined
*/
chain : function(source, event) {
- var len = arguments.length;
+ var len = arguments.length;
var _Lang = this._Lang;
var throwErr = function(msgKey) {
throw Error(_Lang.getMessage(msgKey));
@@ -642,7 +638,6 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
//assertions source either null or set as dom element:
-
if ('undefined' == typeof source) {
throwErr("ERR_SOURCE_DEF_NULL");
//allowed chain datatypes
@@ -690,37 +685,29 @@ _MF_SINGLTN(_PFX_CORE + "Impl", _MF_OBJE
*
* @param request the request currently being processed
* @param context the context affected by this error
- * @param sourceClass the sourceclass throwing the error
- * @param func the function throwing the error
* @param exception the exception being thrown
*/
- stdErrorHandler: function(request, context, sourceClass, func, exception) {
-
- var _Lang = myfaces._impl._util._Lang;
- var exProcessed = _Lang.isExceptionProcessed(exception);
- try {
+ stdErrorHandler: function(request, context, exception) {
//newer browsers do not allow to hold additional values on native objects like exceptions
//we hence capsule it into the request, which is gced automatically
//on ie as well, since the stdErrorHandler usually is called between requests
//this is a valid approach
-
- if (this._threshold == "ERROR" && !exProcessed) {
- this.sendError(request, context, this.CLIENT_ERROR, exception.name,
- "MyFaces ERROR:" + this._Lang.createErrorMsg(sourceClass, func, exception));
- }
- } finally {
-
- //we forward the exception, just in case so that the client
- //will receive it in any way
- try {
- if (!exProcessed) {
- _Lang.setExceptionProcessed(exception);
+ if (this._threshold == "ERROR") {
+ var mfInternal = exception._mfInternal || {};
+ //TODO clean the name mess here
+ var finalMsg = [];
+
+ //extended error message only in dev mode
+ if(jsf.getProjectStage() === "Development") {
+ (mfInternal.caller)? finalMsg.push("Caller: "+mfInternal.caller):null;
+ (mfInternal.callFunc)? finalMsg.push("Caller Function: "+mfInternal.callFunc):null;
}
- } catch(e) {
+ finalMsg.push(exception.message);
+ this.sendError(request, context,
+ mfInternal.title || this.CLIENT_ERROR, mfInternal.name || exception.name, finalMsg.join("\n"));
}
- throw exception;
- }
+
}
});
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=1206133&r1=1206132&r2=1206133&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 Nov 25 12:12:07 2011
@@ -92,15 +92,11 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
try {
this._callSuper("constructor_", args);
- this._onException = this._Lang.hitch(this, this._stdErrorHandler);
- this._onWarn = this._Lang.hitch(this, this._stdErrorHandler);
this._initDefaultFinalizableFields();
delete this._resettableContent["_xhrQueue"];
this.applyArgs(args);
var mfInternal = this._context._mfInternal;
- mfInternal._onException = this._onException;
- mfInternal._onWarning = this._onWarn;
/*namespace remapping for readability*/
//we fetch in the standard arguments
@@ -111,7 +107,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
} catch (e) {
//_onError
- this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "constructor", e);
+ this._stdErrorHandler(this._xhr, this._context, e);
}
},
@@ -152,10 +148,7 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
xhr.timeout = this._timeout || 0;
- var contentType = this._contentType;
- if (this._encoding) {
- contentType = contentType + "; charset:" + this._encoding;
- }
+ var contentType = this._contentType+"; charset=utf-8";
xhr.setRequestHeader(this._CONTENT_TYPE, contentType);
xhr.setRequestHeader(this._HEAD_FACES_REQ, this._VAL_AJAX);
@@ -170,7 +163,8 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
} catch (e) {
//_onError//_onError
- this._onException(this._xhr, this._context, "myfaces._impl.xhrCore._AjaxRequest", "send", e);
+ e = (e._mfInternal)? e: this._Lang.makeException("sendError","sendError", this._nameSpace, "send", e.message);
+ this._stdErrorHandler(this._xhr, this._context, e);
}
},
@@ -197,16 +191,16 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
//a thrown exception best with a message history so
//that we have a message trace
//target 2.1.5
- if (!context._mfInternal.internalError) {
- this._sendEvent("SUCCESS");
- }
+ this._sendEvent("SUCCESS");
+
} catch (e) {
- this._onException(xhr, context, "myfaces._impl.xhrCore._AjaxRequest", "callback", e);
+ this._stdErrorHandler(this._xhr, this._context, e);
}
},
onerror: function(evt) {
-
+ //TODO improve the error code detection here regarding server errors etc...
+ //and push it into our general error handling subframework
var context = this._context;
var xhr = this._xhr;
var _Lang = this._Lang;
@@ -297,11 +291,10 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
* @param func the issuing function
* @param exception the embedded exception
*/
- _stdErrorHandler: function(request, context, sourceClass, func, exception) {
- context._mfInternal.internalError = true;
+ _stdErrorHandler: function(request, context, exception) {
var xhrQueue = this._xhrQueue;
try {
- this.attr("impl").stdErrorHandler(request, context, sourceClass, func, exception);
+ this.attr("impl").stdErrorHandler(request, context, exception);
} finally {
if (xhrQueue) {
xhrQueue.cleanup();
@@ -326,10 +319,6 @@ _MF_CLS(_PFX_XHR + "_AjaxRequest", _MF_O
//cleanup
_finalize: function() {
-
- //final cleanup to terminate everything
- this._Lang.clearExceptionProcessed();
-
if (this._xhr.readyState == this._XHR_CONST.READY_STATE_DONE) {
this._callSuper("_finalize");
}