Jsf 对象没有';t使用primefaces omnifaces超时组合不支持此属性或方法

Jsf 对象没有';t使用primefaces omnifaces超时组合不支持此属性或方法,jsf,internet-explorer-8,primefaces,viewexpiredexception,omnifaces,Jsf,Internet Explorer 8,Primefaces,Viewexpiredexception,Omnifaces,设置: JSF、PrimeFaces 3.2、Omnifaces 1.1、JBoss AS 7.1.1、Final、Mojarra 2.1.7 我有一个简单的页面(如下所列),我已经设置了omnifaces来处理ajax调用的ViewExpiredException。当下面列出的页面过期,我单击IE8上的primefaces按钮(ajax)时,会显示过期的错误页面,但会出现以下javascript错误: 消息:对象不支持此属性或方法,行:1 Char:5500 Code:0 URI:blah b

设置: JSF、PrimeFaces 3.2、Omnifaces 1.1、JBoss AS 7.1.1、Final、Mojarra 2.1.7

我有一个简单的页面(如下所列),我已经设置了omnifaces来处理ajax调用的ViewExpiredException。当下面列出的页面过期,我单击IE8上的primefaces按钮(ajax)时,会显示过期的错误页面,但会出现以下javascript错误:

消息:对象不支持此属性或方法,行:1 Char:5500 Code:0 URI:blah blah/mywebapp/javax.faces.resource/primefaces.js.xhtml?ln=primefaces&v=3.2

它似乎不会在其他浏览器上产生错误

我的页面(home.xhtml):


超时错误页:expired.xhtml

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    template="/WEB-INF/templates/layout.xhtml">
    <ui:define name="body">
    Your session has timed out.
    </ui:define>
</ui:composition>

您的会话已超时。
模板layout.xhtml

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
        xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:ui="http://java.sun.com/jsf/facelets">

<f:view contentType="text/html">
    <h:head>
        <f:facet name="first">
            <meta http-equiv="X-UA-Compatible" content="IE=edge" />
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <meta http-equiv="Cache-Control" content="no-cache, no-store, must-    revalidate" />
            <meta http-equiv="Pragma" content="no-cache" />
            <meta http-equiv="Expires" content="0" />
        </f:facet>
        <base href="${facesContext.externalContext.requestContextPath}" />
    </h:head>
    <h:body>
        <ui:insert name="body"></ui:insert>
    </h:body>
</f:view>
</html>

Web.xml还包括以下内容:

    <error-page>
        <exception-type>javax.faces.application.ViewExpiredException</exception-type>
        <location>/WEB-INF/errorpages/expired.xhtml</location>
    </error-page>

    <filter>
        <filter-name>facesExceptionFilter</filter-name>
        <filter-class>org.omnifaces.filter.FacesExceptionFilter</filter-class>
    </filter>
    <filter-mapping>
        <filter-name>facesExceptionFilter</filter-name>
        <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>

javax.faces.application.ViewExpiredException
/WEB-INF/errorpages/expired.xhtml
FacescececeptionFilter
org.omnifaces.filter.FacesExceptionFilter
FacescececeptionFilter
Facesservlet
当我在过期后单击第二个按钮时,过期的页面显示为无javascript错误


有什么想法吗?

这是基于IE的浏览器中PrimeFaces
update=“@all”
的一个已知问题。整个视图已替换为
document.write()
,但是基于IE的浏览器无法正确加载/初始化任何
资源。另见此。这将为您解决

在此之前,您可以使用以下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);
    }
};

请注意,这假设当前视图使用的是PrimeFaces组件,这反过来会强制自动包含
PrimeFaces.js
jquery.js
脚本。否则,您必须手动声明它们。

顺便说一句,要打破它,请将oncomplete=“showConfirmDlg();”添加到第一个按钮。那么这次它仍然会显示一个错误,抱怨script.js。上面的showConfirmDlg是一个p:remote命令。添加以查看它是否中断,并显示消息:对象不支持此属性或方法行:3,Char:4,代码:0 URI:blah/javax.faces.resource/js/script.js.xhtml如果responseXMLresponseXML.documentElement未定义,则需要添加额外的检查。这似乎没有什么区别,我将继续尝试responseXML和responseXML.documentElement都很好。它实际上指向:originalPrimeFacesAjaxResponseFunction.apply(这是参数);所以我真的不知道在这种情况下该怎么办
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);
    }
};
<h:body>
    <h:outputScript name="script.js" target="head">
    ...
</h:body>