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/

相关文章:

javascript - primefaces jQuery用户界面选项卡

javascript - 尝试从目标事件获取数据时在 IE8 中出现问题

javascript - IE 可在 DOM 上缩放背景图像

java - 为什么我的程序有时会卡住?

java - 移动企业应用平台(MEAP)推荐?

css - 覆盖 Bootstrap Box-Sizing 通用选择器

java - 转换器类抛出异常 java.lang.IllegalArgumentException

internet-explorer - 使用 IE9 测试 IE8 和 IE7?

java - 在 Java 中的双向链表上设置头部和尾部引用真的会从内存中清除它吗?

java - 使用 Apache PdfBox 提取两个书签之间的文本