JSF Language switcher and ajax update

后端 未结 1 1145
清歌不尽
清歌不尽 2021-01-20 15:37

This question is a follow - up of the older Language switcher implementation in JSF 2.

The substance of the question is still valid, although PrimeFaces has released

1条回答
  •  情话喂你
    2021-01-20 16:02

    The update="@all" of all PrimeFaces versions until now (3.4.2) is known to fail in IE. Any JavaScript code delivered along with the ajax response isn't been initialized properly.

    This is discussed in this PrimeFaces forum topic and reported as issue 4731.

    Until they fix it, your best bet is to workaround it by loading the following piece of JavaScript on every view which (possibly) contains an update="@all" command:

    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("") + 6, newViewRoot.indexOf("")));
           $('body').html(newViewRoot.substring(newViewRoot.indexOf("") + 6, newViewRoot.indexOf("")));
        } else {
            originalPrimeFacesAjaxResponseFunction.apply(this, arguments);
        }
    };
    

    Provide this in flavor of a JS file which is loaded by inside the in order to enforce the right loading order.

    
        
        ...
    
    

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