IE 9上的JSF 2 Ajax请求失败

时间:2022-10-13 16:16:09

I recently tried to test my JSF application on IE9 and discovered all Ajax requests to fail with a MalformedXML exception complaining about an undefined object when trying to access the removeChild attribute. I observed the problems both with MyFaces 2.0.5 and mojarra 2.1.1. Are there any known limitiations or prerequisites to support IE 9?

我最近尝试在IE9上测试我的JSF应用程序并发现所有Ajax请求失败,并且在尝试访问removeChild属性时抱怨MalformedXML异常抱怨未定义的对象。我观察了MyFaces 2.0.5和mojarra 2.1.1的问题。是否有任何已知的限制或先决条件来支持IE 9?

To reproduce the problem I nailed it down to a simple test case consisting of one ajax request:

为了重现这个问题,我把它钉在一个由一个ajax请求组成的简单测试用例中:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html">
    <f:view  contentType="text/html">
    <h:head>
        <h:outputScript name="jsf.js" library="javax.faces" target="head"/>    
    </h:head>
    <h:body>
        <h:form id="#{testBean.idForm}">
                <h1>Test of IE9 Ajax</h1>
                <h:panelGroup id="#{testBean.idDiv}" layout="block">
                    Text: <h:outputText value="#{testBean.text}"/>
                    <br/>
                    <h:commandLink 
                        action="#{testBean.onAction}"
                        value="click me">
                        <f:ajax render="#{testBean.idDiv}"/>
                    </h:commandLink>
                </h:panelGroup>
            </h:form>
        </h:body>
    </f:view>
</html>

The bean is

豆是

package ietest;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

@ManagedBean
@SessionScoped
public class TestBean {
        private int clickCount;   
        private String idForm="testForm";
        private String idDiv="testDiv";

        public String getText(){
        String text = "you clicked " + clickCount +" times";
        System.out.println("Return text " + text);
        return text;
    }

    public String onAction(){
        System.out.println("onAction invoked");
        clickCount++;
        return "iebug";
    }

    public String getIdDiv() {
        return idDiv;
    }

    public String getIdForm() {
        return idForm;
    }
}

2 个解决方案

#1


5  

Looks like Mojarra issue JAVASERVERFACES-1981.

看起来像Mojarra发行JAVASERVERFACES-1981。

#2


2  

Cannot reproduce this problem using Mojarra 2.1.1 on Tomcat 7.0.12.

在Tomcat 7.0.12上使用Mojarra 2.1.1无法重现此问题。

IE 9上的JSF 2 Ajax请求失败

Your problem is caused by something else. I suspect it's in your real code an incorrect use of dynamic ids as you have with #{testBean.idDiv}. Try it with fixed ids (why would you ever make it dynamic?)

你的问题是由别的东西引起的。我怀疑在你的真实代码中使用#{testBean.idDiv}时动态ID的使用是错误的。尝试使用固定的ID(为什么你会让它变得动态?)

Further, the <h:outputScript> is entirely superfluous, this one is already by default included by JSF. Remove it. If it makes the problem bigger, then it is definitely caused by something else, e.g. a dirty classpath of different JSF versions mixed altogether.

此外, 完全是多余的,这个版本已经默认包含在JSF中。去掉它。如果它使问题更大,那么它肯定是由其他东西引起的,例如:不同JSF版本的脏类路径混合在一起。

#1


5  

Looks like Mojarra issue JAVASERVERFACES-1981.

看起来像Mojarra发行JAVASERVERFACES-1981。

#2


2  

Cannot reproduce this problem using Mojarra 2.1.1 on Tomcat 7.0.12.

在Tomcat 7.0.12上使用Mojarra 2.1.1无法重现此问题。

IE 9上的JSF 2 Ajax请求失败

Your problem is caused by something else. I suspect it's in your real code an incorrect use of dynamic ids as you have with #{testBean.idDiv}. Try it with fixed ids (why would you ever make it dynamic?)

你的问题是由别的东西引起的。我怀疑在你的真实代码中使用#{testBean.idDiv}时动态ID的使用是错误的。尝试使用固定的ID(为什么你会让它变得动态?)

Further, the <h:outputScript> is entirely superfluous, this one is already by default included by JSF. Remove it. If it makes the problem bigger, then it is definitely caused by something else, e.g. a dirty classpath of different JSF versions mixed altogether.

此外, 完全是多余的,这个版本已经默认包含在JSF中。去掉它。如果它使问题更大,那么它肯定是由其他东西引起的,例如:不同JSF版本的脏类路径混合在一起。