var originalPrimeFacesAjaxResponseFunction = PrimeFaces.ajax.AjaxResponse;
PrimeFaces.ajax.AjaxResponse = function(responseXML) {
	if (responseXML) {
	   var newViewRoot = $(responseXML.documentElement).find("update[id='javax.faces.ViewRoot']").text();
	    if (newViewRoot) {
	       $('head').html(newViewRoot.substring(newViewRoot.indexOf("<head>") + 6, newViewRoot.indexOf("</head>")));
	       $('body').html(newViewRoot.substring(newViewRoot.indexOf("<body>") + 6, newViewRoot.indexOf("</body>")));
	    }
	    else {
	    	//Error here
	    	originalPrimeFacesAjaxResponseFunction.apply(this, arguments);
	    }
	}
    else {
        originalPrimeFacesAjaxResponseFunction.apply(this, arguments);
    }
};