Why usage of any a4j element in jsf add to page code second body and head tags?

前端 未结 1 1568
南方客
南方客 2021-01-14 14:30

In my jsf page code I have a structure similiar to this one :


   

        
1条回答
  •  礼貌的吻别
    2021-01-14 14:56

    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 = "A4J.AJAX._scriptEvaluated=true;";
            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.

    0 讨论(0)
提交回复
热议问题