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 2009/04/23 10:17:48 UTC
svn commit: r767843 - in
/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces:
_impl/_util/_Utils.js _impl/xhrCore/_AjaxRequest.js api/jsf.js
Author: werpu
Date: Thu Apr 23 08:17:47 2009
New Revision: 767843
URL: http://svn.apache.org/viewvc?rev=767843&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2194
https://issues.apache.org/jira/browse/MYFACES-2174
Added config handling methods in the _Utils.js so that
the configs can be read as local or global or a mixed config
Modified:
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js?rev=767843&r1=767842&r2=767843&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js Thu Apr 23 08:17:47 2009
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.10 $ $Date: 2009/04/21 05:53:14 $
+ * Author: Ganesh Jung (latest modification by $Author: werpu $)
+ * Version: $Revision: 1.11 $ $Date: 2009/04/23 08:14:25 $
*
*/
@@ -336,6 +336,47 @@
return result;
};
+
+/**
+ * fetches a global config entry
+ * @param {String} configName the name of the configuration entry
+ * @param {Object} defaultValur
+ *
+ * @return either the config entry or if none is given the default value
+ */
+myfaces._impl._util._Utils.getGlobalConfig = function(configName, defaultValue) {
+ /*use(myfaces._impl._util)*/
+ var _LangUtils = myfaces._impl._util._LangUtils;
+
+ if (_LangUtils.exists(myfaces,"config") && _LangUtils.exists(myfaces.config,configName)) {
+ return myfaces.config[configName];
+ }
+ return defaultValue;
+};
+
+/**
+ * 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
+ *
+ * @return either the config entry or if none is given the default value
+ */
+myfaces._impl._util._Utils.getLocalOrGlobalConfig = function(configName, localOptions, defaultValue) {
+ /*use(myfaces._impl._util)*/
+ var _LangUtils = myfaces._impl._util._LangUtils;
+
+ var globalOption = myfaces._impl._util._Utils.getGlobalConfig(configName, defaultValue);
+ if(!_LangUtils.exists(localOptions, "myfaces") || !_LangUtils.exists(localOptions.myfaces,configName)) {
+ return globalOption;
+ }
+ return localOptions.myfaces[configName];
+};
+
+
/**
* Helper Regexps
*
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js?rev=767843&r1=767842&r2=767843&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxRequest.js Thu Apr 23 08:17:47 2009
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*
- * Author: Ganesh Jung (latest modification by $Author: ganeshpuri $)
- * Version: $Revision: 1.8 $ $Date: 2009/04/19 06:46:13 $
+ * Author: Ganesh Jung (latest modification by $Author: werpu $)
+ * Version: $Revision: 1.9 $ $Date: 2009/04/23 08:14:25 $
*
*/
@@ -28,47 +28,46 @@
* @param {Map} passThough - parameters to pass through to the server (execute/render)
*/
myfaces._impl.xhrCore._AjaxRequest = function(source, sourceForm, context, passThrough) {
- this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", this.alarmThreshold);
- try {
- this.m_contentType = "application/x-www-form-urlencoded";
- this.m_source = source;
- this.m_xhr = null;
+ this.m_exception = new myfaces._impl.xhrCore._Exception("myfaces._impl.xhrCore._AjaxRequest", this.alarmThreshold);
+ try {
+ this.m_contentType = "application/x-www-form-urlencoded";
+ this.m_source = source;
+ this.m_xhr = null;
// myfaces parameters
this.m_partialIdsArray = null;
var errorlevel = 'NONE';
this.m_queuesize = -1;
- if (typeof context != 'undefined'
- && context != null
- && typeof context.myfaces != 'undefined'
- && context.myfaces != null) {
- if (typeof context.myfaces.errorlevel != 'undefined'
- && context.myfaces.errorlevel != null)
- errorlevel = context.myfaces.errorlevel;
- if (typeof context.myfaces.queuesize != 'undefined'
- && context.myfaces.queuesize != null)
- this.m_queuesize = context.myfaces.queuesize;
- if (typeof context.myfaces.pps != 'undefined'
- && context.myfaces.pps
- && typeof passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE] != 'undefined'
- && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE] != null
- && passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].length > 0) {
- this.m_partialIdsArray = passThrough[myfaces._impl.core._jsfImpl._PROP_EXECUTE].split(" ");
- }
+
+ /*namespace remapping for readability*/
+ var _Utils = myfaces._impl._util._Utils;
+ var _LangUtils = myfaces._impl._util._LangUtils;
+
+ if (_Utils.getLocalOrGlobalConfig(context,"errorlevel", null) != null) {
+ errorlevel = context.myfaces.errorlevel;
+ }
+ if (_Utils.getLocalOrGlobalConfig(context,"queuesize", null) != null) {
+ this.m_queuesize = context.myfaces.queuesize;
}
+ if (_Utils.getLocalOrGlobalConfig(context,"pps", null) != null
+ && _LangUtils.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(" ");
+ }
+
this.m_context = context;
- this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
- this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
- this.m_sourceForm = sourceForm;
+ this.m_response = new myfaces._impl.xhrCore._AjaxResponse(errorlevel);
+ this.m_ajaxUtil = new myfaces._impl.xhrCore._AjaxUtils(errorlevel);
+ this.m_sourceForm = sourceForm;
this.m_passThrough = passThrough;
this.m_requestParameters = this.getViewState();
for (var key in this.m_passThrough) {
this.m_requestParameters = this.m_requestParameters +
- "&" + encodeURIComponent(key) +
- "=" + encodeURIComponent(this.m_passThrough[key]);
+ "&" + encodeURIComponent(key) +
+ "=" + encodeURIComponent(this.m_passThrough[key]);
}
- } catch (e) {
- this.m_exception.throwError(null, context, "Ctor", e);
- }
+ } catch (e) {
+ this.m_exception.throwError(null, context, "Ctor", e);
+ }
};
/**
@@ -77,27 +76,27 @@
*/
myfaces._impl.xhrCore._AjaxRequest.prototype.send = function() {
- try {
- if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
- // request object for Internet Explorer
- try {
- this.m_xhr = new ActiveXObject("Msxml2.XMLHTTP");
- } catch (e) {
- this.m_xhr = new ActiveXObject('Microsoft.XMLHTTP');
- }
- } else {
- // request object for standard browser
- this.m_xhr = new XMLHttpRequest();
- }
- this.m_xhr.open("POST", this.m_sourceForm.action, true);
- 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;
+ try {
+ if (myfaces._impl._util._Utils.isUserAgentInternetExplorer()) {
+ // request object for Internet Explorer
+ try {
+ this.m_xhr = new ActiveXObject("Msxml2.XMLHTTP");
+ } catch (e) {
+ this.m_xhr = new ActiveXObject('Microsoft.XMLHTTP');
+ }
+ } else {
+ // request object for standard browser
+ this.m_xhr = new XMLHttpRequest();
+ }
+ this.m_xhr.open("POST", this.m_sourceForm.action, true);
+ 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;
jsf.ajax.sendEvent(this.m_xhr, this.m_context, myfaces._impl.core._jsfImpl._AJAX_STAGE_BEGIN);
- this.m_xhr.send(this.m_requestParameters);
- } catch (e) {
- this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
- }
+ this.m_xhr.send(this.m_requestParameters);
+ } catch (e) {
+ this.m_exception.throwError(this.m_xhr, this.m_context, "send", e);
+ }
};
/**
@@ -121,9 +120,9 @@
+ " and reason " + this.getHtmlStatusText());
}
}
- } catch (e) {
- this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
- }
+ } catch (e) {
+ this.m_exception.throwError(this.m_xhr, this.m_context, "requestCallback", e);
+ }
}
/**
Modified: myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js?rev=767843&r1=767842&r2=767843&view=diff
==============================================================================
--- myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js (original)
+++ myfaces/core/branches/2_0_0/api/src/main/javascript/META-INF/resources/myfaces/api/jsf.js Thu Apr 23 08:17:47 2009
@@ -46,15 +46,8 @@
/*
myfaces.
*/
- if ('undefined' != typeof myfaces.config && null != myfaces.config &&
- 'undefined' != typeof myfaces.config.jsfAjaxImpl && null != myfaces.config.jsfAjaxImpl) {
- jsf.ajax._impl = new myfaces.config.jsfAjaxImpl();
-
- } else {
-
- jsf.ajax._impl = new myfaces._impl.core._jsfImpl();
- }
+ jsf.ajax._impl = new (myfaces._impl._util._Utils.getGlobalConfig("jsfAjaxImpl", myfaces._impl.core._jsfImpl))();
/**
* collect and encode data for a given form element (must be of type form)