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/25 10:39:22 UTC

svn commit: r947961 - /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js

Author: werpu
Date: Tue May 25 08:39:22 2010
New Revision: 947961

URL: http://svn.apache.org/viewvc?rev=947961&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2735


Added:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js

Added: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js?rev=947961&view=auto
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js (added)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_ExtLang.js Tue May 25 08:39:22 2010
@@ -0,0 +1,84 @@
+/**
+ * debugging replacement for lang which adds logging functionality
+ * which is not yet present in the core
+ * this is a full replacement class for myfaces._impl._util._Lang
+ * and replaces the object entirely with
+ * a delegated implementation which adds the new methods to Lang
+ *
+ * We use this class to move some debugging related
+ * lang functions out of the core, which never will
+ * be utilized directly in the core
+ * but will be used externally by extension frameworks
+ * and by unit tests
+ */
+/** @namespace myfaces._impl._util._ExtLang */
+myfaces._impl.core._Runtime.singletonDelegateObj("myfaces._impl._util._ExtLang", myfaces._impl._util._Lang, {
+
+
+    constructor_: function() {
+        //we replace the original one, and since we delegated
+        //we have everything in place
+        myfaces._impl._util._Lang = this;
+    },
+
+    /**
+     * Simple simple logging only triggering at
+     * firebug compatible logging consoles
+     *
+     * note: ;; means the code will be stripped
+     * from the production code by the build system
+     */
+    _log: function(styleClass /*+arguments*/, args) {
+        var logHolder = document.getElementById("myfaces.logging");
+        if (logHolder) {
+            var elem = document.createElement("div");
+            //element.className = styleClass;
+            elem.innerHTML = this.objToArray(arguments, 1).join(" ");
+            logHolder.appendChild(elem);
+        }
+    },
+
+    logLog: function(/*varargs*/) {
+        var argStr = this.objToArray(arguments).join(" ");
+
+        var c = window.console;
+        if (c && c.log) {
+            c.log(argStr);
+        }
+        this._log("logLog", "Log:" + argStr);
+    },
+    logDebug: function(/*varargs*/) {
+        var argStr = this.objToArray(arguments).join(" ");
+        var c = window.console;
+        if (c && c.debug) {
+            c.debug(argStr);
+        }
+        this._log("logDebug", "Debug:" + argStr);
+    },
+    logError: function(/*varargs*/) {
+        var argStr = this.objToArray(arguments).join(" ");
+        var c = window.console;
+        if (c && c.error) {
+            c.error(argStr);
+        }
+        this._log("logError", "Error:" + argStr);
+
+    },
+    logInfo: function(/*varargs*/) {
+        var argStr = this.objToArray(arguments).join(" ");
+        var c = window.console;
+        if (c && c.info) {
+            c.info(argStr);
+        }
+        this._log("logInfo", "Info:" + argStr);
+    },
+    logWarn: function(/*varargs*/) {
+        var argStr = this.objToArray(arguments).join(" ");
+        var c = window.console;
+        if (c && c.warn) {
+            c.warn(argStr);
+        }
+        this._log("logWarn", "Warn:" + argStr);
+    }
+});
+