我必须维护一个基于JSF 1.1和Ajax4JSF的现有企业Web应用程序。我想使用<a4j:support>
向现有输入字段添加异步标准验证。它归结为以下代码片段:
<%@ page contentType="text/html; charset=ISO-8859-1" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>My Validate Test</title>
</head>
<body>
<f:view>
<h:form>
<h:inputText value="42" id="fooInput" required="true">
<a4j:support event="onchange" reRender="fooMsg" immediate="true" ajaxSingle="true"/>
<f:validateDoubleRange minimum="10" maximum="500"/>
</h:inputText>
<h:message for="fooInput" id="fooMsg" style="color: red;"/><br/>
<h:inputText value="Bar" id="barInput">
</h:inputText>
</h:form>
</f:view>
</body>
</html>
但Ajax请求未被触发。抛出以下JS错误:
TypeError: element.selectNodes is not a function
at Object.A4J.AJAX.XMLHttpRequest.getElementsByTagName (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:32:19)
at Object.A4J.AJAX.XMLHttpRequest._appendNewElements (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:43:389)
at Object.A4J.AJAX.XMLHttpRequest.appendNewHeadElements (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:43:185)
at Object.A4J.AJAX.processResponse [as onready] (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:57:731)
at XMLHttpRequest._request.onreadystatechange (https://localhost/MyFooApp/a4j.res/org.ajax4jsf.framework.ajax.AjaxScript.jsf:20:25)
我也试图改变“立即”和“ajaxSingle”属性,但它没有改变任何东西。 Ajax请求不会被触发。 Web应用程序中的其他Ajax4JSF功能似乎有效。问题是什么,我该如何解决?