Author: mgrigorov
Date: Sat Dec 11 09:49:29 2010
New Revision: 1044616

URL: http://svn.apache.org/viewvc?rev=1044616&view=rev
Log:
WICKET-3244 libxml2 splits large CData section. This breaks the processEvaluate 
js

Read text/cdata by iterating over all child nodes

Uses a "static" Wicket._readTextNode() because Wicket.Ajax.Call and 
Wicket.Head.Contributor don't have common parent.

Modified:
    wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: 
wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: 
http://svn.apache.org/viewvc/wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=1044616&r1=1044615&r2=1044616&view=diff
==============================================================================
--- wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js 
(original)
+++ wicket/trunk/wicket/src/main/java/org/apache/wicket/ajax/wicket-ajax.js Sat 
Dec 11 09:49:29 2010
@@ -1329,14 +1329,7 @@ Wicket.Ajax.Call.prototype = {
                steps.push(function(notify) {
                        // get the component id
                        var compId = node.getAttribute("id");
-                       var text="";
-
-                       // get the new component body
-                       if (node.hasChildNodes()) {
-                               for( i=0 ; i < node.childNodes.length; i++ ) {
-                                       text = text + 
node.childNodes[i].nodeValue;
-                               }
-                       }
+                       var text= Wicket._readTextNode(node);
                         
                        // if the text was escaped, unascape it
                        // (escaping is done when the component body contains a 
CDATA section)
@@ -1363,7 +1356,7 @@ Wicket.Ajax.Call.prototype = {
        processEvaluation: function(steps, node) {
                steps.push(function(notify) {
                        // get the javascript body
-                   var text = node.firstChild.nodeValue;
+                   var text = Wicket._readTextNode(node);
                    
                    // unescape it if necessary
                    var encoding = node.getAttribute("encoding");
@@ -1410,7 +1403,7 @@ Wicket.Ajax.Call.prototype = {
 
        // Adds a closure that processes a redirect
        processRedirect: function(steps, node) {
-               var text = node.firstChild.nodeValue;
+               var text = Wicket._readTextNode(node);
                Wicket.Log.info("Redirecting to: "+text);
                window.location=text;
        },
@@ -1467,7 +1460,7 @@ Wicket.Head.Contributor.prototype = {
                // need to replace that first
                
                // get the header contribution text and unescape it if necessary
-               var text = headerNode.firstChild.nodeValue;     
+               var text = Wicket._readTextNode(headerNode);    
            var encoding = headerNode.getAttribute("encoding");
            
            if (encoding != null && encoding != "") {
@@ -1662,7 +1655,7 @@ Wicket.Head.Contributor.prototype = {
                                notify();
                        }
                });                                     
-       }       
+       }
 };
 
 /**
@@ -2353,7 +2346,6 @@ Wicket.Focus = {
 }
 Wicket.Event.addDomReadyEvent(Wicket.Focus.attachFocusEvent);
 
-
 // DEBUG FUNCTIONS
 function wicketAjaxDebugEnabled() {
     if (typeof(wicketAjaxDebugEnable)=="undefined") {
@@ -2389,3 +2381,15 @@ function wicketHide(id) {
            e.style.display = "none";
        }
 }
+
+// reads large text/cdata nodes. WICKET-2759/3244
+Wicket._readTextNode = function(node) {
+       var text = "";
+       // get the new component body
+       if (node.hasChildNodes()) {
+               for( i=0 ; i < node.childNodes.length; i++ ) {
+                       text = text + node.childNodes[i].nodeValue;
+               }
+       }
+       return text;
+}


Reply via email to