在我的jsf页面代码中,我有一个与此结构类似的结构:
<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>
在Test2.jsf中,我包括以下richfaces库:
<%@ taglib uri="http://richfaces.org/a4j" prefix="a4j"%>
<%@ taglib uri="http://richfaces.org/rich" prefix="rich"%>
当我尝试在页面代码中使用任何a4j元素(例如a4j:button)时,此代码将在我的输出html文件中生成:
<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>
当我在页面代码中使用a4j元素时,会添加最后两行,它会复制现有的body和html标签(前两行)。我正在使用的richfaces版本是3.1.6.SR1。有人可以给我提示如何解决吗?
好的,这是3.1.6.SR1库的问题,这是最后一个支持jsf 1.1版本的库。我在Google中找到以下解决方案https://developer.jboss.org/thread/196997?tstart=0。但是,它并不完美,并且并非在每种情况下都有效。因此,我试图以其他方式解决此问题,并且根据以上链接的建议,我将AJAX.js文件格式更改为richfaces-impl.jar。我从richfaces-3.2版本中获取了AJAX.js文件,并替换了3.1.6.SR1中的代码。以下部分应更改:
第1412行//添加了A4J.AJAX.TestScriptEvaluation();
A4J.AJAX.processResponse = function(req) {
A4J.AJAX.TestScriptEvaluation();
var options = req.options;
var ajaxResponse = req.getResponseHeader('Ajax-Response');
第2014行的TestScriptEvaluation函数应替换为以下函数:
//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;
}
就这样。通过此更改,此问题不再存在。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句