In my jsf page code I have a structure similiar to this one :
<frameset id="navframeset">
<frame name="navframe" src='<c:url value="TopNavigation.jsf"/>'/>
<frameset>
<frame name="leftframe" src='<c:url value="Test1.jsf"/>'/>
<frame name="tabbedframe" src='<c:url value="Test2.jsf"/>' />
</frameset>
In Test2.jsf i included following richfaces libraries :
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
When I try to use any of a4j element in a page code, for instance a4j:button, then this code is generated in my output html file :
<head>...</head>
<body>..</body>
<head><script xmlns="http://www.w3.org/1999/xhtml">A4J.AJAX._scriptEvaluated=true;</script></head>
<body marginwidth="0" marginheight="0"></body>
These two last lines are added when I use a4j element in my page code and it duplicate existing body and html tags(first two lines). Version of richfaces which I'm using is 3.1.6.SR1. Can anybody give me a hint how to fix it ?
Ok, this is an issue of 3.1.6.SR1 library, the last one which support jsf 1.1 version. I have found in google following solution https://developer.jboss.org/thread/196997?tstart=0. However it's not perfect and doesn't work in every situation. Because of this i was trying to solve this issue in other ways and as suggestion in above link I've changed AJAX.js file form richfaces-impl.jar. I took AJAX.js file from richfaces-3.2 version and replace code in 3.1.6.SR1. Following parts should be changed :
line 1412 // Added A4J.AJAX.TestScriptEvaluation();
A4J.AJAX.processResponse = function(req) {
A4J.AJAX.TestScriptEvaluation();
var options = req.options;
var ajaxResponse = req.getResponseHeader('Ajax-Response');
line 2014 TestScriptEvaluation function should be replaced to the following one:
//Test for re-evaluate Scripts in updated part. Opera & Safari do it.
A4J.AJAX._scriptEvaluated=false;
A4J.AJAX.TestScriptEvaluation = function () {
if ((!document.all || window.opera) && !A4J.AJAX._scriptTested){
try{
// Simulate same calls as on XmlHttp
var oDomDoc = Sarissa.getDomDocument();
var _span = document.createElement("span");
document.body.appendChild(_span);
// If script evaluated with used replace method, variable will be set to true
var xmlString = "<html xmlns='http://www.w3.org/1999/xhtml'><sc"+"ript>A4J.AJAX._scriptEvaluated=true;</scr"+"ipt></html>";
oDomDoc = (new DOMParser()).parseFromString(xmlString, "text/xml");
var _script=oDomDoc.getElementsByTagName("script")[0];
if (!window.opera && !A4J.AJAX.isWebkitBreakingAmps() && _span.outerHTML) {
_span.outerHTML = new XMLSerializer().serializeToString(_script);
} else {
var importednode ;
importednode = window.document.importNode(_script, true);
document.body.replaceChild(importednode,_span);
}
} catch(e){ /* Mozilla in XHTML mode not have innerHTML */ };
}
A4J.AJAX._scriptTested = true;
}
And that's all. With this changes this issue is not exists anymore.