Ajax problem with Doctype in IE9
mdurr Apr 19, 2011 7:36 AMHi everyone, I'm having some problems with richfaces (4.0.0.Final) ajax components in IE9. The sample below is more or less a copy of the example on richfaces showcase site. It works fine in IE9.
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head><title>Test</title></h:head>
<h:body>
<h:form>
<h:outputLabel value="Name:" for="nameInput"/>
<h:inputText id="nameInput" value="#{helloWorld.name}">
<a4j:ajax event="keyup" render="output"/>
</h:inputText>
<h:outputText value="Hello #{helloWorld.name}!" id="output"/>
</h:form>
</h:body>
</html>
My problem occurs when I add other components to the page. In this example I have added an ajax enabled a4j:outputPanel *before* the test form:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" lang="en"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich"
xmlns:a4j="http://richfaces.org/a4j">
<h:head><title>Test</title></h:head>
<h:body>
<a4j:outputPanel ajaxRendered="true" id="dummy"/>
<h:form>
<h:outputLabel value="Name:" for="nameInput"/>
<h:inputText id="nameInput" value="#{helloWorld.name}">
<a4j:ajax event="keyup" render="output"/>
</h:inputText>
<h:outputText value="Hello #{helloWorld.name}!" id="output"/>
</h:form>
</h:body>
</html>
Now the code stops working in IE9, still works fine in Firefox. After some trial and error I have found two ways to make the example work again:
- Move the a4j output panel below the form
- Remove the Doctype tag, changing it to Strict doesn't work you have to remove it completely...
Does anyone know how to fix this? Removing the doctype makes the page look really bad in all browsers, and only having one working ajax component per page is not really an option... Or might this be a bug in richfaces?
Best regards,
Magnus