我正在使用 JSF Mojarra 2.2.1、Primefaces 4.0 Snapshot 和 IE 9。这个问题发生在 IE 9 中,当我用 f:ajax 替换它时也存在类似的问题,除非我使用 @all 渲染。当通过 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"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form id="testForm">
<h1>Test of IE9 Ajax</h1>
Text: <h:outputText value="#{testBean.count}" />
<br />
<p:commandButton oncomplete="alert('a')" update=":testForm"
action="#{testBean.increment}" value="click me">
</p:commandButton>
</h:form>
</h:body>
</html>
我的 bean 是,
package test;
import java.io.Serializable;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class TestBean implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;
private int count = 0;
public void increment()
{
count++;
}
public int getCount() {
return count;
}
public void setCount(int count) {
this.count = count;
}
}
在测试中,只有在奇数时才会发出警报,这是ajax调用不流畅的另一个迹象。
更新:
我意识到发生这种情况是因为 IE9 在替换 jquery 的 replace all 方法时忽略了输入的 onclick="javascript"事件。
更新 2:
这不会发生在我的家庭计算机 IE 9(相同版本)中,它只发生在办公计算机中。我看不到安全设置,您知道为什么会这样吗? Javascript 可以工作,但无法正常运行。
非常感谢任何帮助。
谢谢
最佳答案
请在 <h:head>
中尝试以下代码标签:
<f:facet name="first">
<meta http-equiv="X-UA-Compatible" content="edge" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</f:facet>
如果有帮助,请告诉我。
关于JSF & Primefaces & IE Ajax 不工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18384936/