java - Primefaces 数据表 onrowselect 事件在 IE 8 中不起作用

标签 java primefaces internet-explorer-8

我试图让以下代码在 IE 8 中运行,但没有结果(尽管它在 Google Chrome 中运行良好):

xhtml:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:head>
    </h:head>

    <h:body>
        <h:form id="form">

            <p:dataTable id="eventsDT" var="answer" value="#{verify.answers}" rowKey="#{answer.id}"  selectionMode="single" >
                <p:ajax event="rowSelect" listener="#{verify.onRowSelectTest}" />
                <p:column headerText="Id">
                    <h:outputText value="#{answer.id}" />
                </p:column>
                <p:column headerText="Text">
                    <h:outputText value="#{answer.text}" />
                </p:column>
            </p:dataTable>

        </h:form>
    </h:body>
</html>

Answer.java:

package ru.trust.appVerification;

    public class Answer {

        private int id;
        private String text = "Undefined";

        public Answer(int id, String text) {
            this.id = id;
            this.text = text;
        }

        public int getId() {
            return id;
        }

        public String getText() {
            return text;
        }

        public void setId(int id) {
            this.id = id;
        }

        public void setText(String text) {
            this.text = text;
        }
    }

验证.java

   package ru.trust.appVerification;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.*;
import java.util.stream.*;
import javax.annotation.PostConstruct;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.AjaxBehaviorEvent;
import org.primefaces.event.SelectEvent;

@ManagedBean
@ViewScoped

public class Verify implements Serializable {

     public List<Answer> getAnswers() {
        List<Answer> answers = new ArrayList<Answer>();

        answers.add(new Answer(1, "Yes"));
        answers.add( new Answer(2, "No"));
        return answers;
    }

    public void onRowSelectTest(SelectEvent event) {
        Answer answer = (Answer)event.getObject();

    }
}

我的代码有什么问题或者 Internet Explorer 8 根本不支持它吗?

最佳答案

尝试将其添加到 xhtml 的顶部:

<?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"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:p="http://primefaces.org/ui"
          xmlns:f="http://java.sun.com/jsf/core">
        <h:head>

        <f:facet name="first">
          <meta http-equiv="X-UA-Compatible" content="IE=edge" />
         <meta content="text/html; charset=UTF-8" http-equiv="content-type"/>
        </f:facet>
       // other head code goes here

       </h:head>

代替:

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:f="http://xmlns.jcp.org/jsf/core">

    <h:head>
    </h:head>

我遇到了类似的问题。添加这个对我来说效果很好。

关于java - Primefaces 数据表 onrowselect 事件在 IE 8 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32440708/

相关文章:

java - Java 中的对象创建语法

java - 错过 Spring 的 Activity

java - 基于 LDAP Active Directory 组搜索,未向下钻取以包含多个 OU

jsf-2 - Primefaces:单击 p:column 内的 div 时不会调用 rowSelect 方法

css - 如何在 Primefaces 中垂直对齐 inputText 和 commandButton

IE 8 问题中的 Javascript 数组

java - 如何通过 REST 在 Sakai 中获取作业的内容

primefaces - 如何制作 p :menu scrollable in primefaces?

javascript - IE 8 安全设置阻止 javascript 发送 xmlHTTPRequest

jquery - 为什么IE8渲染superfish菜单错误?