IE 9上的JSF 2 Ajax请求失败

时间:2011-05-10 10:23:32

标签: ajax jsf jsf-2 internet-explorer-9

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

为了重现这个问题,我把它钉在一个由一个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>

豆是

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 个答案:

答案 0 :(得分:5)

看起来像Mojarra问题JAVASERVERFACES-1981

答案 1 :(得分:2)

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

enter image description here

您的问题是由其他原因造成的。我怀疑在您的真实代码中使用动态ID与#{testBean.idDiv}一样不正确。尝试使用固定的ID(为什么你会让它变得动态?)

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