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/04/02 22:55:22 UTC

svn commit: r930380 - in /myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl: _util/_Utils.js core/jsf_impl.js xhrCore/_AjaxResponse.js

Author: werpu
Date: Fri Apr  2 20:55:22 2010
New Revision: 930380

URL: http://svn.apache.org/viewvc?rev=930380&view=rev
Log:
https://issues.apache.org/jira/browse/MYFACES-2637
Fixed up the form determination code, so that it can handle detachement cases and multiple forms
regarding the viewstate.
Also fixed up the detachment code in the jsf.ajax.request part, it was buggy
we now can deal with replacement elements properly which just can deliver
the submit name, if a form can be idenitified uniquely.

This should now finally hopefully allow frameworks like dojo to work properly,
additional testing is needed (I will run some dijit testing) but I assume
the commit is more important, since it does not break anything (hopefully)
in normal cases.

Modified:
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
    myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js?rev=930380&r1=930379&r2=930380&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/_util/_Utils.js Fri Apr  2 20:55:22 2010
@@ -305,26 +305,26 @@ if (!myfaces._impl._util._LangUtils.exis
         }
 
         /*
-            Now to the broken browsers IE6+.... ie7 and ie8 quirks mode
+         Now to the broken browsers IE6+.... ie7 and ie8 quirks mode
 
-            we deal mainly with three problems here
-            class and for are not handled correctly
-            styles are arrays and cannot be set directly
-            and javascript events cannot be set via setAttribute as well!
-
-            or in original words of quirksmode.org ... this is a mess!
-
-            Btw. thank you Microsoft for providing all necessary tools for free
-            for being able to debug this entire mess in the ie rendering engine out
-            (which is the Microsoft ie vms, developers toolbar, Visual Web Developer 2008 express
-            and the ie8 8 developers toolset!)
-
-            also thank you http://www.quirksmode.org/
-            dojotoolkit.org and   //http://delete.me.uk/2004/09/ieproto.html
-            for additional information on this mess!
+         we deal mainly with three problems here
+         class and for are not handled correctly
+         styles are arrays and cannot be set directly
+         and javascript events cannot be set via setAttribute as well!
+
+         or in original words of quirksmode.org ... this is a mess!
+
+         Btw. thank you Microsoft for providing all necessary tools for free
+         for being able to debug this entire mess in the ie rendering engine out
+         (which is the Microsoft ie vms, developers toolbar, Visual Web Developer 2008 express
+         and the ie8 8 developers toolset!)
+
+         also thank you http://www.quirksmode.org/
+         dojotoolkit.org and   //http://delete.me.uk/2004/09/ieproto.html
+         for additional information on this mess!
 
-            The lowest common denominator tested within this code
-            is IE6, older browsers for now are legacy!
+         The lowest common denominator tested within this code
+         is IE6, older browsers for now are legacy!
          */
         attribute = attribute.toLowerCase();
 
