JSF & Primefaces & IE Ajax 不工作

标签 jsf primefaces internet-explorer-9

我正在使用 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/

相关文章:

jsf-2 - 用primefaces 5.2改变表达语言

html - OS X 的 IE9 和 FF11 有间距问题

jsf - 如何使用 FacesContext 获取 JSF 中以前的 URL?

javascript - 在页面的页眉中而不是在页脚中包含 JS 脚本?

JSF 形式的 Hibernate POJO

html - ie9 滚动条和 eclipse 刻边框始终显示在对象上

internet-explorer-9 - Watin 2 和 IE 9 下载管理器

jsf - Primefaces 从数据表下载文件

jsf - Primefaces 数据表标题对齐

jsf - @this的功能到底是什么?