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/08/31 12:58:33 UTC

svn commit: r991153 - in /myfaces/core/trunk/api/src/main: javascript/META-INF/resources/myfaces/_impl/_util/ javascript/META-INF/resources/myfaces/_impl/core/ javascript/META-INF/resources/myfaces/_impl/xhrCore/ resources/META-INF/licenses/

Author: werpu
Date: Tue Aug 31 10:58:32 2010
New Revision: 991153

URL: http://svn.apache.org/viewvc?rev=991153&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2902 
* removal of the affected code in iframerequest and replace it with better working code

https://issues.apache.org/jira/browse/MYFACES-2458 following bugs fixed:
* Possible issue with <f:ajax> execute="multiple ids". Seems the javax.faces.partial.execute request param may differ from Sun RI
* Function _Lang.getEventTarget(...) fails to find form if event is one of ajax events (e.g. 'error'). In this case event contains 'source' property, but 'srcElement' or 'target' is checked 
* If calling jsf.ajax.request() directly and no options map is specified, the XHR call never occurs because the options map evaluates to undefined. 

Removed:
    myfaces/core/trunk/api/src/main/resources/META-INF/licenses/yui-LICENSE.TXT
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/_Lang.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/_IFrameRequest.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=991153&r1=991152&r2=991153&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 Tue Aug 31 10:58:32 2010
@@ -456,15 +456,15 @@ myfaces._impl.core._Runtime.singletonExt
      * @param evalNodes
      */
     replaceElement: function(item, evalNode) {
-        var _Browser = this._RT.browser;
-        if (!_Browser.isIE || _Browser.isIE >= 8) {
+      //  var _Browser = this._RT.browser;
+      //  if (!_Browser.isIE || _Browser.isIE >= 8) {
             //standards conform no leaking browser
             item.parentNode.replaceChild(evalNode, item);
-        } else {
+      // } else {
             //browsers with defect garbage collection
-            item.parentNode.insertBefore(evalNode, item);
+      //       item.parentNode.insertBefore(evalNode, item);
             this._removeNode(item, false);
-        }
+      //  }
     },
 
 

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=991153&r1=991152&r2=991153&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 Tue Aug 31 10:58:32 2010
@@ -83,7 +83,16 @@ myfaces._impl.core._Runtime.singletonDel
     getEventTarget: function(evt) {
         //ie6 and 7 fallback
         evt = (!evt) ? window.event || {} : evt;
-        var t = (evt.srcElement ? evt.srcElement : (evt.target ? evt.target : null));
+       /**
+        * evt source is defined in the jsf events
+        * seems like some component authors use our code
+        * so we add it here see also
+        * https://issues.apache.org/jira/browse/MYFACES-2458
+        * not entirely a bug but makes sense to add this
+        * behavior. I dont use it that way but nevertheless it
+        * does not break anything so why not
+        * */
+        var t = evt.srcElement || evt.target  || evt.source || null;
         while ((t) && (t.nodeType != 1)) {
             t = t.parentNode;
         }

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=991153&r1=991152&r2=991153&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 Tue Aug 31 10:58:32 2010
@@ -118,6 +118,9 @@ myfaces._impl.core._Runtime.singletonExt
      */
     request : function(elem, event, options) {
 
+        //options not set we define a default one with nothing
+        options = 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
@@ -125,7 +128,8 @@ myfaces._impl.core._Runtime.singletonExt
         var _Lang = this._Lang;
         var _Dom = myfaces._impl._util._Dom;
 
-        var elementId = null;
+        //blank to avoid errors in case nothing is determinable
+        var elementId = "";
 
 
         /**
@@ -249,7 +253,8 @@ myfaces._impl.core._Runtime.singletonExt
        try {
             if (passThrgh.execute) {
                 /*the options must be a blank delimited list of strings*/
-                transformList(this.P_EXECUTE, passThrgh.execute, true);
+                /*compliance with Mojarra which automatically adds @this to an execute*/
+                transformList(this.P_EXECUTE, passThrgh.execute+ " @this", true);
                 passThrgh.execute = null;
                 /*remap just in case we have a valid pointer to an existing object*/
                 delete passThrgh.execute;

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js?rev=991153&r1=991152&r2=991153&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_IFrameRequest.js Tue Aug 31 10:58:32 2010
@@ -111,7 +111,6 @@ myfaces._impl.core._Runtime.extendClass(
         //via our xml parser
         var request = {};
         try {
-            //Derived from the YUI library, looking this up saved me some time
             request.responseText = this._getFrameText();
             request.responseXML = this._getFrameXml();
             request.readyState = this._READY_STATE_DONE;
@@ -129,9 +128,8 @@ myfaces._impl.core._Runtime.extendClass(
             //_onError
             this._onException(null, this._context, this.CLS_NAME, "constructor", e);
         } finally {
-            //this closes any hanging or pedning comm channel caused by the iframe
-            //this._frame.src = "about:blank";
-            this._setFrameText("");
+            //this closes any hanging or pending comm channel caused by the iframe
+            this._clearFrame();
             this._frame = null;
         }
     },
@@ -139,27 +137,36 @@ myfaces._impl.core._Runtime.extendClass(
     /**
      * returns the frame text in a browser independend manner
      */
+    _getFrameDocument: function() {
+      //we cover various browsers here, because almost all browsers keep the document in a different
+      //position
+      return this._frame.contentWindow.document || this._frame.contentDocument || this._frame.document  ;
+    },
+
     _getFrameText: function() {
-        var doc = this._frame.contentWindow.document;
-        return doc.body ? doc.body.innerHTML : doc.documentElement.textContent;
+        var framedoc = this._getFrameDocument();
+        //also ie keeps the body in framedoc.body the rest in documentElement
+        var body = framedoc.body || framedoc.documentElement ;
+        return  body.innerHTML;
     },
 
-    /**
-     * sets the frame text in a browser independend manner
-     *
-     * @param text to be set
-     */
-    _setFrameText: function(text) {
-        var doc = this._frame.contentWindow.document;
-        doc.body ? (doc.body.innerHTML = text) : (doc.documentElement.textContent = text);
+    _clearFrame: function() {
+        var framedoc = this._getFrameDocument();
+        var body = framedoc.documentElement || framedoc.body;
+        //ie8 in 7 mode chokes on the innerHTML method
+        //direct dom removal is less flakey and works
+        //over all browsers, but is slower
+        this._Dom.removeChildNodes(body, false);
     },
 
     /**
      * returns the processed xml from the frame
      */
     _getFrameXml: function() {
-        var doc = this._frame.contentWindow.document;
-        return doc.XMLDocument ? doc.XMLDocument : doc;
+        var framedoc = this._getFrameDocument();
+        //same situation here, the xml is hosted either in xmlDocument or
+        //is located directly under the frame document
+        return  framedoc.XMLDocument ||  framedoc;
     },