@@ -491,75 +491,58 @@ if (!myfaces._impl._util._LangUtils.exis
      *
      * @param {XMLHTTPRequest} request
      * @param {Map} context
-     * @param {String} submitIdentifier - child elements name identifier
+     * @param {Node} element - element as source, can be detached, undefined or null
      *
      * @return either null or a form node if it could be determined
      */
-    myfaces._impl._util._Utils.fuzzyFormDetection = function(request, context, submitIdentifier) {
+    myfaces._impl._util._Utils.fuzzyFormDetection = function(request, context, element) {
         if (0 == document.forms.length) {
             return null;
+        } else if (1 == document.forms.length) {
+            return document.forms[0];
+        }
+        if ('undefined' == typeof element || null == element) {
+            return null;
         }
 
-        if ('undefined' == typeof submitIdentifier || null == submitIdentifier) {
-            //no identifier found we give it a shot with the first form
-            return document.forms[0];
+        var submitIdentifier = ('undefined' != element.id) ? element.id : null;
+        var submitName = ('undefined' != element.name) ? element.name : null;
+
+        if ('undefined' != typeof submitIdentifier && null != submitIdentifier && '' != submitIdentifier) {
+            //we have to assert that the element passed down is detached
+            var domElement = myfaces._impl._util._LangUtils.byId(submitIdentifier);
+            if ('undefined' != typeof domElement && null != domElement) {
+                var foundForm = myfaces._impl._util._Utils.getParent(null, context, domElement, "form");
+                if (null != foundForm) return foundForm;
+            }
         }
 
         /**
-         * highest chance is to find an element with an identifier
+         * name check
          */
-        var elementById = document.getElementById(submitIdentifier);
         var foundElements = new Array();
-        if (null != elementById) {
-            if ('undefined' == typeof element.name || null == element.name || submitIdentifier == element.name) {
-                foundElements.push(elementById);
-            }
-        }
 
         /**
          * the lesser chance is the elements which have the same name
          * (which is the more likely case in case of a brute dom replacement)
          */
-        var namedFoundElements = document.getElementsByName(submitIdentifier);
+        var namedFoundElements = document.getElementsByName(submitName);
         if (null != namedFoundElements) {
             for (var cnt = 0; cnt < namedFoundElements.length; cnt++) {
                 // we already have covered the identifier case hence we only can deal with names,
-                // since identifiers are unique
-                // we have to filter that element out for the rest of the stack, to have a clean handling
-                // of the number of referenced forms
-                if('undefined' == typeof namedFoundElements[cnt].id || null == namedFoundElements[cnt].id || namedFoundElements[cnt].id != submitIdentifier) {
-                    foundElements.push(namedFoundElements[cnt]);
+                var foundForm = myfaces._impl._util._Utils.getParent(null, context, namedFoundElements[cnt], "form");
+                if (null != foundForm) {
+                    foundElements.push(foundForm);
                 }
             }
         }
 
-        if (null == foundElements || 0 == foundElements.length) {
+        if (null == foundElements || 0 == foundElements.length || foundElements.length > 1) {
             return null;
         }
 
-        //we now iterate over all possible elements with the identifier element being the first if present
-        //however if the identifier element has no parent form we must rely on our found named elements
-        //to have at least one parent form
-        var foundForm = null;
-        var formCnt = 0;
-        for (var cnt = 0; cnt < foundElements.length; cnt++) {
-            var foundElement = foundElements[cnt];
-            var parentItem = ('undefined' != typeof foundElement && null != foundElement) ? foundElement.parentNode : null;
-            while (parentItem != null
-                    && parentItem.tagName.toLowerCase() != "form") {
-                parentItem = parentItem.parentNode;
-            }
-            if (parentItem != null) {
-                foundForm = parentItem;
-                formCnt++;
-            }
-            if(formCnt == 1) {
-                return foundForm;
-            }
-            if(formCnt > 1) return null;
-        }
 
-        return null;
+        return foundElements[0];
     };
 
     /**
@@ -572,14 +555,13 @@ if (!myfaces._impl._util._LangUtils.exis
      */
     myfaces._impl._util._Utils.getParent = function(request, context, item, tagNameToSearchFor) {
 
-		try {
-            if('undefined' == typeof item || null == item) {
-			    throw Error("myfaces._impl._util._Utils.getParen: item is null or undefined,this not allowed");
-		    }
+        try {
+            if ('undefined' == typeof item || null == item) {
+                throw Error("myfaces._impl._util._Utils.getParen: item is null or undefined,this not allowed");
+            }
 
             //search parent tag parentName
-            var parentItem = ('undefined' != typeof item.parentNode) ? item.parentNode: null;
-
+            var parentItem = ('undefined' != typeof item.parentNode) ? item.parentNode : null;
 
             if ('undefined' != typeof item.tagName && null != item.tagName && item.tagName.toLowerCase() == tagNameToSearchFor) {
                 return item;

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js?rev=930380&r1=930379&r2=930380&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/core/jsf_impl.js Fri Apr  2 20:55:22 2010
@@ -154,22 +154,21 @@ if (!myfaces._impl._util._LangUtils.exis
          **/
         var JSF2Utils = myfaces._impl._util._LangUtils;
         var elementId = null;
-        if(JSF2Utils.isString(element)) {
-            elementId = element;
-        } else if ('undefined' != typeof element && null != element) {
-            //inputs do not have names defined per spec so we can rely on the proper id being set
-            elementId = element.id;
-        }
-
         /**
          * we cross reference statically hence the mapping here
          * the entire mapping between the functions is stateless
          */
         element = JSF2Utils.byId(element);
-
-        /*assert a valid structure of a given element*/
-        //element can be mapped out by the time of passing the request by some underlying framework
-        //this._assertElement(element);
+        if ('undefined' != typeof element && null != element) {
+            //detached element handling, we also store the element name
+            //to get a fallback option in case the identifier is not determinable
+            // anymore, in case of a framework induced detachment the element.name should
+            // be shared if the identifier is not determinable anymore
+            elementId = ('undefined' != typeof element.id)? element.id: null;
+            if((elementId == null || elementId == '') && 'undefined' != typeof element.name) {
+                elementId = element.name;
+            }
+        }
 
         /*assert if the onerror is set and once if it is set it must be of type function*/
         this._assertFunction(options.onerror);
@@ -206,19 +205,10 @@ if (!myfaces._impl._util._LangUtils.exis
         /**
          * fetch the parent form
          */
-        var sourceForm = ('undefined' != typeof element && null != element) ? myfaces._impl._util._Utils.getParent(null, ajaxContext, element, "form") : null;
 
-        if ('undefined' == typeof sourceForm || null == sourceForm) {
-            //in case of a detached element we have to try to determine fuzzily over the name/id attribute
-            //  which form we have to use
-            //this should get in 90% of all usecases with multiple forms the form right
-            sourceForm = myfaces._impl._util._Utils.fuzzyFormDetection(null, ajaxContext, elementId);
-            //the identifier must be unique within the scope of the page (aka only one form can have it, name or id
-            // (in a detachment case we have only name, because the identifier is lost)
-            // because the spec clearly states, if the dom element could not be determined, throw an error we we have here
-            if(null == sourceForm) {
-                throw Error("Sourcform could not be determined, either because "+ elementId+ " is not in a form or we have multiple forms with named elements of name "+elementId+", stopping the ajax processing");
-            }
+        var sourceForm = myfaces._impl._util._Utils.fuzzyFormDetection(null, ajaxContext, element);
+        if (null == sourceForm) {
+            throw Error("Sourcform could not be determined, either because element is not attached to a form or we have multiple forms with named elements of the same identifier or name, stopping the ajax processing");
         }
 
         /**
@@ -399,7 +389,7 @@ if (!myfaces._impl._util._LangUtils.exis
      * The value for it comes from the request parameter of the jsf.js script called "stage".
      */
     myfaces._impl.core._jsfImpl.prototype.getProjectStage = function() {
-    	/* 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 */
         var scriptTags = document.getElementsByTagName("script");
         for (var i = 0; i < scriptTags.length; i++)
         {
@@ -422,7 +412,7 @@ if (!myfaces._impl._util._LangUtils.exis
                 else
                 {
                     /* we found the script, but there was no stage parameter --> Production */
-                	return "Production";
+                    return "Production";
                 }
             }
         }
@@ -460,10 +450,11 @@ if (!myfaces._impl._util._LangUtils.exis
 
         if ('undefined' == typeof source) {
             throw new Error(" source must be defined");
-        //allowed chain datatypes
+            //allowed chain datatypes
         } else if ('function' == typeof source) {
             throw new Error(" source cannot be a function (probably source and event were not defined or set to null");
-        } if (myfaces._impl._util._LangUtils.isString(source)) {
+        }
+        if (myfaces._impl._util._LangUtils.isString(source)) {
             throw new Error(" source cannot be a string ");
         }
 
@@ -472,7 +463,7 @@ if (!myfaces._impl._util._LangUtils.exis
         } else if ('function' == typeof event) {
             throw new Error(" event cannot be a function (probably source and event were not defined or set to null");
         } else if (myfaces._impl._util._LangUtils.isString(event)) {
-                throw new Error(" event cannot be a string ");
+            throw new Error(" event cannot be a string ");
         }
 
         var thisVal = source;

Modified: myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js
URL: http://svn.apache.org/viewvc/myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js?rev=930380&r1=930379&r2=930380&view=diff
==============================================================================
--- myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js (original)
+++ myfaces/core/trunk/api/src/main/javascript/META-INF/resources/myfaces/_impl/xhrCore/_AjaxResponse.js Fri Apr  2 20:55:22 2010
@@ -20,7 +20,6 @@
 
 _reserveMyfacesNamespaces();
 
-
 if (!myfaces._impl._util._LangUtils.exists(myfaces._impl.xhrCore, "_AjaxResponse")) {
 
 
@@ -34,22 +33,22 @@ if (!myfaces._impl._util._LangUtils.exis
     };
 
     /*partial response types*/
-    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSE_PARTIAL         = "partial-response";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSETYPE_ERROR       = "error";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSE_PARTIAL = "partial-response";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSETYPE_ERROR = "error";
     /*TODO: -=Leonardo Uribe=- Does this response type really exists? really from server comes a partial-response with redirect command*/
-    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSETYPE_REDIRECT    = "redirect";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSETYPE_REDIRECT    = "changes";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSETYPE_REDIRECT = "redirect";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._RESPONSETYPE_REDIRECT = "changes";
 
     /*partial commands*/
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_CHANGES     = "changes";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_UPDATE      = "update";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_DELETE      = "delete";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_INSERT      = "insert";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_EVAL        = "eval";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_ERROR       = "error";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_ATTRIBUTES  = "attributes";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_EXTENSION   = "extension";
-    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_REDIRECT    = "redirect"
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_CHANGES = "changes";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_UPDATE = "update";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_DELETE = "delete";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_INSERT = "insert";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_EVAL = "eval";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_ERROR = "error";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_ATTRIBUTES = "attributes";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_EXTENSION = "extension";
+    myfaces._impl.xhrCore._AjaxResponse.prototype._PCMD_REDIRECT = "redirect"
     /**
      * uses response to start Html element replacement
      *
@@ -74,28 +73,28 @@ if (!myfaces._impl._util._LangUtils.exis
             }
 
             if (!myfaces._impl._util._LangUtils.exists(request, "responseXML")) {
-            	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_EMPTY_RESPONSE);
+                myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_EMPTY_RESPONSE);
                 return;
             }
 
             var xmlContent = request.responseXML;
             if (xmlContent.firstChild.tagName == "parsererror") {
-            	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
+                myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
                 return;
             }
             var partials = xmlContent.childNodes[0];
             if ('undefined' == typeof partials || partials == null) {
-            	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
+                myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
                 return;
             } else {
-            	if (partials.tagName != this._RESPONSE_PARTIAL) {
-            		// IE 8 sees XML Header as first sibling ...
-            		partials = partials.nextSibling;
+                if (partials.tagName != this._RESPONSE_PARTIAL) {
+                    // IE 8 sees XML Header as first sibling ...
+                    partials = partials.nextSibling;
                     if ('undefined' == typeof partials || partials == null || partials.tagName != this._RESPONSE_PARTIAL) {
-                    	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
+                        myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
                         return;
                     }
-            	}
+                }
             }
 
             var childNodesLength = partials.childNodes.length;
@@ -132,34 +131,34 @@ if (!myfaces._impl._util._LangUtils.exis
 
     myfaces._impl.xhrCore._AjaxResponse.prototype.processError = function(request, context, node) {
         /**
-     * <error>
-     *      <error-name>String</error-name>
-     *      <error-message><![CDATA[message]]></error-message>
-     * <error>
-     */
+         * <error>
+         *      <error-name>String</error-name>
+         *      <error-message><![CDATA[message]]></error-message>
+         * <error>
+         */
         var errorName = node.firstChild.textContent;
         var errorMessage = node.childNodes[1].firstChild.data;
 
-        if('undefined' == typeof errorName || null == errorName) {
+        if ('undefined' == typeof errorName || null == errorName) {
             errorName = "";
         }
-        if('undefined' == typeof errorMessage || null == errorMessage) {
+        if ('undefined' == typeof errorMessage || null == errorMessage) {
             errorMessage = "";
         }
-        myfaces.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_SERVER_ERROR , errorName, errorMessage);
+        myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_SERVER_ERROR, errorName, errorMessage);
     }
 
     myfaces._impl.xhrCore._AjaxResponse.prototype.processRedirect = function(request, context, node) {
         /**
-     * <redirect url="url to redirect" />
-     */
+         * <redirect url="url to redirect" />
+         */
         var redirectUrl = node.getAttribute("url");
-        if('undefined' == typeof redirectUrl || null == redirectUrl) {
-        	myfaces.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,"Redirect without url");
+        if ('undefined' == typeof redirectUrl || null == redirectUrl) {
+            myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Redirect without url");
             return false;
         }
         redirectUrl = myfaces._impl._util._LangUtils.trim(redirectUrl);
-        if(redirectUrl == "") {
+        if (redirectUrl == "") {
             return false;
         }
         window.location = redirectUrl;
@@ -189,7 +188,7 @@ if (!myfaces._impl._util._LangUtils.exis
                 //you have to insert it here
                 //  this._responseHandler.doExtension(childNode);
             } else {
-            	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
+                myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML);
                 return false;
             }
         }
@@ -198,31 +197,26 @@ if (!myfaces._impl._util._LangUtils.exis
 
     myfaces._impl.xhrCore._AjaxResponse.prototype.processUpdate = function(request, context, node) {
         if (node.getAttribute('id') == "javax.faces.ViewState") {
-            /*if(null != document.getElementById("javax.faces.ViewState")) {
-                document.getElementById("javax.faces.ViewState").value = node.firstChild.nodeValue;
-            } else {
 
-            }*/
             //update the submitting forms viewstate to the new value
             // The source form has to be pulled out of the CURRENT document first because the context object
             // may refer to an invalid document if an update of the entire body has occurred before this point.
-            sourceForm = document.forms.length > 0 ? document.forms[0]:null;
 
-            if ('undefined' == typeof sourceForm || null == sourceForm) {
-                var sourceForm = myfaces._impl._util._Utils.getParent(null, context, context.source, "form");
-            }
+            var sourceForm = myfaces._impl._util._Utils.fuzzyFormDetection(null, context, context.source);
 
-            if(null != sourceForm) {
+            //the source form could be determined absolutely by either the form, the identifier of the node, or the name
+            //if only one element is given
+            if (null != sourceForm) {
                 /*we check for an element and include a namesearch, but only within the bounds of the committing form*/
-                var element = myfaces._impl._util._Utils.getElementFromForm(request, context, "javax.faces.ViewState", sourceForm,  true, true);
-                if(null == element) {//no element found we have to append a hidden field
+                var element = myfaces._impl._util._Utils.getElementFromForm(request, context, "javax.faces.ViewState", sourceForm, true, true);
+                if (null == element) {//no element found we have to append a hidden field
                     element = document.createElement("input");
-                    myfaces._impl._util._Utils.setAttribute(element,"type", "hidden");
-                    myfaces._impl._util._Utils.setAttribute(element,"name","javax.faces.ViewState");
+                    myfaces._impl._util._Utils.setAttribute(element, "type", "hidden");
+                    myfaces._impl._util._Utils.setAttribute(element, "name", "javax.faces.ViewState");
                     sourceForm.appendChild(element);
                 }
                 //viewstate cannot have split cdata blocks so we can skip the costlier operation
-                myfaces._impl._util._Utils.setAttribute(element,"value", node.firstChild.nodeValue);
+                myfaces._impl._util._Utils.setAttribute(element, "value", node.firstChild.nodeValue);
 
             }
             //else??? the latest spec has this omitted we have to wait for the RI which probably covers this
@@ -231,9 +225,9 @@ if (!myfaces._impl._util._LangUtils.exis
             // response may contain several blocks
             var cDataBlock = myfaces._impl._util._Utils.concatCDATABlocks(node);
 
-            switch(node.getAttribute('id')) {
+            switch (node.getAttribute('id')) {
                 case "javax.faces.ViewRoot":
-                    this._replaceBody(request, context,  cDataBlock );
+                    this._replaceBody(request, context, cDataBlock);
 
                     break;
                 case "javax.faces.ViewHead":
@@ -244,11 +238,11 @@ if (!myfaces._impl._util._LangUtils.exis
                     break;
                 case "javax.faces.ViewBody":
                     //we assume the cdata block is our body including the tag
-                    this._replaceBody(request, context,  cDataBlock );
+                    this._replaceBody(request, context, cDataBlock);
                     break;
 
                 default:
-                    this._replaceElement(request, context,node.getAttribute('id'), cDataBlock );
+                    this._replaceElement(request, context, node.getAttribute('id'), cDataBlock);
 
                     break;
             }
@@ -261,14 +255,14 @@ if (!myfaces._impl._util._LangUtils.exis
      * replacing the entire body does not work fully by simply adding a second body
      * and by creating a range instead we have to work around that by dom creating a second
      * body and then filling it properly!
-     * 
+     *
      * @param {Object} request our request object
      * @param {Map} context the response context
      * @param {String} newData the markup which replaces the old dom node!
      */
     myfaces._impl.xhrCore._AjaxResponse.prototype._replaceBody = function(request, context, newData) {
-        var parser =  myfaces.ajax._impl = new (myfaces._impl._util._Utils.getGlobalConfig("updateParser",myfaces._impl._util._HtmlStripper))();
-                 
+        var parser = myfaces.ajax._impl = new (myfaces._impl._util._Utils.getGlobalConfig("updateParser", myfaces._impl._util._HtmlStripper))();
+
         var oldBody = document.getElementsByTagName("body")[0];
         var newBody = document.createElement("body");
         var placeHolder = document.createElement("div");
@@ -278,18 +272,16 @@ if (!myfaces._impl._util._LangUtils.exis
 
         //the contextualFragment trick does not work on the body tag instead we have to generate a manual body
         //element and then add a child which then is the replacement holder for our fragment!
-        var bodyData = parser.parse(newData,"body");
+        var bodyData = parser.parse(newData, "body");
         bodyParent.replaceChild(newBody, oldBody);
-        this._replaceElement(request, context, placeHolder , bodyData );
+        this._replaceElement(request, context, placeHolder, bodyData);
 
-        for(var key in parser.tagAttributes) {
+        for (var key in parser.tagAttributes) {
             var value = parser.tagAttributes[key];
             myfaces._impl._util._Utils.setAttribute(newBody, key, value);
         }
     };
 
-
-
     /**
      * Helper method to avoid duplicate code
      * @param {Object} request our request object
@@ -299,7 +291,7 @@ if (!myfaces._impl._util._LangUtils.exis
      */
     myfaces._impl.xhrCore._AjaxResponse.prototype._replaceElement = function(request, context, oldElement, newData) {
         myfaces._impl._util._Utils.replaceHtmlItem(request, context,
-            oldElement, newData, this.m_htmlFormElement);
+                oldElement, newData, this.m_htmlFormElement);
     };
 
     /*insert, three attributes can be present
@@ -312,20 +304,20 @@ if (!myfaces._impl._util._LangUtils.exis
      * the after is the id if set which the component has to be inserted after
      **/
     myfaces._impl.xhrCore._AjaxResponse.prototype.processInsert = function(request, context, node) {
-        var insertId    = node.getAttribute('id');
-        var beforeId    = node.getAttribute('before');
-        var afterId     = node.getAttribute('after');
-
-        var insertSet   = 'undefined' != typeof insertId && null != insertId && myfaces._impl._util._LangUtils.trim(insertId) != "";
-        var beforeSet   = 'undefined' != typeof beforeId && null != beforeId && myfaces._impl._util._LangUtils.trim(beforeId) != "";
-        var afterSet    = 'undefined' != typeof afterId && null != afterId && myfaces._impl._util._LangUtils.trim(afterId) != "";
+        var insertId = node.getAttribute('id');
+        var beforeId = node.getAttribute('before');
+        var afterId = node.getAttribute('after');
+
+        var insertSet = 'undefined' != typeof insertId && null != insertId && myfaces._impl._util._LangUtils.trim(insertId) != "";
+        var beforeSet = 'undefined' != typeof beforeId && null != beforeId && myfaces._impl._util._LangUtils.trim(beforeId) != "";
+        var afterSet = 'undefined' != typeof afterId && null != afterId && myfaces._impl._util._LangUtils.trim(afterId) != "";
 
-        if(!insertSet) {
-        	myfaces.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
+        if (!insertSet) {
+            myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, id must be present");
             return false;
         }
-        if(!(beforeSet || afterSet)) {
-        	myfaces.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
+        if (!(beforeSet || afterSet)) {
+            myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, before id or after id must be present");
             return false;
         }
         //either before or after but not two at the same time
@@ -334,11 +326,11 @@ if (!myfaces._impl._util._LangUtils.exis
 
         var cDataBlock = myfaces._impl._util._Utils.concatCDATABlocks(node);
 
-        if(beforeSet) {
+        if (beforeSet) {
             beforeId = myfaces._impl._util._LangUtils.trim(beforeId);
             var beforeNode = document.getElementById(beforeId);
-            if('undefined' == typeof beforeNode || null == beforeNode) {
-            	myfaces.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, before  node of id "+beforeId+" does not exist in document");
+            if ('undefined' == typeof beforeNode || null == beforeNode) {
+                myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, before  node of id " + beforeId + " does not exist in document");
                 return false;
             }
             /**
@@ -351,35 +343,34 @@ if (!myfaces._impl._util._LangUtils.exis
             parentNode = beforeNode.parentNode;
             parentNode.insertBefore(nodeHolder, beforeNode);
 
-
             myfaces._impl._util._Utils.replaceHtmlItem(request, context,
-                nodeHolder, cDataBlock, null);
+                    nodeHolder, cDataBlock, null);
 
         } else {
             afterId = myfaces._impl._util._LangUtils.trim(afterId);
             var afterNode = document.getElementById(afterId);
-            if('undefined' == typeof afterNode || null == afterNode) {
-            	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, after  node of id "+after+" does not exist in document");
+            if ('undefined' == typeof afterNode || null == afterNode) {
+                myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in PPR Insert, after  node of id " + after + " does not exist in document");
                 return false;
             }
             nodeHolder = document.createElement("div");
             parentNode = afterNode.parentNode;
             parentNode.insertBefore(nodeHolder, afterNode.nextSibling);
             myfaces._impl._util._Utils.replaceHtmlItem(request, context,
-                nodeHolder, cDataBlock, null);
+                    nodeHolder, cDataBlock, null);
         }
         return true;
     }
 
     myfaces._impl.xhrCore._AjaxResponse.prototype.processDelete = function(request, context, node) {
         var deleteId = node.getAttribute('id');
-        if('undefined' == typeof deleteId || null == deleteId) {
-        	myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,
-                myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,  "Error in delete, id not in xml markup");
+        if ('undefined' == typeof deleteId || null == deleteId) {
+            myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,
+                    myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in delete, id not in xml markup");
             return false;
         }
 
-        myfaces._impl._util._Utils.deleteItem(request, context, deleteId, "","");
+        myfaces._impl._util._Utils.deleteItem(request, context, deleteId, "", "");
         return true;
     }
 
@@ -393,33 +384,33 @@ if (!myfaces._impl._util._LangUtils.exis
         //<attributes id="id of element"> <attribute name="attribute name" value="attribute value" />* </attributes>
         var attributesRoot = node;
         var elementId = attributesRoot.getAttribute('id');
-        if('undefined' == typeof elementId || null == elementId) {
-        	myfaces.ajax.sendError(request, context,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML
-                ,myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML,  "Error in attributes, id not in xml markup");
+        if ('undefined' == typeof elementId || null == elementId) {
+            myfaces.ajax.sendError(request, context, myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML
+                    , myfaces._impl.core._jsfImpl._ERROR_MALFORMEDXML, "Error in attributes, id not in xml markup");
             return false;
         }
         var childs = attributesRoot.childNodes;
 
-        if('undefined' == typeof childs || null == childs) {
+        if ('undefined' == typeof childs || null == childs) {
             return false;
         }
-        for(var loop2 = 0; loop2 < childs.length; loop2++) {
+        for (var loop2 = 0; loop2 < childs.length; loop2++) {
             var attributesNode = childs[loop2];
 
             var attributeName = attributesNode.getAttribute("name");
             var attributeValue = attributesNode.getAttribute("value");
 
-            if('undefined' == typeof attributeName || null == attributeName) {
+            if ('undefined' == typeof attributeName || null == attributeName) {
                 continue;
             }
 
             attributeName = myfaces._impl._util._LangUtils.trim(attributeName);
             /*no value means reset*/
-            if('undefined' == typeof attributeValue || null == attributeValue) {
+            if ('undefined' == typeof attributeValue || null == attributeValue) {
                 attributeValue = "";
             }
 
-            switch(elementId) {
+            switch (elementId) {
                 case "javax.faces.ViewRoot":
                     throw new Error("Changing of viewRoot attributes is not supported");
                     break;
@@ -438,7 +429,6 @@ if (!myfaces._impl._util._LangUtils.exis
                     break;
             }
 
-
         }
         return true;
     }