开发者

JSF 2 Ajax requests fail on IE 9

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?

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

<?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 t开发者_StackOverflow中文版ext " + text);
        return text;
    }

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

    public String getIdDiv() {
        return idDiv;
    }

    public String getIdForm() {
        return idForm;
    }
}


Looks like Mojarra issue JAVASERVERFACES-1981.


Cannot reproduce this problem using Mojarra 2.1.1 on Tomcat 7.0.12.

JSF 2 Ajax requests fail on IE 9

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?)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