Object doesn't support this property or method with primefaces omnifaces timeout combination

前端 未结 1 1390
南旧
南旧 2020-12-20 02:36

Setup: JSF, PrimeFaces 3.2, Omnifaces 1.1, JBoss AS 7.1.1, Final, Mojarra 2.1.7

I have a simple page (listed below) and I have set up omnifaces to deal with ViewExpi

相关标签:
1条回答
  • 2020-12-20 03:30

    This is a known issue of PrimeFaces update="@all" in IE based browsers. The entire view is been replaced by document.write(), however IE based browsers doesn't properly load/initialize any <script> resources. See also this PrimeFaces forum topic. This will be addressed for PrimeFaces version 3.4.2.

    Until then, you can workaround it using the following JavaScript

    var originalPrimeFacesAjaxResponseFunction = PrimeFaces.ajax.AjaxResponse;
    PrimeFaces.ajax.AjaxResponse = function(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 {
            originalPrimeFacesAjaxResponseFunction.apply(this, arguments);
        }
    };
    

    which needs to be loaded after PrimeFaces own JS resources; this can be done by referencing it in <h:body> with target="head".

    <h:body>
        <h:outputScript name="script.js" target="head">
        ...
    </h:body>
    

    Note that this assumes that the current view is using PrimeFaces components which should in turn force auto-inclusion of primefaces.js and jquery.js scripts. Otherwise you've to manually declare them.

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